Page 3 of 5

Re: How does the floating point math package in BASIC work?

Posted: Tue Jul 08, 2014 11:22 pm
by JeeK
jedie wrote:
JeeK wrote:All C6 opcodes should be D6 ...
I have changed all C6 to D6, see complete code: https://gist.github.com/jedie/22dba94f5b7534f946f9 :D
[..]
I think another bug seems to be in passing the value for D:

Code: Select all

551 D2=(D+I) 'AND &HFFFF
552 'PRINT "SET D=";D2
553 POKE &H4500,D2 ' SET START VALUE
[..]
1000 ' MACHINE CODE IN HEX
1010 ' LDD $4500
1020 DATA FC,45,00
If D is loaded from $4500, the BASIC code has to poke the whole 16 bit value into &H4500 and &H4501.

Code: Select all

POKE &H4500,D2/256
POKE &H4501,255 AND D2
(assuming, that D2 is kept less than 32767)

But here we have only one byte, but even this on the wrong position: if D2 is regarded as 8 bit value, it will be stored into the high byte of the 16 bit value in $4500, while $4501 is not defined at all ...

Re: How does the floating point math package in BASIC work?

Posted: Wed Jul 09, 2014 8:00 am
by jedie
JeeK wrote:If D is loaded from $4500, the BASIC code has to poke the whole 16 bit value into &H4500 and &H4501.

Code: Select all

POKE &H4500,D2/256
POKE &H4501,255 AND D2
You are right. I changed it, see: https://gist.github.com/jedie/22dba94f5 ... /revisions

But also, doesn't work :(

Re: How does the floating point math package in BASIC work?

Posted: Wed Jul 09, 2014 8:41 am
by JeeK
jedie wrote:
JeeK wrote:If D is loaded from $4500, the BASIC code has to poke the whole 16 bit value into &H4500 and &H4501.

Code: Select all

POKE &H4500,D2/256
POKE &H4501,255 AND D2
You are right. I changed it, see: https://gist.github.com/jedie/22dba94f5 ... /revisions

But also, doesn't work :(
This was just a technical bug fix, in my previous post viewtopic.php?f=8&t=4887&start=10#p11382 I outlined some doubt about the entry point ...

Re: How does the floating point math package in BASIC work?

Posted: Wed Jul 09, 2014 8:46 am
by jedie
JeeK wrote:Whatever you expecting, I doubt that $8C37 does it in this way. A $942D it can be seen that A is loaded from $50 (destroys D) and B is stored as exponent ...??? I can't imagine this is a usable entry point... (referring to the disassembly you provided in the corresponding forums thread).
If compare it to the D64 ROM this entry point looks more like that you are expecting. Maybe some information has been intermixed between various ROM versions (D32 ROM and D64 ROM in D32 mode)?
Maybe there is a other ROM entry point which can be used?
I collect all interesting parts from Stew's D64ROM.txt, see: viewtopic.php?f=5&t=4370&p=11388#p11378
$92DA ;load FPA2 from varptr X
$93BF ;load variable into FPA1 (X is varptr)
$9FD0 ;assign D to FPA1
$9C3E ;assign contents of $52 / $53 to FPA1
also interesting:
$9587 ;convert FPA1 to string at $3DA
$93DA ;assign FPA1 to variable store $40 - $44
$93D5 ;assign FPA1 to variable store $45 - $49
Maybe i should do something with VARPTR ?

The used $8C37 ROM code:

Code: Select all

*** assign D to FPA1 (signed)

8C37 0F06       CLR   <$06      ;numeric / string flag
8C39 DD50       STD   <$50
8C3B C690       LDB   #$90
8C3D 7E942D     JMP   $942D     ;signed assign!
The "$9FD0 ;assign D to FPA1" part:

Code: Select all

9FD0 0F06       CLR   <$06      ;numeric / string flag
9FD2 DD52       STD   <$52
9FD4 C690       LDB   #$90      ;meaningless
9FD6 7E9C3E     JMP   $9C3E     ;assign contents of $52 / $53 to FPA1
D would be stored at $52 / $53 and then call $9C3E insert in FPA1...

I will not try to store my value with POKE at $52 / $53 and call $9C3E
EDIT: Doesn't work, code: https://gist.github.com/jedie/22dba94f5 ... 0fac864dbf diffs: https://gist.github.com/jedie/22dba94f5 ... /revisions

