Re: A83: Op1 to anything?


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

Re: A83: Op1 to anything?




Well.. the op registers are stored in bcd format (binary coded decimal), which
means that the hexadecimal digits 0-9 are used, but a-f aren't. So the "body"
(i.e. no info about the decimal point) of PI would be 31415926535846h. To
convert this into a normal integer (314159265358462d) you'd have to take the
first nibble (hexadecimal digit), multiply it by 10, add the next nibble,
multiply this by ten and so on. There is most certainly a rom function that
does this, but I'm not sure where it is.

However, for functions like f.ex. _getK you get a value in op2 which you don't
have to convert at all! If you were to check for the cursor keys or 2nd, you'd
know that the byte at op2+2 (first byte of that "body") would represent the
key (some keys on the lower half of the keybord use 3-digit numbers, so
they're a bit trickier), but that byte wouldn't be the number you'd find in
the manual, but instead the bcd version of that number.

Still, in theory all you do is taking the hex digits one at a time and adding
them to some result variable after multiplying that variable with ten.

Linus

On 24-May-98, michael wrote:

>I was woundering after i do a floating point routine in my program if there
>is any way to extract that number in OP1 to hl, or a (probably not because
>it is one byte, but mabye) , or anything else?  

>                                        Mike




References: