ABS key (BD) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The G key in E mode without shifts produces the functionABS; it requires one numeric operand X, and the value of the function is the same as X except that it is always positive: ABS(-X) = X. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code BD first to 0E, then to EA, and adds the priority 10h/16d. Code + priority 10EAh are now pushed on to the machine stack (270D S PUSH PO) while the expression following ABS is evaluated. When the code is taken off the machine stack (2734 S LOOP), it is converted (2773 S TIGHTER) from EA to 2A, the calculator offset for 346A abs. abs subroutine 346A Called from 0028 FP CALC by offset 2A; the executive routine for the ABS function. Not otherwise called from ROM, butcan be called direct from m/c. Replaces a number X by its absolute value ABS X. Input parameters: HL points to the first byte of the FP number X; if the call is from FP CALC this will be the last number on the calculator stack, but this isn't necessary for direct calls. Action: load FF into the B register. Exit: through 3474 NEG TEST (346E negate), which given FFin B zeroes the sign bit of either small integer or full format FP numbers. Output parameters: B holds FF - A holds zero - the sign of the FP number has been made positive if necessary. Called from: 2320 CIRCLE 23A3 DR SIN NZ (3 times) 23C1 DR PRMS (twice) 247D CD PRMS1 2DF2 PF NEGTVE 3783 get-argt 37AA cos Rems: 346E negate resets sign bit 3474 NEG TEST point of entry; B becomes 80 3483 INT CASE zeroes C register for abs ABSOLUTE MAGNITUDE FUNCTION see 346A abs ACS key (B6) see also commands, functions and operators, KEYBOARD SCANNING, 0246 extended mode table (c) The W key in E mode with either shift produces the function ACS; it requires one numeric operand X, and the value of the function is the number in radians whose COS is X. If you are unsure about radians, see index entry on 3783 get-argt. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B6 first to 07, then to E3, and adds the priority 10h/16d. Code and priority 10E3h are now pushed on to the machine stack (270D S PUSH PO) while the expression following ACS is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E3 to 23, the calculator offset for 3843 acs. acs subroutine 3843 Called from 0028 FP CALC by offset 23; the executive routine for the ACS function. Finds the number Y = arc cos X whose COS is X. Y is in radians; if you are unsure about radians, see index entry on 3783 get-argt. Not called from ROM; can be used in m/c either through the calculator or direct. Input parameters: the number X whose arc cos is to be found must be the last value on the calculator stack, even for direct calls. Action: use the calculator to find arc sin X and subtractit from pi/2. Exit: RET Output parameters: arc cos X is left as the last number on the calculator stack - mem-0 to mem-2 corrupted. Rems: 3449 series-06 indirectly uses Chebyshev polynomials ADD BACK subroutine 3004 see also precision In rounding decimal numbers, the usual rule is simply todrop the last digit if it is four or less, but to increase the last remaining digit if the last one is five or more. With binary numbers the rule is similar but simpler; drop the last digit, and increase the last remaining if the lastdigit was one. In other words, drop the last digit but add it tothe rest of the number. This is what this subroutine is for - itis only called if the last digit was one, so all it actually does is increment the four-byte mantissa of a FP number by one. Input parameters: D'E'DE contain the four mantissa bytes of a FP number. Action: increment E and then D, returning after each if te result isn't zero; FF would become zero - increment E' - jump on to ALL ADDED if the result isn't zero - increment D'. _300D_ALL_ADDED: exchange back to the main registers. Exit: RET. Output parameters: same as input, except for the increasein the mantissa - the Z flag is set if all four bytes went from FF to 00. Called from: 2FE5 ONE SHIFT 3186 NORML NOW ADD CHAR subroutine 0F81 Adds a character at the cursor position to the current BASIC line in the editing or input area in the work space. 1219 RAM SET makes it the output routine of the "R" channel on start-up from the initial channel information list 15AF; this channel is used to output from sources other than the keyboard, eg in copying from the program to the editing area. Not otherwise called from ROM, but used as exit routine by other subroutines. Input parameters: A holds the character byte - 5C5B K CUR holds the address where it is to go; but this address is occupied by the following character. Action: zero bit zero of 5C41 MODE; cancels extended mode - call 1652 ONE SPACE to make a space at the address in K CUR. _0F8B_ADD_CH_1 (entry here from 0F6C ED CONTR, with the space already made): insert the byte - move on the pointer - load the pointer back into K CUR. Exit: RET. Output parameters: A unchanged - HL decremented by 1 - DE holds the cursor address - BC corrupted. Exit from: 0F38 ED LOOP (twice) 107C ED GRAPH ADD CH 1 0F8B (0F81 ADD CHAR) Exit from: 0F6C ED CONTR 0F81 ADD CHAR addend see also CALCULATE Addend, augend, dividend, minuend, multiplicand, subtrahend are all rather old-fashioned jargon terms; perhaps ithelps to know that the Latin endings "-and, -end" mean "what hasto be done", as in "agenda", things to be done. _Addend: number to be added - to some other number, the _augend - making a_sum. _Subtrahend: number to be subtracted - from some other number, the_minuend - making a_difference. _Multiplicand: number to be multiplied - by some other number, the_multiplier - making a_product. _Dividend: number to be divided - by some other number, the_divisor - making a_quotient. In C = A + B, B is the addend, A the augend. In binary FP calculator operations, the number to be operated_with is always last value on the calculator stack, and the number to be operated_on second last; in the addition operation, of course, they are interchangeable, but pedanticallythe addend means the last value, eg at 3014 addition. 2FDD SHIFT FP smaller number is in addend position 2FFB ZEROS 4/5 zeroes addend 3004 ADD BACK zeroes addend on overflow 3014 addition addend is at top of stack, augend second 303E FULL ADDN smaller number put in addend position 3055 SHIFT LEN addend adjusted by right shift ADDEND 0 2FF9 (2FDD SHIFT FP) Jumps from: 2FDD SHIFT FP addition subroutine 3014 Called from 0028 FP CALC by offset 0F; the executive routine for the "+" operator. Adds an addend Y to an augend X; see the index entry "addend" for these tiresome expressions. Both X and Y must be in FP format, and they must be held consecutively, with the five bytes of Y following those of X. Called many times from ROM, always through the calculator; could also be called direct. Addition of full format FP numbers isn't at all a simpleoperation: see the index entry on 303E FULL ADDN. If both numbers to be added are in "small integer" format, and the result is also within "small integer" range, things are much simpler, and this is the action described here. However, there is a serious error over the "wrong number", -10000h/-65536d; seeunder "wrong number". Input parameters: HL and DE address the first bytes of X and Y respectively; if the routine is called through 0028 FP CALC they are the last two values on the calculator stack, but this isn't necessary for direct calls, provided the numbers are held consecutively. They may be in either small integer or full FP format. Action: check the exponent bytes of X and Y - if either is non-zero jump on to 303E FULL ADDN; either X or Y isn't in small integer format - (both are small integers) get the value of X; if X is negative this will be 10000h/65536d minus its absolute value, and the same for Y - get the sign byte of Y - get the value of Y - add the values, with result Z, say; if X and Y are both positive and Z is "big", ie too big for a small integer, this produces a carry. But if X and Y are both negative, carry is produced if Z is small, and_not produced if Z is big. If one is negative and the other positive, Z is bound to be small; there will be carry if Z is positive, no carry if it is negative - add the two sign bytes, with the carry from the last result; the sign bytes are 00 for positive and FF for negative, so +X +Y = +Z (Z small) gives 00 + 00 + 00 = 00 +X +Y = +Z (Z big) gives 00 + 00 + 01 = 01 +X -Y = +Z (Z small) gives 00 + FF + 01 = 00 +X -Y = -Z (Z small) gives 00 + FF + 00 = FF -X +Y = +Z (Z small) gives FF + 00 + 01 = 00 -X +Y = -Z (Z small) gives FF + 00 + 00 = FF -X -Y = -Z (Z small) gives FF + FF + 01 = FF -X -Y = -Z (Z big) gives FF + FF + 00 = FE - rotate the result of the addition right, with lo bit going to the hi bit and into the carry - use ADC A,00 to add back the carry, so 00000000b/00h -> 00000000b/00h -> 00000000b/00h 00000001b/01h -> 10000000b/80h -> 10000001b/81h 11111111b/FFh -> 11111111b/FFh -> 00000000b/00h 11111110b/FEh -> 01111111b/7Fh -> 01111111b/7Fh - if the result isn't zero, jump on to ADDN OFLW; Z isn't a small integer - (result is a small integer) use SBC A,A to subtract the carry from zero; this restores the former value 00 or FF, thus giving the correct sign byte for Z - put the sign byte in the second byte of the result - put the absolute value Z in the third and fourth bytes - return. _363C_ADDN_OFLW: set the pointers back to the first bytesof X and Y. [For the remarks in the notes on -65536d see under "wrong number".] Exit: RET if the whole operation involved nothing but small integers. - if either of the input values was in full FP format, exit to 303E FULL ADDN, which carries out full exponent/mantissaaddition. - if the result of the trial addition was too big, through ADDN OFLW into FULL ADDN. Output parameters (all cases): HL points to the first byte of the result - DE to the first byte after it, which will now be the stack end if the result is on the calculator stack. The calculator and calculator memory aren't used. Called from: 03F8 BEEP 1DAB NEXT 235A C ARC GE1 23A3 DR SIN NZ 23C1 DR PRMS (4 times) 2425 ARC LOOP 2439 ARC START (twice) 2497 DRAW SAVE 25F8 S RND 2CDA NXT DGT 1 2D40 NXT DGT 2 2DA2 FP TO BC 3449 series-06 3453 G LOOP 36C4 EXP 373D GRE 8 3783 get-argt (3 times) 37B7 C ENT 37FA CASES (twice) 3833 asn (twice) Rems: 2D8E INT STORE no twos complementing required 2F9B PREP ADD is called by addition for FP numbers 2FBA FETCH TWO is called by addition for FP numbers 3004 ADD BACK effect of overflow in FP numbers 300F SUBTRACT changes sign and goes into addition 303E FULL ADDN explains operation of FP number addition 316E SHIFT ONE 5th mantissa byte always 0 after addition 335B CALCULATE example of binary operation addition of line or variable see 08B6 ME CONTRL under 0605 SAVE ETC ADDN OFLW 303C (3014 addition) Jumps from: 3014 addition ADD REP 6 309F (303E FULL ADDN) Jumps from: 3055 SHIFT LEN address dropping This term is used for various programming devices by which a subroutine is made to return to an address different from its normal return point. a) when the subroutine call instruction is followed by a string of "literals" or "offsets" read by the subroutine - chiefly 0028 FP CALC, also 335B CALCULATE and 0008 ERROR 1; see the index entries. b) when a subroutine has been called from within a subroutine; return address 1 is below return address 2 on the stack, so POPping address 2 means return will be to address 1. c) when the address of the start of a loop has been PUSHed on the stack, so that looping can be effected over long distances by RETs instead of JRs or JPs. The looping address must be dropped to escape from the subroutine. d) by resetting the stack pointer. 0055 ERROR 3 machine stack reset to error address 1024 ED ENTER two addresses dropped 1031 ED EDGE to return via 0F38 ED LOOP 15AB MAIN ADD2 report address dropped 1BEE CHECK END two return addresses dropped 1C11 CLASS 05 drop 1B52 SCAN LOOP 1C4E CLASS 02 drop 1B52 SCAN LOOP 1C96 PERMS drop 1B52 SCAN LOOP