hi. i am porting some ml routines from c64 to c128. now i used in the c64 code some calls to BASIC to convert a 4-byte (long) integer to float, i used this two routines and now i need to know where to find the equivalents in the BASIC 7.0 Rom.
ulongtofac = $bc4f
factomem = $bbd0
oh, and btw before i have to consult "mapping the c128", where is FAC and ARG located on the c128?
Quote from: hannenz on January 20, 2008, 11:21 PM
hi. i am porting some ml routines from c64 to c128. now i used in the c64 code some calls to BASIC to convert a 4-byte (long) integer to float, i used this two routines and now i need to know where to find the equivalents in the BASIC 7.0 Rom.
ulongtofac = $bc4f
factomem = $bbd0
oh, and btw before i have to consult "mapping the c128", where is FAC and ARG located on the c128?
All of the info you are seeking is available in the C-128 Alive archives.
Check this:
$63-$67 FAC; Floating-point accumulator 1 $63=exponent, $64...$67=mantissa, $68=sign
$63-$67 ARG; Floating-point accumulator 2 $6a=exponent, $6b...$6e=mantissa, $6f=sign
ulongtofac = $bc4f => $af63 (jump table) $8bd4 (directly)
factomem = $bbd0 => $af66 (jump table) $8c00 (directly)
WTE
hey, cool - thank you very much!!
hi again.
the factomem at $8c00 is ok but for ulongtofac i need a routine that converts a 32-bit (4-byte) long integer into a float. There is such a routine in BASIC 2.0.
$8bd4 seems to copy a float from ROM (mem) into FAC#1; that's not what i need...
I found out myself in the meantime; for all that are interested:
To convert a 4-byte unsigne integer into a float, do the following:
copy the 4 bytes to FAC#1 ($64-$67)
ldx #$a0
lda #0
sec
jsr $8c7b
FAC#1 will now conatin the float representation of the 4-byte unsgined integer...
This is a jump six bytes beyond the "2-byte-to-float" routine at $8c75, which bypasses the clearing of the "high word" at $66/$67 and it is necessary to load .X with $a0 and set the carry flag vefor jumping; the "lda #0" i think is in fact unnecessary but i found it like that in an assembler book for c64 from which i converted all this to c128, so it doesn't harm (except the 2 cycles) and just to be sure... ;)
for signed integers it should go something like
lda $64
eor #$ff
asl
lda #0
ldx #$a0
jsr $8c7b
but this is untested
EDIT: this is were i got some really useful information, quite nice site btw, so i think i should share this: http://members.tripod.com/~rvbelzen/