[Index] [Previous] [Next]

2.5 Sign Magic

A group of functions for testing and changing the sign of an fp number.

 

FTestSign_tail

When FACCUM is non-zero, RST FTestSign jumps here to get the sign as an integer : 0x01 for positive, 0xFF for negative.

Load A with the most-significant byte of FACCUM, the top-most bit of which holds the sign. Then we LXI into SignToInt.
09DA 3A7101 FTestSign_tail LDA FACCUM+2
09DD FE.. CPI ..

 

InvSignToInt

Inverts the sign byte in A before falling into SigntoInt.

Simply invert A.
09DE 2F InvSignToInt CMA

 

SignToInt

Converts the sign byte in A to 0x01 for positive, 0xFF for negative.

Get bit 7 into carry flag and subtract from itself with carry. If A was +ve then it is now 0, whereas if A was -ve then A is now FF.
09DF 17 SignToInt RAL
09E0 9F SBB A
Return if A is FF, otherwise return with A=1.
09E1 C0 RNZ
09E2 3C INR A
09E3 C9 RET

 

Sgn

Returns an integer that indicates FACCUM's sign. We do this by a simple call to FTestSign which gets the answer in A, then fall into FCharToFloat to get that answer back into FACCUM.

Get FACCUM's sign in A. A will be 0x01 for positive, 0 for zero, and 0xFF for negative.
09E4 EF Sgn RST FTestSign

 

FCharToFloat

Converts the signed byte in A to a floating-point number in FACCUM..

Get the char value in A as an unnormlised floating-point number.
09E5 0688 FCharToFloat MVI B,88 ie 2^8
09E7 110000 LXI D,0000
09EA 217201 LXI H,FACCUM+3
09ED 4F MOV C,A
]Set FACCUM's exponent to 2^8, in preparation for a jump into FNormalise.
09EE 70 MOV M,B
09EF 0600 MVI B,00
Set FTEMP to 0x80, another preparation step for FNormalise.
09F1 23 INX H
09F2 3680 MVI M,80
Get sign into carry flag and jump to FNormalise.
09F4 17 RAL
09F5 C35B08 JMP FNormalise

 

Abs

FACCUM = |FACCUM|.

Return if FACCUM is already positive, otherwise fall into FNegate to make it positive.
09F8 EF Abs RST FTestSign
09F9 F0 RP

 

FNegate

Negate FACCUM's sign, ie FACCUM = -FACCUM.

09FA 217101 FNegate LXI H,FACCUM+2
09FD 7E MOV A,M
09FE EE80 XRI 80
0A00 77 MOV M,A
0A01 C9 RET

 


[Index] [Previous] [Next]