The OP Registers

The OP registers are not really registers, but are a block of memory that is used to store data, such as floating point values, to pass as arguments to system routines that operate on such values, and to retrieve the value returned by them. They are most often used with the math routines, but are also used to store variable names for user variable manipulation routines.

There are six OP registers, named OP1 through OP6. Each is 11 bytes long, and if used to store a floating-point value, has the following format:

The first byte (_OP1) is the sign byte, which is either $00, $01, $80, or $81.
The bits are composed as follows:
Bit 0 = 0 if real, 1 if complex
Bits 1-6 = 0
Bit 7 = 0 if positive, 1 if negative
Complex numbers are stored in two OP registers, with the real portion in one register and the imaginary portion in the following register.

The next two bytes are the exponent bytes (_OP1EXPM and _OP1EXPL). The exponent is calculated by subtracting $FC00 from this word (don't forget to store the least significant byte first). This indicates how many places to move the decimal point.

The next 7 bytes are the mantissa (starting at _OP1M) in BCD format, a sequence of 14 digits.

The last byte (_OP1EXT) is an extra byte that is not used.

Example:

     ld hl,FPNum1
     call _MOV10TOOP1
     ret

FPNum1: ; 3.1415926535900e+00 = pi
     .db $00, $00, $FC, $31, $41, $59, $26, $53, $59, $00
FPNum2: ; 1.2000000000000e+02 = 120
     .db $00, $02, $FC, $12, $00, $00, $00, $00, $00, $00
FPNum3: ;-3.6512000000000e-04 = -.00036512
     .db $80, $FC, $FB, $36, $51, $20, $00, $00, $00, $00

Back to the Main Page