Routines 
Prev: 13418  Up: Map  Next: 13458 
Used by the routine at subtract.
The address of this routine is found in the table of addresses. It is called via the calculator literal 27 by the routines at CD_PRMS1, get_argt, cos, atn, asn and acs. It is also called indirectly via fp_calc_2.
This subroutine performs its unary operation by changing the sign of the 'last value' on the calculator stack.
Zero is simply returned unchanged. Full five byte floatingpoint numbers have their sign bit manipulated so that it ends up reset (for 'abs') or changed (for 'negate'). 'Small integers' have their sign byte set to zero (for 'abs') or changed (for 'negate').


negate  13422  CALL TEST_ZERO  If the number is zero, the subroutine returns leaving 00 00 00 00 00 unchanged.  
13425  RET C  
13426  LD B,0  B is set to 0 for 'negate'.  
This entry point is used by the routine at abs.


NEG_TEST  13428  LD A,(HL)  If the first byte is zero, the jump is made to deal with a 'small integer'.  
13429  AND A  
13430  JR Z,INT_CASE  
13432  INC HL  Point to the second byte.  
13433  LD A,B  Get 255 for 'abs', 0 for 'negate'.  
13434  AND 128  Now 128 for 'abs', 0 for 'negate'.  
13436  OR (HL)  This sets bit 7 for 'abs', but changes nothing for 'negate'.  
13437  RLA  Now bit 7 is changed, leading to bit 7 of byte 2 reset for 'abs', and simply changed for 'negate'.  
13438  CCF  
13439  RRA  
13440  LD (HL),A  The new second byte is stored.  
13441  DEC HL  HL points to the first byte again.  
13442  RET  Finished.  
The 'integer case' does a similar operation with the sign byte.


INT_CASE  13443  PUSH DE  Save STKEND in DE.  
13444  PUSH HL  Save pointer to the number in HL.  
13445  CALL INT_FETCH  Fetch the sign in C, the number in DE.  
13448  POP HL  Restore the pointer to the number in HL.  
13449  LD A,B  Get 255 for 'abs', 0 for 'negate'.  
13450  OR C  Now 255 for 'abs', no change for 'negate'.  
13451  CPL  Now 0 for 'abs', and a changed byte for 'negate'; store it in C.  
13452  LD C,A  
13453  CALL INT_STORE  Store result on the stack.  
13456  POP DE  Return STKEND to DE.  
13457  RET 
Prev: 13418  Up: Map  Next: 13458 