Next idea: POKE to $1052 / $1053 and move it in machine code part to $52 / $53
EDIT2: Done with: https://gist.github.com/jedie/22dba94f5 ... 4fda40945a diff: https://gist.github.com/jedie/22dba94f5 ... /revisions
Also not work as expected :(

Re: How does the floating point math package in BASIC work?

Posted: Wed Jul 09, 2014 9:01 am
by JeeK
JeeK wrote:
jedie wrote:
JeeK wrote:If D is loaded from $4500, the BASIC code has to poke the whole 16 bit value into &H4500 and &H4501.

Code: Select all

POKE &H4500,D2/256
POKE &H4501,255 AND D2
You are right. I changed it, see: https://gist.github.com/jedie/22dba94f5 ... /revisions

But also, doesn't work :(
This was just a technical bug fix, in my previous post viewtopic.php?f=8&t=4887&start=10#p11382 I outlined some doubt about the entry point ...
Looked at my (undocumented) disassembly and found that your commented listing is incomplete
(https://gist.github.com/jedie/6573826). There are lines missing!
So, the entry point seems right ... back to the BASIC test program which does not behave properly.

EDIT: The assembler code should be reverted to the previous version:

Code: Select all

LDD $1052
JSR $9C3E  ; D to FACC0

Re: How does the floating point math package in BASIC work?

Posted: Thu Jul 10, 2014 8:38 am
by JeeK
JeeK wrote: [..]
EDIT: The assembler code should be reverted to the previous version:

Code: Select all

LDD $1052
JSR $9C3E  ; D to FACC0
What about this? Does it work if changed back?

Re: How does the floating point math package in BASIC work?

Posted: Thu Jul 10, 2014 9:31 am
by jedie
Damn!!! I used all the time the "D32 Enhanced ROM v2.2 by Stephen J. Woolham" and not the origin :(

I retested all reversions from https://gist.github.com/jedie/22dba94f5 ... /revisions with the origin ROM and with JSR $9C3E and JSR $8C37 but also with unsatisfying results...

Re: How does the floating point math package in BASIC work?

Posted: Thu Jul 10, 2014 9:42 am
by jedie
I tried a other variant, see: https://gist.github.com/jedie/22dba94f5 ... /revisions

Load D from $1052 call "Add D to FPA0" and then use Reg X for transfer the FPA0 values to $70xx

But same result as many other variants: Only the first Value (the FPA0 exponent) will increased by **2

Re: How does the floating point math package in BASIC work?

Posted: Thu Jul 10, 2014 9:56 am
by jedie
I try my new filter stuff to analyse the xroar trace...

Get this, e.g.:

Code: Select all

... [Skip 21546 lines] ...
4003| bd8c37      JSR     $8c37               cc=a0 a=00 b=06 dp=00 x=4000 y=890b u=0000 s=7f1f | $4003: UNKNOWN
... [Skip 78 lines] ...
4006| 9e4f        LDX     <$4f                cc=88 a=00 b=0d dp=00 x=83c0 y=890b u=0000 s=7f21 | $4006: UNKNOWN
4008| bf704f      STX     $704f               cc=88 a=00 b=0d dp=00 x=83c0 y=890b u=0000 s=7f21 | $4008: UNKNOWN
400b| 9e51        LDX     <$51                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $400b: UNKNOWN
400d| bf7051      STX     $7051               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $400d: UNKNOWN
4010| 9e52        LDX     <$52                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4010: UNKNOWN
4012| bf7052      STX     $7052               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4012: UNKNOWN
4015| 9e54        LDX     <$54                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4015: UNKNOWN
4017| bf7054      STX     $7054               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4017: UNKNOWN
401a| 39          RTS                         cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f23 | $401a: UNKNOWN
... [Skip 21579 lines] ...
4003| bd8c37      JSR     $8c37               cc=a0 a=00 b=07 dp=00 x=4000 y=890b u=0000 s=7f1f | $4003: UNKNOWN
... [Skip 78 lines] ...
4006| 9e4f        LDX     <$4f                cc=88 a=00 b=0d dp=00 x=83e0 y=890b u=0000 s=7f21 | $4006: UNKNOWN
4008| bf704f      STX     $704f               cc=88 a=00 b=0d dp=00 x=83e0 y=890b u=0000 s=7f21 | $4008: UNKNOWN
400b| 9e51        LDX     <$51                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $400b: UNKNOWN
400d| bf7051      STX     $7051               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $400d: UNKNOWN
4010| 9e52        LDX     <$52                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4010: UNKNOWN
4012| bf7052      STX     $7052               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4012: UNKNOWN
4015| 9e54        LDX     <$54                cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4015: UNKNOWN
4017| bf7054      STX     $7054               cc=84 a=00 b=0d dp=00 x=0000 y=890b u=0000 s=7f21 | $4017: UNKNOWN
I see that X is e.g.: $83c0 and $83e0
But in my BASIC PRINT's i see only $83 (the FPA0 exponent) and not $c0 and $e0 (the FPA0 MS)

But it's also clear that NMS,NLS,LS and SIGN is $00 :?

EDIT: Hm! LDD is not in the trace! Hm...

Re: How does the floating point math package in BASIC work?

Posted: Thu Jul 10, 2014 11:13 am
by jedie
Playing with the trace filter, i get the complete trace of the test program.

From machine code call $4000 until RTS: https://gist.github.com/jedie/4c884924d6a4e393f4c9

I have input the value 2...

I searched for all ST ops and see that there addresses used to store things are only:
4f
50
51
52
54
63

From https://github.com/6809/rom-info/blob/m ... agon32.txt :

Code: Select all

$4f-$54 ; Floating Point Accumulator Num 1
$4f ; Exponent
$50-$53 ; Mantissa
$50-$51 ; 16 bit values in FAC stored here
$52-$53 ; VARPTR of variables is stored here {1}
$54 ; Mantissa Sign (0x00 positive, 0xff negative)
$55 ; Temp sign of FAC
$63         ; CoCo - Extended precision byte {1} - also Dragon ?
So $63 is the "Extended precision byte" ? Don't know what function this is.