Author Topic: long to fac, fac to mem  (Read 898 times)

0 Members and 1 Guest are viewing this topic.

hannenz

  • Guest
long to fac, fac to mem
« 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.

Code: [Select]
ulongtofac = $bc4f
factomem = $bbd0

oh, and btw before i have to consult "mapping the c128", where is FAC and ARG located on the c128?

Offline BigDumbDinosaur

  • C128 user
  • ******
  • Posts: 757
  • Age: 67
  • Location: Midwest USA
  • Activity:
    0%
  • Country: us
  • Reputation: 64
  • Gender: Male
  • Yuh think donkeys are dumb, try a politician!
  • With us since: 02/01/1970
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
    • View Profile
    • BCS Technology Limited
Re: long to fac, fac to mem
« Reply #1 on: January 21, 2008, 01:40 AM »
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.

Code: [Select]
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.
x86?  We don't got no x86.  We don't NEED no stinking x86!

Offline wte

  • C64 user
  • *****
  • Posts: 342
  • Location: Frankfurt
  • Activity:
    0%
  • Country: de
  • Reputation: 10
  • Gender: Male
  • With us since: 18/03/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • http://blog.c128.net
Re: long to fac, fac to mem
« Reply #2 on: January 21, 2008, 07:18 AM »
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

hannenz

  • Guest
Re: long to fac, fac to mem
« Reply #3 on: January 22, 2008, 06:46 AM »
hey, cool - thank you very much!!

hannenz

  • Guest
Re: long to fac, fac to mem
« Reply #4 on: January 25, 2008, 09:46 PM »
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:

Code: [Select]
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
Code: [Select]
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/
« Last Edit: January 26, 2008, 10:26 AM by hannenz »

 



Back to top