Prev: 13357 Up: Map Next: 13385
13372: THE 'EXCHANGE' SUBROUTINE (offset 1)
Used by the routine at compare.
The address of this routine is found in the table of addresses. It is called via the calculator literal 1 by the routines at BEEP, OPEN, FOR, NEXT_LOOP, CIRCLE, DRAW, CD_PRMS1, INT_TO_FP, PRINT_FP, series, n_mod_m, int, ln, get_argt, tan, atn and to_power.
This binary operation 'exchanges' the first number with the second number, i.e. the topmost two numbers on the calculator stack are exchanged.
Input
DE Address of the first byte of the second number
HL Address of the first byte of the first number
Output
HL Address of the first byte of the second number
exchange 13372 LD B,5 There are five bytes involved.
SWAP_BYTE 13374 LD A,(DE) Each byte of the second number.
13375 LD C,(HL) Each byte of the first number.
13376 EX DE,HL Switch source and destination.
13377 LD (DE),A Now to the first number.
13378 LD (HL),C Now to the second number.
13379 INC HL Move to consider the next pair of bytes.
13380 INC DE
13381 DJNZ SWAP_BYTE Exchange the five bytes.
13383 EX DE,HL Get the pointers correct as 5 is an odd number.
13384 RET Finished.
Prev: 13357 Up: Map Next: 13385