Re: A83: Floating Point Stack


[Prev][Next][Index][Thread]

Re: A83: Floating Point Stack




In accordance with the prophecy, Ted21@aol.com uttered:


> I have been working more on my math programs and I was wondering if anyone 
> can help me with the Floating Point Stack.  I have the following:

> #define FPmov(from,to)  ld hl,from
> #define / ld de,to
> #define / call FPmov_asm

> FPmov_asm:
>    ld bc,9
>    ldir
>    ret


> and now I would like to be able to create an FPpush and an FPpop.  I know 
> about _pushop1/_popop1 and would prefer not use them.  I really want it to 
> pretty much be like this:
>   FPpush(var)     ;var is pushed onto the stack;
>   FPpop(var)      ;the next piece of the stack it popped into var

> If you can help, I'll appreciate it.

> Ted


Here you go...

_PUSHREAL will push 9 bytes starting at hl onto the stack, and fail if there
is no memory. If you do not wish to go through the trouble of adding an error
handler yourself, you could always check so that you have at least 9 bytes of
free memory before calling this function.

_FPOPREAL will return a pointer to the most recently pushed fp number in hl,
and update the internal fps stack pointer. This means that after calling this
function, you should immediately copy 9 bytes from hl to your own safe mem,
before calling any other system function that may change things in memory.

Hope this helps.

Linus

   - Linus Akesson ------------------------- http://linusworld.cjb.net -
   ::: :::. :.:: :. ::.. : :... ::.: ::. :::: :.:. :: :..: :.. :.: :....

      User-friendly: (adj.) trivialized, slow, incapable, and boring.



References: