Prev: 342D Up: Map Next: 3449
343C: THE 'EXCHANGE' SUBROUTINE (offset +01)
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 +01 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 343C LD B,$05 There are five bytes involved.
SWAP_BYTE 343E LD A,(DE) Each byte of the second number.
343F LD C,(HL) Each byte of the first number.
3440 EX DE,HL Switch source and destination.
3441 LD (DE),A Now to the first number.
3442 LD (HL),C Now to the second number.
3443 INC HL Move to consider the next pair of bytes.
3444 INC DE
3445 DJNZ SWAP_BYTE Exchange the five bytes.
3447 EX DE,HL Get the pointers correct as 5 is an odd number.
3448 RET Finished.
Prev: 342D Up: Map Next: 3449