Re: Who remembers about the floating point calculator?

2009-02-01 Thread Andrew Collier


On 1 Feb 2009, at 13:00, Frode Tennebø wrote:


On Saturday 31. January 2009, Andrew Collier wrote:

Hi,

AS you may know, if you CALL a machine code routine with some
parameters, they are pushed onto the ROM's floating point calculator
stack. I'm trying to use this, but having some difficulty getting the
numbers back out again. Can anyone spot what's going wrong?


Since no one else has come to the rescue I'll give it a shot from 20
years old memory.  The sequence seems right at first glance, I would
therefore look at something external.  first thing to check is that  
you
are not using bank D and that interrupts are disabled.  Then check  
that

it is indeed 32768 and 81920 which are stored on the stack initially.



Hi,

Thanks, I've found the problem now. What I'd forgotten was that you  
get two FPC stack entries for each parameter - the first describes the  
type (which allows for CALL statements with string arguments) and this  
is what was coming out as 0xc0 every time.


Cheers,
Andrew

--
 ---   Andrew Collier 
   http://www.intensity.org.uk/ ---
  --




Re: Who remembers about the floating point calculator?

2009-02-01 Thread Frode Tennebø
On Saturday 31. January 2009, Andrew Collier wrote:
> Hi,
>
> AS you may know, if you CALL a machine code routine with some
> parameters, they are pushed onto the ROM's floating point calculator
> stack. I'm trying to use this, but having some difficulty getting the
> numbers back out again. Can anyone spot what's going wrong?

Since no one else has come to the rescue I'll give it a shot from 20 
years old memory.  The sequence seems right at first glance, I would 
therefore look at something external.  first thing to check is that you 
are not using bank D and that interrupts are disabled.  Then check that 
it is indeed 32768 and 81920 which are stored on the stack initially.

Sorry if this seems obvious, but without knowing more I'm just guessing 
here.

 -Frode
-- 
^ Frode Tennebø | email: fr...@tennebo.com | fr...@irc ^
|  with Standard.Disclaimer; use Standard.Disclaimer;  |


Who remembers about the floating point calculator?

2009-01-31 Thread Andrew Collier

Hi,

AS you may know, if you CALL a machine code routine with some  
parameters, they are pushed onto the ROM's floating point calculator  
stack. I'm trying to use this, but having some difficulty getting the  
numbers back out again. Can anyone spot what's going wrong?


Consider a routine taking two parameters, which I'll designate FROM  
and TO; each are addresses in BASIC format (i.e. between 16384 and  
540671) - I want to separate these into a (page+1) and offset of each  
address, and collect the resulting 16-bit values using JGETINT.


If I call the following routine with CALL (address), 32768, 81920 then  
the values which are returned in HL from the calls to JGETINT are, in  
order:

0x  ; fine, 81920 mod 16384 == 0
0x0005  ; fine, 82910 div 16384 == 5
0x00c0  ; wrong - expect 32768 mode 16384 == 0
0x  ; wrong - expect 32768 mode 16384 == 2

Are there any entry conditions to 0x28 or JGETINT which I need to obey  
and have forgotten about? Have I got the FPC sequence wrong?


Thanks in advance for any useful observations,
Andrew

ENTRY:
cp 2
jp nz, parameter_error

rst 0x28 ; call floating point calculator, stack = FR,TO

db 0x25 ; DUP   ; FR,TO,TO
db 0xe2 ; STK16K; FR,TO,TO,16K
db 0x08 ; MOD   ; FR,TO,TO\16K
db 0x06 ; SWOP  ; FR,TO\16K,TO
db 0xe2 ; STK16K; FR,TO\16K,TO,16K
db 0x09 ; IDIV  ; FR,TO\16K,TO/16K

db 0x1c ; SWOP13; TO/16K,TO\16K,FR

db 0x25 ; DUP   ; TO/16K,TO\16K,FR,FR
db 0xe2 ; STK16K; TO/16K,TO\16K,FR,FR,16K
db 0x08 ; MOD   ; TO/16K,TO\16K,FR,FR\16K
db 0x06 ; SWOP  ; TO/16K,TO\16K,FR\16K,FR
db 0xe2 ; STK16K; TO/16K,TO\16K,FR\16K,FR,16K
db 0x09 ; IDIV  ; TO/16K,TO\16K,FR\16K,FR/16K

db 0x06 ; SWOP  ; TO/16K,TO\16K,FR/16K,FR\16K

db 0x33 ; EXIT

call JGETINT
ld (FROM_os),hl

call JGETINT
ld a,h
or a
jr nz, invalid_argument_error
ld a,l
dec a
cp 32
jr nc, invalid_argument_error
ld (FROM_page),a


call JGETINT
ld (TO_os),hl

call JGETINT
ld a,h
or a
jr nz, invalid_argument_error
ld a,l
dec a
cp 32
jr nc, invalid_argument_error
ld (TO_page),a

--
 ---   Andrew Collier 
   http://www.intensity.org.uk/ ---
  --