Re: Pascal Compiler

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2004-12-13 10:58:57

Hello,

* On Mon, Dec 13, 2004 at 09:57:28AM +0100 Baltissen, GJPAA (Ruud) wrote:
 
> "Astro compiler" just popped up in my mind. Anyone?

I believe I saw this on one disc I transferred last weekend for someone
else. I will have a look, if no one else jumps in.

 
> To use the above subroutine I have to do this:
> 	lda	addr7
> 	sta	addr1
> 	lda	addr8
> 	sta	addr2
> 	ldx	#size
> 	jsr	Loop
> 	lda	addr3
> 	sta	addr9
> The subroutine itself takes 14 bytes (incl. ldx #size), the above routine 23
> !!! So its clear to forget using the subroutine as so.

Why don't you use some ZP locations as pointers? Thus, you do not give
the value itself, but pointers to it? This shortens the subroutine as
well as the calling function.


 
> I use these routines at the moment:
> 
> .eq AscFloat	= $BCF3
> .eq Byte2Real	= $B3A2
> .eq ChrGot		= $0079
> .eq FAC2ARG		= $BC0C
> .eq FACplusARG	= $B86A
> .eq Int2Real	= $B395
> .eq Long2Real	= $BC4F
> .eq Real2Long	= $BC9B			; result at $62
> .eq Real2ZStr	= $BDDD			; result at $0100
> .eq SignFAC		= $BC2B			; negative: A = $FF, pos: A
> = $01
> .eq ScrOut		= $E716			; out put char in A
> .eq Word2Real	= $BC49
> 
> 
> > and output the string ($AB1E)
> 
> Don't use it yet, see above.

I once outputted something on comp.sys.cbm for the numerical functions:

Message-ID: <38d49f55.2317131@news.cis.dfn.de>
http://groups.google.com/groups?selm=38d49f55.2317131%40news.cis.dfn.de

Furthermore, according to the same book (Lothar English, "Das
Maschinensprache Buch für Fortgeschrittene zum Commodore 64", Data
Becker, 1984), there are the following conversion routines:


1. signed byte -> FP:

   LDA #byte
   JSR $BC3C

2. unsigned byte -> FP:

   LDA #byte
   JSR $B3A2

3. signed word (2 byte) -> FP:

   LDY #low
   LDA #high
   JSR $B395

4. unsigned word (2 byte) -> FP:

   LDY #low
   LDA #high
   STY $63
   STA $62
   LDX #$90
   SEC
   JSR $BC49

5. signed 24 bit (3 byte) -> FP:

   LDA #low
   LDX #mid
   LDY #high
   STY $62
   STX $63
   STA $64
   LDA $62
   EOR #$FF
   ASL A
   LDA #0
   STA $65
   LDX #$98
   JSR $BC4F

6. unsigned 24 bit (3 byte) -> FP:

   LDA #low
   LDX #mid
   LDX #high
   JSR $AF87
   JSR $AF7E

7. signed dword (4 byte) -> FP:

   ; $62 (MSB) - $65 (LSB) already contain the bytes!

   LDA $62
   EOR #$FF
   ASL A
   LDA #0
   LDX #$A0
   JSR $BC4F

8. unsigned dword (4 byte) -> FP:

   ; $62 (MSB) - $65 (LSB) already contain the bytes!

   SEC
   LDA #0
   LDX #$A0
   JSR $BC4F



A. FP -> integer

   ; the FP values has to be already in the FAC
   ; exponent should be less than $A0; if not, this will not work,
   ; as the value is to big
   
   JSR $BC9B
   ; result is in $62 (MSB) to $65 (LSB)


As you can read german: If you want, I can scan the appropriate pages of
this book for you (no OCR, just plain PNG files!).


> > Furthermore, that routine - as almost all other routines in BASIC,
> > too - utilizes FP. It first converts the integer to FP, then it
> > converts the FP to ASCII, and then it prints out the ASCII.
> 
> But when going for size, information like that is more then welcome.

AFAIK, the only math function in the C64 that does not utility FP is
$A96B, which converts an ASCII string into a 16-bit-integer (in
$14/$15). This function is used to convert the line number into binary.
Unfortunately, this function has two drawbacks:

- it can only convert values of 0 to 63999
- it has the known "bug" if the value is bigger than this

AFAIK, every other function utilizes the FP format.

Regards,
   Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.