LS-DOS 6.3.1 for the Model 4 - BASIC/OV2 Disassembled

Page Customization

Introduction/Summary

LS-DOS 6.3.1 BASIC/OV2 Disassembly (Model 4)

BASIC/OV2 holds the four program editing commands the Disk BASIC of LS-DOS 6.3.1 keeps out of BASIC/CMD: C for COPY, M for MOVE, F for FIND and S for SEARCH. It is 1376 bytes dated 21 February 1990, the only one of the three BASIC files carrying the date of the 6.3.1 release itself, and it is built from BMOVE/ASM. It is not a load module: newb.jcl assembles it with EDAS's core image switch, so the file is the bytes themselves with no load records at all, and it runs where it is read in, the DOS overlay area at 1E00H to 235FH. The enhancement package of BASIC/CMD reads it there itself rather than letting the DOS command interpreter load it, so the file is never a command a user can type.

MORC at 8234H of that package is the whole of the loading. It saves the command token, calls CLEAR 447EH, which closes every open file and throws every variable away, and NORMNUM 661EH, which walks the program and puts every line reference back into the plain number form; reads OVRLY$ 0069H and skips the load when it already holds 01H; otherwise opens BASIC/OV2 with a buffer at 1E00H and reads six whole sectors, which is B296, 160 bytes more than the file holds; and jumps to 1E00H with Register A holding the command token and Register Pair HL at INBUF 7039H. The call to NORMNUM is what makes the rest sound: MOVE's own walk writes the resolved 0DH form of a reference and reads it back, and FIND looks only for the plain 0EH form, so neither would be safe if a 0DH left by an earlier GOTO were still standing in the program text.

The entry at 1E00H stores the Stack Pointer into SAVSTK (2352H) and separates the four tokens: 05H to COPY (22C5H), 02H to MOVE (1E0EH), and everything else to DOFIND (20C0H), which keeps the token in DTYPE (21E9H) and is therefore both SEARCH, 03H, and FIND, 04H. No command returns to its caller: each of them loads Register Pair HL with an address in BASIC/CMD, puts the Stack Pointer back from SAVSTK and jumps, and the four exits at 2342H to 2354H are chained by three 0DDH prefix bytes so that one load of Register Pair HL survives the three beneath it.

MOVE (1E0EH) takes three line numbers and reads them with NXTLIN (1E4AH) and its second entry NXTLIN1 (1E56H), all three of which must name lines that exist. GOTLIN (1E64H) refuses an insert point inside the block, counts the line numbers free above it into BLANKS (1EC3H), counts the lines of the block with the walk at CNTLP (1EAFH) and refuses a block that needs more numbers than there are. The memory check at 1ED2H proves the block fits in the free memory between LOPT 71A3H and HIPT 7178H, and 1EFDH settles the direction, whose Carry Flag is then carried on the stack through the whole of the rest of the command.

Then the heart of MOVE, which is one walk of the program run twice from TIME2 (1F1DH). Pass 1 turns every reference to a line of the block into the 0DH token and the address that line will stand at once it has moved, which is what RANGE (1FBAH) works out by adding OFFSET (1FCCH); an undefined reference is reported by UNDEF (1F71H) and the walk carries on. PAS1DUN (1FD3H) then lifts the block into free memory, shuffles the lines between the hole and the insert point over it with an instruction it writes at 2023H, gives every line of the block its new link and its new number at ADJ1 (203DH), puts the block down again at ADJ2A (2074H) and adjusts the links of the shuffled lines at ADJ3 (20A5H). ADJ4 (20B9H) clears DOPASS1 (2355H) and goes back to TIME2 for pass 2, which turns every address pass 1 wrote into the number the line now carries.

FIND and SEARCH (20C0H) are one body of code and part company only at SHOW (21E8H): SEARCH goes to SHOLIN (2211H), which makes the line found the current one and hands a full stop to NOBRK@ 80F4H, the key handler of the enhancement package, and never returns; FIND goes to SHONUM (21EEH), which writes the line's number and does return, so that FIND lists every match in one line with COMSTR (220EH) between them. What is looked for is read out of the tokenized command line at LBUF+1 6EFAH and not out of INBUF, which is the one place this overlay prefers the tokenized form, and it has to: a keyword stands in the program text as one byte. The first character chooses among three searches, KEYFIND (20E7H) for a token, VARFIND (212CH) for a name and NUMFIND (221EH) for a line number, and a bare command goes to AGAIN (2265H), which picks the last search up at the line after the one it stopped at.

COPY (22C5H) copies nothing itself. It finds the line asked for, moves its tokenized text into LBUF, has UNTOKE 7A0DH turn it back into characters at INBUF, makes room for a five character line number in front of them with the LDDR at 2319H, writes the new number into that room with @HEXDEC, shows the whole line on the display and jumps to 5993H, the line entry of BASIC/CMD, so that the line is entered exactly as a typed line would be. That is why 59AFH counts COPY as the keyboard, and why a COPY to a number above 65529 gives Syntax error and not Illegal function call.

Notes

BASIC/OV2 is the only file of the release built as a core image, which is why rec.py cannot be run on it: the first byte of the file is EDH, the first half of the LD (nn),SP at 1E00H, and a record reader takes that for a record type and walks off the end. The source has the assembler check the length itself, with an IFGT that gives an error if the code reaches past 23FFH, which is the top of the DOS overlay area.

The file occupies part of LOWBUF$ 2300H, the resident system's low memory disk buffer: 2300H to 235FH is the tail of COPY and the whole of the overlay's own storage. That is the same region B296 writes over, MORC reading 1536 bytes for a file of 1376, so the 160 bytes from 2360H to 23FFH take whatever followed the file in its last sector on the diskette.

Once the overlay has been read in, OVRLY$ 0069H holds 01H and MORC skips the load, so a second extended command does not touch the disk and the file need not still be there. SVCUSR at 8078H of the enhancement package clears that cell before any supervisor call that might load a DOS overlay over the same address, which is what makes the caching safe.

KEYFIND is the only code in the whole of the Disk BASIC that uses the alternate accumulator. No row of BASIC/CMD's 21978 bytes decodes as EX AF,AF', and KEY2 (2118H) uses it twice over to hold the result of one comparison while a second is made, which is how both halves of a two byte function token are matched without a spare register.

The reference walk of MOVE takes no notice of a string literal or of REM text, where VARFIND steps carefully over both. It is safe all the same, and the reason is in the line readers of BASIC/CMD: 7E42H throws away every control character but a tab and a line feed when a line is read from a text file, and the keyboard reader does the same, so no 0DH or 0EH byte can reach a literal or a remark. VARFIND has to be careful because the characters it looks for are ordinary ones.

Three runs of this file are reached by nothing. The Illegal function call at 1EBCH cannot be taken, the end of the program standing beyond the last line of the block because 1E5CH has already found that line; the Illegal function call at 2142H cannot be taken, 20D5H and 20D9H having already proved the first character of the name is a letter, which VALID accepts; and the jump at ILLEG (2340H) is two bytes nothing needs, every one of COPY's eight error jumps being within reach of BADLIN (2346H) itself, the furthest at 79H bytes where a relative jump reaches 7FH. The call and return at 22B0H is a fourth small waste of the same kind, a jump to CKSPCL (22B6H) doing the same work in the same three bytes.

216DH to 2176H is the one part of the file the two builds differ over. BMOVE/ASM has it inside an IF on the 6.3.1 build switch, and the other branch is a jump to a patch area at the end of the source that the 6.3.1 assembly leaves out altogether. What the release's branch adds is that the apostrophe form of REM and the second byte of a two byte function token are both stepped over by VARFIND, so that neither can be taken for the beginning of a variable name.

Against the manual

The BASIC Reference Manual's Copying, Moving, and Searching section describes all four commands and the bytes agree with it almost everywhere, including the parts that are easiest to get wrong. Its example that a block moved after line 100 where line 110 follows can be no more than nine lines long is exactly what BLANKS (1EC3H) works out and 1EC9H tests: one less than the difference of the two numbers. Its rule that Num2 must be greater than or equal to Num1 is the comparison at 1E2AH, which lets the two be equal and so allows a block of one line. Its claim that these commands clear all variable values and close any open files is true by way of the CLEAR 447EH that MORC calls before the overlay is entered, not of anything in this file.

Its syntax tables give the object as optional for SEARCH and as required for FIND, and that difference is real: a bare S reaches AGAIN (2265H) and repeats the last search, and a bare F is refused at 2268H and goes back to the prompt without a word. The reason is in the two answers of SHOW: SEARCH shows one line and stops, so there is something to carry on from, and FIND writes the whole list in one go, so there is not.

Its warning that type declarations must be used and that F A would not find A$ or A() is the test at 219EH, which refuses a match when the character after the name is one VALID (229DH) accepts, and VALID accepts the four declaration characters and an opening parenthesis. Its warning that only the first ten characters of a name are significant is the collecting loop at VAR1 (2131H), which stops at ten, together with 2193H, which accepts a ten character match without looking at what follows it: a search for a name of the full ten characters matches every longer name that begins with it.

The manual says the space after the letter is mandatory when a keyword is being looked for. Nothing in this file requires it: 20CAH calls NXTCHAR, which steps over as many spaces as there are, so none, one or several make no difference here. The requirement belongs to the tokenizer and to the abbreviation test of CKABBR at 81D5H, which have to see the letter as a word of its own before the command token is ever written.

Two things the manual does not say. FIND and SEARCH of a line number name the line of that number as well as every line that refers to it, because 223DH leaves the line's own number in Register Pair DE and the first comparison of every line at 2241H is made against it, before NUMLP2 (2253H) begins looking for a reference. And the file need only be on the disk for the first of these commands in a session, the caching at OVRLY$ 0069H taking care of the rest, where the manual says the file must be present when using them.

Bugs

B350: 1EC7H skips the only limit there is on the new line numbers whenever the block is moved to after the last line of the program. 1E98H leaves BLANKS (1EC3H) at 0000H in that case, meaning that there is no following line to run into, and that jump reads the 0000H as a reason to skip the comparison entirely. ADJ1 then gives each line of the block the next number after NUM3 with the plain increment at 204AH and no ceiling of any kind, so a program whose last line is numbered near the top of the range comes back with lines numbered above 65529, which the line entry will not accept from the keyboard, and with enough lines the numbers wrap through 65535 to 0 and the program's numbers are no longer in order. FIND 5AB4H gives up as soon as a line's number stands above the one asked for, so every line past the wrap becomes unreachable to GOTO, LIST, EDIT and DELETE while still being listed.

B351: 1ECEH stores the count of lines in the block into LTM (235AH) and nothing ever reads it. That instruction is the only one in BASIC/OV2 that names 235AH, the count is used where it stands in Register Pair BC at 1EC9H and nowhere else, and no routine outside the file could read the cell to any purpose, the overlay area being written over by the next DOS overlay. Four bytes of code and two of storage with nothing behind them.

B352: 219BH keeps the length of the name where the source means to keep the character of the line. 2192H has already loaded Register A from Register C for the comparison above it, so what is saved and brought back at 21A1H is a number from one to nine, and the comparison with an opening parenthesis at 21BEH can therefore never be equal on the path from 21A2H. Nothing goes wrong, because BYV1 (21C2H) reads the same character one instruction later and tests it for the parenthesis itself, so both paths reach VARLP3 (215DH) with the search standing in the same place.

B353: the jump at 2024H reads a Carry Flag that is not the one the code took care to save. 2007H pushes the direction so that the downward path below it may spoil the flags, and DOMOV (201BH) then reads the live flags rather than popping that copy. On the upward path they are still the direction; on the downward path they are whatever the subtraction at 2013H left, which is the Carry Flag clear for every pair of addresses where the insert point stands below the block. The two readings agree only because 1E7CH refuses a move whose block already stands at the insert point, which is the one case where that subtraction would borrow and the shuffle would be taken for an upward one.

B354: 2221H leaves a FIND or a SEARCH whose number has anything after it doing nothing and saying nothing. 221EH reads the number with NUM2DE and that jump goes to EXIT (234EH) when the line has not ended, which prints the prompt and no message, where MOVE at 1E3AH and COPY at 22ECH both give Illegal function call for exactly the same fault. So F 100,200 and S 100X look as though they found nothing, and a mistyped command cannot be told from a search that matched no line.

B355: the push at 2299H is never popped. AGN1 puts the address of the stored name on the stack before it jumps to VARREP (214DH), which is what NUMREP does at 2232H because its own comparison keeps the number it is looking for there; the variable search keeps nothing on the stack and reads nothing from it. The word stays where it is until one of the four exits puts the Stack Pointer back from SAVSTK (2352H), so the only cost is two bytes of stack for the length of one search.

Variables

Memory Used by BASIC/OV2

Address
Size
Contents
1E86H-1E87H
2 bytes
POSN3
The operand of the LD HL at 1E85H, 0000H in the file: the address of the line the block is to be put after. Written at 1E44H from FIND's answer, read at 1E85H and 1F00H.
1E9CH-1E9DH
2 bytes
NUM3
The operand of the LD DE at 1E9BH, 0000H in the file: the number of that line, and then the number the last moved line was given. Written at 1E40H and stepped one at a time by ADJ1 at 204BH; read at 1E64H, 1E9BH and 2046H.
1EA7H-1EA8H
2 bytes
STRTLIN
The operand of the LD HL at 1EA6H, 0000H in the file: the address of the first line of the block. Written at 1E15H; read at 1EA6H, 1EE4H, 1EF5H, 1F06H, 1FDAH, 2000H, 202EH and 207DH.
1EAAH-1EABH
2 bytes
ENDLIN
The operand of the LD DE at 1EA9H, 0000H in the file: the address of the last line of the block. Written at 1E21H; read at 1EA9H, 1EDDH and 1FEDH.
1EC3H-1EC4H
2 bytes
BLANKS
The operand of the LD HL at 1EC2H, 0000H in the file: how many line numbers are free above the insert line, or 0000H for no limit at all. Written at 1E82H and 1EA3H, read at 1EC2H. The 0000H case is B350.
1FCCH-1FCDH
2 bytes
OFFSET
The operand of the LD HL at 1FCBH, 0000H in the file: the distance every moved line's address changes by. Written at 1F18H, read by RANGE at 1FCBH and by ADJ0 at 2039H.
2023H
1 byte
DIRECT
The second byte of the instruction at 2022H, B0H in the file, which makes it an LDIR; 201BH stores B8H there for a downward move, which makes it an LDDR.
205AH-205BH
2 bytes
OFFSET1
The operand of the LD DE at 2059H, 0000H in the file: the distance the block's own bytes moved to reach free memory, which turns an old link into the next line's place in the copy. Written at 2035H, read at 2059H.
205FH-2060H
2 bytes
ENDPT
The operand of the LD HL at 205EH, 0000H in the file: the byte past the end of the block in free memory, which ADJ1 stops on. Written at 1FE7H from the LDIR's own Register Pair DE, read at 205EH.
2072H-2073H
2 bytes
UPSTART
The operand of the LD DE at 2071H, 0000H in the file: where an upward shuffle left room for the block. Written at 2026H from the shuffle's own Register Pair DE, read at 2071H.
208CH-208DH
2 bytes
TOCNG
The operand of the LD BC at 208BH, 0000H in the file: the count of bytes the shuffle moved. Written at 201EH, read at 208BH.
20AFH-20B0H
2 bytes
ENDPT1
The operand of the LD HL at 20AEH, 0000H in the file: the byte past the shuffled region in its new place, which ADJ3 stops on. Written at 2091H, read at 20AEH.
21E9H
1 byte
DTYPE
The operand of the LD A at 21E8H, 00H in the file: the command token, 03H for SEARCH and 04H for FIND. Written at 20C0H, read by SHOW at 21E8H and by AGAIN at 2265H.
21F1H
1 byte
FTIME
The operand of the LD A at 21F0H, 00H in the file: 00H until FIND has written a number and 01H after, which is what puts a comma in front of every number but the first. Written at 20C4H and 21F5H, read at 21F0H.
2207H-2208H
2 bytes
NXTPO
The operand of the LD HL at 2206H, 0000H in the file: the address of the next line of the program. Written a byte at a time by GTPTR at 21DCH and 21E2H, read at 2206H, so that SHOW leaves the search one byte below that line.
2352H-2353H
2 bytes
SAVSTK
The operand of the LD SP at 2351H, 0000H in the file: the Stack Pointer as BASIC's own CLEAR left it. Written by the first instruction of the overlay at 1E00H and loaded back by every one of the four exits.
2355H
1 byte
DOPASS1
Which pass of the line reference walk is running, 00H in the file: not 00H for the first and 00H for the second. Written at 1F1DH and 20BAH, read at 1F36H and 1FD3H.
2356H-2357H
2 bytes
NUM1
The first line number of the block, 0000H in the file. Written at 1E11H, read at 1E76H and by RANGE at 1FC1H.
2358H-2359H
2 bytes
NUM2
The last line number of the block, 0000H in the file. Written at 1E1DH, read by RANGE at 1FBAH.
235AH-235BH
2 bytes
LTM
The count of lines in the block, 0000H in the file. Written at 1ECEH and read by nothing at all, which is B351.
235CH-235DH
2 bytes
TOMOVE
The length of the block in bytes, 0000H in the file. Written at 1EEBH, read at 1EF0H, 1F11H, 1FE1H, 2077H, 2080H and 2096H.
235EH-235FH
2 bytes
NEWLIN
The address in the program text the block is to be moved to, 0000H in the file. Written at 1E8BH, read at 1EF8H, 1FF7H, 200EH, 2069H and 2087H.

Memory of Other Files Used

Address
Size
Contents
6E9EH
2 bytes
PGMBGN (BASIC/CMD)
The address of the first line of the program, read at 1F20H, 20F7H, 214AH and 2228H so that each of the four walks starts at the top.
6EF9H-7038H
320 bytes
LBUF (BASIC/CMD)
The tokenized line buffer. DOFIND reads what is to be searched for from 6EFAH at 20C7H; COPY puts the tokenized text of the line it is copying there at 22FDH; and the colon the enhancement package keeps at 6EF9H is the byte 2304H hands to UNTOKE and 2319H drops again.
7039H-7138H
256 bytes
INBUF (BASIC/CMD)
The input buffer. MOVE and COPY read their line numbers from the characters standing there, 1E00H being entered with Register Pair HL on it; UNTOKE lays the copied line down from 7039H; and COPY hands 7038H to the line entry at 233AH.
7145H
2 bytes
IPOS (BASIC/CMD)
The place in the line to carry on from after a packed number, read at 1FAEH so that PAS2A can write the three bytes of a reference, and at 225FH so that NUMFIND can step back over one.
7178H
2 bytes
HIPT (BASIC/CMD)
The highest free byte of memory, read at 1ED2H as the top of the room the block may be put in.
7192H
2 bytes
CURLIN (BASIC/CMD)
The number of the line being run, written by SHOLIN at 2215H so that the key handler of the enhancement package lists the line the search found.
71A3H
2 bytes
LOPT (BASIC/CMD)
The lowest free byte of memory, read at 1ED5H, 1FDDH, 202AH and 2074H: it is the bottom of the room and the address the block is parked at while the shuffle runs.
83DBH
1 byte
LSTTYP$ (BASIC/CMD, the enhancement package)
The kind of the last search: 0EH a line number, 80H or above a keyword token, below that the length of a variable name, 00H none yet. Written at 20E7H, 2145H and 222DH; read by AGAIN at 226DH.
83DCH-83DDH
2 bytes
LSTLIN$ (BASIC/CMD, the enhancement package)
The line the last search stopped at. Written at 2105H, 2159H and 223DH; read by SHONUM at 2200H, by SHOLIN at 2211H, by 2248H and by AGAIN at 2275H.
83DEH-83DFH
2 bytes
LSTNUM$ (BASIC/CMD, the enhancement package)
The line number the last search looked for. Written at 2224H, read by AGAIN at 2280H.
83E0H
1 byte
LSTKEY$ (BASIC/CMD, the enhancement package)
The second half of a two byte keyword token, FFH when there is none. Written at 20F4H, read by AGAIN at 228DH.
83E1H-83EBH
11 bytes
LSTVAR$ (BASIC/CMD, the enhancement package)
The variable name the last search looked for, up to ten characters and a 00H. Collected at 2138H and ended at 213DH; read a character at a time at 2185H and named again by 215DH and 2296H.

Routines of Other Files Called

AddressContents
052DH@DSPLY (BOOT/SYS), SVC 10: COPY shows the whole of the line it has built before it enters it (2336H).
06F6H@HEXDEC (BOOT/SYS), SVC 97: the new line number written as five characters right justified with leading spaces (2329H).
3131HThe word in and a number (BASIC/CMD): the second half of the Undef. line report, naming the line the reference stands in (1F83H).
3139HNUMDSP (BASIC/CMD): a line number written as decimal digits, for the Undef. line report (1F7CH) and for every number FIND lists (2203H).
41E9HThe carriage return only when one is wanted (BASIC/CMD): the Undef. line report begins on a line of its own (1F71H).
46A5HThe text writer (BASIC/CMD): UNDEF$ (1F78H) and COMSTR (21FDH).
5AB4HFIND (BASIC/CMD): a line looked up by its number, at 1E5CH, 1E6EH, 1F62H, 2279H, 22D7H and 22F3H.
5E93HNXTCHAR (BASIC/CMD): the next character or token of the line, called from eighteen places in this file.
5F9AHNUM2DE (BASIC/CMD): a line number read out of the command line, at 1E37H, 1E50H, 221EH, 225CH, 22CDH and 22E9H.
5FAEHNUMPOSN (BASIC/CMD), which BMOVE/ASM itself names: the two bytes after a reference token, at 1F50H, 1F5EH and 1F9DH.
7A0DHUNTOKE (BASIC/CMD): the tokenized line COPY has moved into LBUF turned back into characters at INBUF (2305H).

Routines of Other Files Jumped To

AddressContents
425CHOMERR (BASIC/CMD): error 7, Out of memory, the exit NOMEM (234AH) takes when the block is longer than the free memory.
5920HREADY (BASIC/CMD): the prompt and command level, the exit EXIT (234EH) takes when a command is done or has nothing to say.
5993HThe line entered into the program (BASIC/CMD): COPY's last act, which tokenizes the line in INBUF and puts it in the program (233DH).
5F95HFUNCERR (BASIC/CMD): error 5, Illegal function call, the exit BADLIN (2346H) takes and the only error this file reports apart from Out of memory.
80F4HNOBRK@ (BASIC/CMD, the enhancement package): the command level key handler, given a full stop so that it lists the line SEARCH found, the exit DOLINE (2342H) takes.

Disassembly

1E00H - The Entry, the Four Commands and MOVE's Three Arguments (1E00H-1E49H)

BASIC/OV2 is not a load module and it is not loaded by the DOS: the enhancement package of BASIC/CMD reads it off the disk itself and jumps into it. MORC at 8234H of that package clears every variable with CLEAR 447EH, puts every line reference back into its plain number form with NORMNUM 661EH, reads the 1376 bytes in as six whole sectors to 1E00H, records 01H in OVRLY$ 0069H so that a second extended command skips the load, and jumps to 1E00H with Register A holding the command token and Register Pair HL pointing at INBUF 7039H, where the line as it was typed still stands. The four tokens come from ABBTBL of NEWB/ASM, which CKABBR writes over the abbreviation letter in the line buffer: 05H for C, COPY; 02H for M, MOVE; 03H for S, SEARCH; and 04H for F, FIND. This entry separates COPY and MOVE and sends the other two to DOFIND 20C0H, which tells SEARCH from FIND by the token it keeps in DTYPE 21E9H. Nothing else can arrive: ABBR at 81CAH refuses a token of 06H or more, and CKABBR writes none below 02H. The first instruction of all is the one every exit depends on, SAVSTK 2352H taking the Stack Pointer as BASIC's own CLEAR left it, because none of the four commands returns to its caller: each of them ends by loading Register Pair HL with an address in BASIC/CMD, putting that stack back and jumping. MOVE takes three line numbers, the first and last of the block to move and the line to put it after, and reads them with the one routine at 1E4AH twice over and its second half once.

1E00
LD (2352H),SP ED 73 52 23LD (SAVSTK),SP
The entry (1E00H), which MORC jumps to at 8274H with Register A holding the command token and Register Pair HL pointing at INBUF 7039H: store the Stack Pointer into SAVSTK at 2352H, which is the operand of the LD SP instruction at 2351H, so that every exit of this overlay can put the stack back as BASIC's CLEAR left it.
1E04
CP 05H FE 05
Compare Register A with 05H, the token ABBTBL holds for the letter C and so for COPY, which copies one line of the program to a new number.
1E06
Jump to COPY at 22C5H on Z, the command being COPY, which reads a line number to copy and a new number to give the copy.
1E09
CP 02H FE 02
Compare Register A with 02H, the token ABBTBL holds for the letter M and so for MOVE, which moves a block of lines to another place in the program.
1E0B
Jump to DOFIND at 20C0H on NZ, the token being neither 05H nor 02H, which leaves 03H for SEARCH and 04H for FIND and nothing else, ABBR at 81CAH having refused anything from 06H up.
1E0EMOVE
MOVE (1E0EH): call NXTLIN at 1E4AH, which reads the first line number of the block and proves that a line of that number stands in the program.
1E11
LD (2356H),DE ED 53 56 23LD (NUM1),DE
Store Register Pair DE, that first line number, into NUM1 at 2356H, which RANGE at 1FBAH reads to decide whether a reference falls inside the block.
1E15
LD (1EA7H),BC ED 43 A7 1ELD (STRTLIN),BC
Store Register Pair BC, the address FIND gave that line, into STRTLIN at 1EA7H, the operand of the LD HL instruction at 1EA6H, which is the first byte of the block that is to move.
1E19
PUSH DE D5
Push Register Pair DE, the first line number, which the comparison at 1E2AH wants back once the second number has been read over it.
1E1A
Call NXTLIN at 1E4AH a second time, which reads the last line number of the block and finds its line in the program.
1E1D
LD (2358H),DE ED 53 58 23LD (NUM2),DE
Store Register Pair DE, that number, into NUM2 at 2358H, which is the number RANGE at 1FBAH compares a reference against first.
1E21
LD (1EAAH),BC ED 43 AA 1ELD (ENDLIN),BC
Store Register Pair BC, the address of that line, into ENDLIN at 1EAAH, the operand of the LD DE instruction at 1EA9H, which is the last line of the block that is to move.
1E25
LD B,H 44
Load Register B from Register H, the high byte of the text pointer, which the comparison below is about to write over.
1E26
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC carries the place in the command line through that comparison.
1E27
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the last line number of the block into Register Pair HL.
1E28
POP DE D1
Pop Register Pair DE, the first line number of the block, which the push at 1E19H left on the stack.
1E29
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag so that the subtraction below is a true subtraction.
1E2A
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the first number of the block from the last, which sets the Carry Flag when the two were typed the wrong way round.
1E2C
Jump to BADLIN at 2346H on Carry, the last number standing below the first, which gives error 5, Illegal function call. A block of one line is let through, the two numbers being equal and the subtraction leaving no borrow.
1E2F
LD H,B 60
Load Register H from Register B, the high byte of the place in the command line that 1E25H put there.
1E30
LD L,C 69
Load Register L from Register C, its low byte, so that Register Pair HL is the text pointer again and the third number can be read.
1E31
Call NXTCHAR at 5E93H, which steps the text pointer over the comma and brings the first character of the third number back in Register A.
1E34
Jump to BADLIN at 2346H on Z, the line having ended after the second number where MOVE wants a third, the line the block is to be put after.
1E37
Call NUM2DE at 5F9AH, which reads that third number into Register Pair DE and comes back with the Zero Flag set when the line has ended after it.
1E3A
Jump to BADLIN at 2346H on NZ, something standing after the third number: MOVE takes exactly three and nothing may follow the last of them.
1E3D
Call NXTLIN1 at 1E56H, the second half of the reader below, which refuses a number of zero and finds the line the third number names.
1E40
LD (1E9CH),DE ED 53 9C 1ELD (NUM3),DE
Store Register Pair DE, that third number, into NUM3 at 1E9CH, the operand of the LD DE instruction at 1E9BH, which is the line the block is to follow.
1E44
LD (1E86H),BC ED 43 86 1ELD (POSN3),BC
Store Register Pair BC, the address FIND gave that line, into POSN3 at 1E86H, the operand of the LD HL instruction at 1E85H.
1E48
Jump to GOTLIN at 1E64H, all three numbers having been read and all three of their lines found in the program.

1E4AH - NXTLIN and NXTLIN1: a Number Read and its Line Found (1E4AH-1E63H)

One routine with two entries, and between them they do every check MOVE makes on an argument. The first entry reads a number and demands that the line be followed by more of the command, which is right for the first and second of the three; the second entry takes a number already in Register Pair DE and only refuses zero and finds the line, which is right for the third, after which the line must end. Both of them answer with Register Pair BC addressing the line that was found and Register Pair HL back on the place in the command line, and both of them jump to BADLIN 2346H rather than return when anything is wrong, which is why the stack SAVSTK 2352H holds is what puts the depth right.

1E4ANXTLIN
NXTLIN (1E4AH), which 1E0EH and 1E1AH call: call NXTCHAR at 5E93H, which steps the text pointer on and brings the next character that is not a space back in Register A.
1E4D
Jump to BADLIN at 2346H on Z, the character being a colon or the 00H that ends the line, so that there is no number standing here to be read.
1E50
Call NUM2DE at 5F9AH, which reads the digits into Register Pair DE, takes a full stop for the number of the line being run, and sets the Zero Flag when the line has ended after them.
1E53
Jump to BADLIN at 2346H on Z, the line having ended after this number: both of the numbers that reach this entry are followed by another.
1E56NXTLIN1
LD A,D 7A
NXTLIN1 (1E56H), which 1E3DH calls for the third number with the reader above having left it in Register Pair DE: load Register A from Register D, the high byte of that number.
1E57
OR E B3
Or Register A with Register E, the low byte, which sets the Zero Flag when the whole of the number is 0000H.
1E58
Jump to BADLIN at 2346H on Z, the number being zero, which no line of a program may carry, the lowest being one.
1E5B
PUSH HL E5
Push Register Pair HL, the place in the command line, which FIND below uses for its own walk through the program text.
1E5C
Call FIND at 5AB4H, which walks the program for a line of the number in Register Pair DE and comes back with the Carry Flag set when one is there and Register Pair BC addressing its link word.
1E5F
POP HL E1
Pop Register Pair HL, the place in the command line, so that the caller reads on from where it stood.
1E60
RET C D8
Return to the caller on Carry, the line having been found, with Register Pair BC addressing it and Register Pair DE still holding its number.
1E61
Jump to BADLIN at 2346H, no line of that number standing in the program, which gives error 5, Illegal function call.

1E64H - GOTLIN: the Insert Point, the Spare Numbers and the Lines Counted (1E64H-1ED1H)

MOVE renumbers the lines it moves, and this is where it works out whether there are numbers left to give them. The block keeps its order and its contents and gets new numbers running up from one past the number it is put after, so a block of four lines put after line 300 becomes 301, 302, 303 and 304. That can only be done when the line standing after line 300 carries a number far enough above it, and the count of numbers there is room for is what BLANKS 1EC3H holds. A zero in BLANKS means unlimited, which is the answer when the insert point is the end of the program, and 1E98H is the test that gives it: the link of the line after the insert point is 0000H. Then the lines of the block are counted by walking their links from STRTLIN 1EA7H to ENDLIN 1EAAH, and the count is refused when it stands above BLANKS. Three subtractions in this part run with no OR A in front of them and all three are safe, each having a logical operation two or three instructions above it that cleared the Carry Flag: 1E92H clears it for 1E9EH, 1EAFH for 1EB1H and 1EC6H for 1EC9H. The count goes into LTM 235AH at the end of it and nothing in the file ever reads LTM again.

1E64GOTLIN
LD DE,(1E9CH) ED 5B 9C 1ELD DE,(NUM3)
GOTLIN (1E64H), which 1E48H reaches with all three numbers read: load Register Pair DE from NUM3 at 1E9CH, the number of the line the block is to be put after.
1E68
Call RANGE at 1FBAH, which answers with the Carry Flag clear when the number in Register Pair DE falls inside the block that is to move.
1E6B
Jump to BADLIN at 2346H on NC, the line to put the block after standing inside the block itself, which would be a move into nowhere.
1E6E
Call FIND at 5AB4H, which finds that line again and leaves Register Pair HL addressing the line above it, the one whose number sets the limit.
1E71
INC HL 23
Increment Register Pair HL past the low byte of that line's link, the first of the two steps to its number.
1E72
INC HL 23
Increment Register Pair HL a second time, so that it addresses the low byte of that line's number.
1E73
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, the low byte of the number of the line after the insert point.
1E74
INC HL 23
Increment Register Pair HL to the high byte of that number.
1E75
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the whole of that number.
1E76
LD HL,(2356H) 2A 56 23LD HL,(NUM1)
Load Register Pair HL from NUM1 at 2356H, the first number of the block that is to move.
1E79
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1E7A
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the number after the insert point from the first number of the block, which gives Z when the block already stands exactly there.
1E7C
Jump to BADLIN at 2346H on Z, the block already standing after the line named, so that the move would change nothing at all.
1E7F
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the value BLANKS is to start at, which says that the number of spare line numbers is not yet known.
1E82
LD (1EC3H),HL 22 C3 1ELD (BLANKS),HL
Store Register Pair HL into BLANKS at 1EC3H, the operand of the LD HL instruction at 1EC2H, which the count below is weighed against.
1E85
LD HL,0000H 21 00 00
Load Register Pair HL with the word POSN3 holds at 1E86H, 0000H in the file and the address of the insert line, which 1E44H wrote into this instruction's own operand.
1E88
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, the low byte of that line's link, which is the address the block is to be put at.
1E89
INC HL 23
Increment Register Pair HL to the high byte of that link.
1E8A
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE is the address of the line after the insert line.
1E8B
LD (235EH),DE ED 53 5E 23LD (NEWLIN),DE
Store Register Pair DE into NEWLIN at 235EH, the place in the program text the block is to be moved to.
1E8F
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that address into Register Pair HL so that the line there can be read.
1E90
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, the low byte of the link of the line after the insert line.
1E91
INC HL 23
Increment Register Pair HL to the high byte of that link.
1E92
OR (HL) B6
Or Register A with the byte Register Pair HL addresses, which sets the Zero Flag when the link is 0000H and so the program ends there, and clears the Carry Flag for the subtraction at 1E9EH.
1E93
INC HL 23
Increment Register Pair HL to the low byte of that line's own number.
1E94
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, that low byte.
1E95
INC HL 23
Increment Register Pair HL to the high byte of the number.
1E96
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the number of the line after the insert line.
1E97
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which brings that number into Register Pair HL for the subtraction below.
1E98
Jump to GOODRM at 1EA6H on Z, the link having been 0000H, so that the insert point is the end of the program and BLANKS stays 0000H, which the test at 1EC5H reads as room for any number of lines.
1E9A
DEC HL 2B
Decrement Register Pair HL, the number of the line after the insert point, because that number itself may not be given to a moved line.
1E9B
LD DE,0000H 11 00 00
Load Register Pair DE with the word NUM3 holds at 1E9CH, 0000H in the file and the number of the insert line, which 1E40H wrote into this instruction's own operand.
1E9E
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL with the Carry Flag that 1E92H cleared, which leaves the count of line numbers free between the insert line and the line above it.
1EA0
Jump to BADLIN at 2346H on Z, the two lines being consecutively numbered, so that there is no number at all to give a moved line.
1EA3
LD (1EC3H),HL 22 C3 1ELD (BLANKS),HL
Store Register Pair HL into BLANKS at 1EC3H, the count of spare numbers, which the test at 1EC9H weighs the lines of the block against.
1EA6GOODRM
LD HL,0000H 21 00 00
GOODRM (1EA6H), which 1E98H also reaches: load Register Pair HL with the word STRTLIN holds at 1EA7H, 0000H in the file and the address of the first line of the block, which 1E15H wrote into this instruction's own operand.
1EA9
LD DE,0000H 11 00 00
Load Register Pair DE with the word ENDLIN holds at 1EAAH, 0000H in the file and the address of the last line of the block, which 1E21H wrote into this instruction's own operand.
1EAC
LD BC,0001H 01 01 00
Load Register Pair BC with 0001H, the count of lines in the block, which starts at one because the first line is already in hand.
1EAFCNTLP
OR A B7
CNTLP (1EAFH), the top of the counting walk: set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1EB0
PUSH HL E5
Push Register Pair HL, the address of the line this turn is looking at, which the subtraction is about to spoil.
1EB1
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the last line of the block from this one, which gives Z when the walk has reached the last line.
1EB3
POP HL E1
Pop Register Pair HL, that address, with the flags of the subtraction left standing.
1EB4
Jump to ENDCNT at 1EC2H on Z, the walk having reached the last line of the block, with Register Pair BC holding how many lines it counted.
1EB7
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, the low byte of this line's link, which is the address of the next line.
1EB8
INC HL 23
Increment Register Pair HL to the high byte of that link.
1EB9
LD H,(HL) 66
Load Register H with the byte Register Pair HL addresses, that high byte.
1EBA
LD L,A 6F
Load Register L from Register A, the low byte, so that Register Pair HL addresses the next line of the program.
1EBB
OR H B4
Or Register A with Register H, which sets the Zero Flag when the link was 0000H and the walk has run off the end of the program.
1EBC
Jump to BADLIN at 2346H on Z, the end of the program having been reached before the last line of the block. Nothing can reach it: 1E5CH found that last line, so its address stands on the walk.
1EBF
INC BC 03
Increment Register Pair BC, one more line counted in the block.
1EC0
Jump back to CNTLP at 1EAFH, which weighs the next line against the last one.
1EC2ENDCNT
LD HL,0000H 21 00 00
ENDCNT (1EC2H): load Register Pair HL with the word BLANKS holds at 1EC3H, 0000H in the file and the count of spare line numbers, which 1E82H and 1EA3H write into this instruction's own operand.
1EC5
LD A,H 7C
Load Register A from Register H, the high byte of that count.
1EC6
OR L B5
Or Register A with Register L, the low byte, which sets the Zero Flag when the count is 0000H and clears the Carry Flag for the subtraction at 1EC9H.
1EC7
Jump to OKLINS at 1ECEH on Z, BLANKS holding 0000H, which 1E98H left there for an insert point at the end of the program and which means there is no limit to check at all. B350: with no limit the new numbers run up from NUM3 2356H with no ceiling, so a block moved to after a line numbered near the top wraps past 65535.
1EC9
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL with the Carry Flag that 1EC6H cleared, the lines of the block from the spare numbers, which sets the Carry Flag when there are fewer numbers than lines.
1ECB
Jump to BADLIN at 2346H on Carry, there being fewer spare numbers than lines to move, which is the error the source calls not enough lines available. A block that needs exactly as many numbers as there are is let through.
1ECEOKLINS
LD (235AH),BC ED 43 5A 23LD (LTM),BC
OKLINS (1ECEH): store Register Pair BC, the count of lines in the block, into LTM at 235AH. B351: nothing in the file reads LTM, 1ECEH being the only instruction of BASIC/OV2 that names 235AH, so the count it keeps there is written and never looked at again.

1ED2H - The Memory Check, the Direction of the Shuffle and the Offset (1ED2H-1F1CH)

MOVE lifts the block right out of the program, shuffles what is left over the hole, and puts the block down again, so it needs somewhere to put the block while the shuffle runs. The place it uses is the free memory between LOPT 71A3H and HIPT 7178H, which is the gap between the top of the variables and the bottom of the string space, and the block has to fit in it: MORC called CLEAR 447EH before it entered this overlay, so that gap is the whole of the memory the program is not using. TOMOVE 235CH takes the length of the block in bytes. Then the direction is settled by one subtraction, STRTLIN 1EA7H less NEWLIN 235EH, and the Carry Flag it leaves is carried on the stack through the whole of the rest of MOVE, popped and pushed again at 1FEBH, 2004H, 206DH and 208EH and read for the last time at 209AH. Last comes OFFSET 1FCCH, which is what every line reference in the program has to be moved by: the distance from where a moved line stands now to where it will stand, which for a move up is the gap between the two places less the length of the block itself, because the lines above the hole come down by that much.

1ED2
LD HL,(7178H) 2A 78 71LD HL,(HIPT)
Load Register Pair HL from HIPT at 7178H, the pointer the interpreter keeps to the highest byte of memory that is free.
1ED5
LD DE,(71A3H) ED 5B A3 71LD DE,(LOPT)
Load Register Pair DE from LOPT at 71A3H, the pointer to the lowest free byte, which stands above the program text and the variables.
1ED9
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1EDA
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, which leaves Register Pair HL holding how many bytes of free memory there are between the two pointers.
1EDC
PUSH HL E5
Push Register Pair HL, that count of free bytes, which the comparison at 1EF0H wants once the length of the block is known.
1EDD
LD HL,(1EAAH) 2A AA 1ELD HL,(ENDLIN)
Load Register Pair HL with the word ENDLIN holds at 1EAAH, the address of the last line of the block.
1EE0
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, the low byte of that line's link, which is the first byte past the end of the block.
1EE1
INC HL 23
Increment Register Pair HL to the high byte of that link.
1EE2
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE addresses the byte after the block.
1EE3
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that address into Register Pair HL to be measured from.
1EE4
LD DE,(1EA7H) ED 5B A7 1ELD DE,(STRTLIN)
Load Register Pair DE with the word STRTLIN holds at 1EA7H, the address of the first line of the block.
1EE8
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1EE9
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the first byte of the block from the first byte past it, which is the length of the block. No borrow is possible here, which is what makes the subtraction at 1EF0H safe without an OR A of its own.
1EEB
LD (235CH),HL 22 5C 23LD (TOMOVE),HL
Store Register Pair HL into TOMOVE at 235CH, the length of the block in bytes, which the three block copies at 1FE5H, 207BH and the count at 2096H all read.
1EEE
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the length the move needs into Register Pair DE.
1EEF
POP HL E1
Pop Register Pair HL, the count of free bytes that 1EDCH pushed, with the flags of the subtraction above left standing.
1EF0
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the length the block needs from the free memory there is, with the Carry Flag the subtraction at 1EE9H left clear because that one could not borrow.
1EF2
Jump to NOMEM at 234AH on Carry, the block being longer than the free memory, which gives error 7, Out of memory, through OMERR 425CH.
1EF5
LD HL,(1EA7H) 2A A7 1ELD HL,(STRTLIN)
Load Register Pair HL with the word STRTLIN holds at 1EA7H, the address the block stands at now.
1EF8
LD DE,(235EH) ED 5B 5E 23LD DE,(NEWLIN)
Load Register Pair DE from NEWLIN at 235EH, the address the block is to be put at, which 1E8BH wrote.
1EFC
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1EFD
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the place the block is going from the place it stands, which sets the Carry Flag when the block is moving to a higher address. The source calls that direction up, meaning later in the listing.
1EFF
PUSH AF F5
Push Register Pair AF, which puts that Carry Flag on the stack: it is the one thing the rest of MOVE cannot work out again, and 1FEBH, 2004H, 206DH, 208EH and 209AH all read it from there.
1F00
LD HL,(1E86H) 2A 86 1ELD HL,(POSN3)
Load Register Pair HL with the word POSN3 holds at 1E86H, the address of the line the block is to be put after.
1F03
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, the low byte of that line's link.
1F04
INC HL 23
Increment Register Pair HL to the high byte of that link.
1F05
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE addresses the place the block is to be put at, which is the same value NEWLIN holds.
1F06
LD HL,(1EA7H) 2A A7 1ELD HL,(STRTLIN)
Load Register Pair HL with the word STRTLIN holds at 1EA7H, the address the block stands at now.
1F09
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the place it is going into Register Pair HL and the place it stands into Register Pair DE.
1F0A
PUSH AF F5
Push Register Pair AF a second time, the direction flag again, because the OR A below destroys the flags and the Carry Flag is wanted after the subtraction.
1F0B
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1F0C
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, which leaves the distance from where the block stands to where it is going.
1F0E
POP AF F1
Pop Register Pair AF, the direction flag that 1F0AH pushed, the subtraction having spoilt the one in the flags.
1F0F
Jump to DIR2 at 1F18H on NC, the block moving down to a lower address, in which case the distance just worked out is the whole of the offset.
1F11
LD DE,(235CH) ED 5B 5C 23LD DE,(TOMOVE)
Load Register Pair DE from TOMOVE at 235CH, the length of the block, which the offset of an upward move has to lose.
1F15
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1F16
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the length of the block from the distance, because the lines standing above the hole the block leaves come down by that length before the block is put back.
1F18DIR2
LD (1FCCH),HL 22 CC 1FLD (OFFSET),HL
DIR2 (1F18H): store Register Pair HL into OFFSET at 1FCCH, the operand of the LD HL instruction at 1FCBH, which RANGE adds to every reference that falls inside the block.
1F1B
OR 01H F6 01
Or Register A with 01H, which leaves Register A holding something other than 00H whatever the walks and counts above left in it, because the cell below is read as a flag and not as a number.

1F1DH - TIME2: the Line References Marked and Written Back, Run Twice (1F1DH-1FB9H)

This is the part of MOVE that makes it more than a block copy, and it is one walk of the whole program run twice over. The problem it solves is that the lines being moved are about to be renumbered, so every GOTO, GOSUB, ON ERROR GOTO, RESTORE and THEN in the program that names one of them has to be given its new number, and the new numbers are not known until the move is done. The answer is to turn each such reference into the address of the line it names, plus OFFSET 1FCCH so that it is the address the line will have once it has moved, and then after the move to turn every address back into the number the line now carries. The interpreter already keeps a line reference in two forms and that is what makes it possible: the 0EH token with the number after it as it was typed, and the 0DH token with the line's address after it, which is what a GOTO leaves behind once it has resolved one. So pass 1 writes 0DH and an address and pass 2 writes 0EH and a number, and DOPASS1 2355H is the flag that says which pass is running, nonzero for the first and 00H for the second. The flag is read at 1F36H in the middle of the walk rather than at the top, so the two passes are one body of code with one test. Pass 1 looks for the pair A8H 89H, ON ERROR GOTO, as well as for a bare 0EH, because an ON ERROR GOTO 0 may not be touched; pass 2 looks only for the 0DH it wrote. Neither pass takes any notice of a string literal or of REM text, which VARFIND at 212CH is careful to step over: the walk is safe only because the tokenizer leaves no 0EH or 0DH byte in either, a number in a string being stored as its characters.

1F1DTIME2
LD (2355H),A 32 55 23LD (DOPASS1),A
TIME2 (1F1DH), which 1F1BH falls into for the first pass and 20BDH jumps to for the second: store Register A into DOPASS1 at 2355H, which 1F1BH left not 00H for pass 1 and 20B9H cleared to 00H for pass 2.
1F20
LD HL,(6E9EH) 2A 9E 6ELD HL,(PGMBGN)
Load Register Pair HL from PGMBGN at 6E9EH, the address of the first line of the program, so that the walk starts at the top of the text.
1F23
DEC HL 2B
Decrement Register Pair HL by one, because the increment at the top of the walk is about to put it back and the walk is written to be entered from the line above.
1F24PAS1
INC HL 23
PAS1 (1F24H), the top of the walk and the point every line end comes back to: increment Register Pair HL to the low byte of this line's link.
1F25
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, that low byte.
1F26
INC HL 23
Increment Register Pair HL to the high byte of the link.
1F27
OR (HL) B6
Or Register A with the byte Register Pair HL addresses, which sets the Zero Flag when the link is 0000H and so the program has ended.
1F28
Jump to PAS1DUN at 1FD3H on Z, the whole program having been walked, which reads DOPASS1 at 2355H to find out which of the two passes has just finished.
1F2B
INC HL 23
Increment Register Pair HL to the low byte of this line's own number.
1F2C
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, that low byte.
1F2D
INC HL 23
Increment Register Pair HL to the high byte of the number.
1F2E
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the number of the line being walked, which the message at 1F83H needs and which is kept on the stack across each reference.
1F2FPAS1A
PAS1A (1F2FH): call NXTCHAR at 5E93H, which steps the text pointer on and brings the next byte of the line back in Register A, unpacking a number token and leaving the place to carry on from in IPOS at 7145H.
1F32PAS1B
OR A B7
PAS1B (1F32H), which 1F46H and 1F4DH reach so that a byte already read is weighed again: set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
1F33
Jump back to PAS1 at 1F24H on Z, this line having ended, which goes round to the next line of the program.
1F35
LD C,A 4F
Load Register C from Register A, the byte just read, because the flag test below needs Register A for itself.
1F36
LD A,(2355H) 3A 55 23LD A,(DOPASS1)
Load Register A with the byte at DOPASS1 2355H, which says which of the two passes is running.
1F39
OR A B7
Set the flags from Register A with OR A, which gives Z when DOPASS1 at 2355H holds 00H and so the second pass is running.
1F3A
LD A,C 79
Load Register A from Register C, the byte of the line put back, a load changing no flag, so that the jump below acts on the pass and Register A holds the byte for the comparisons after it.
1F3B
Jump to PAS2 at 1F98H on Z, the second pass, which looks for the 0DH token the first pass wrote and for nothing else.
1F3D
CP 0A8H FE A8
Compare Register A with 0A8H, the token for ON, which is the first byte of the only reference in the language whose line number may be a zero.
1F3F
Jump to PAS1C at 1F59H on NZ, the byte not being ON, which weighs it as a plain line reference instead.
1F41
Call NXTCHAR at 5E93H, which brings the byte after the ON back in Register A.
1F44
CP 89H FE 89
Compare Register A with 89H, the token for ERROR, so that the pair A8H 89H is ON ERROR and nothing else can be.
1F46
Jump back to PAS1B at 1F32H on NZ, an ON that is not an ON ERROR, which weighs the byte just read for itself rather than reading another.
1F48
Call NXTCHAR at 5E93H, which brings the byte after the ERROR back in Register A, where GOTO and its line number are to stand.
1F4B
CP 0EH FE 0E
Compare Register A with 0EH, the token the tokenizer leaves in front of a line number as it was typed.
1F4D
Jump back to PAS1B at 1F32H on NZ, the ON ERROR not being followed by a line number, which is an ON ERROR GOTO whose number has already been resolved or a statement in error.
1F4F
PUSH DE D5
Push Register Pair DE, the number of the line being walked, which the reference handling below needs the pair for.
1F50
Call NUMPOSN at 5FAEH with the Zero Flag the comparison above set, which brings the referenced line number back in Register Pair DE and leaves the place to carry on from in IPOS at 7145H.
1F53
LD A,D 7A
Load Register A from Register D, the high byte of the referenced number.
1F54
OR E B3
Or Register A with Register E, its low byte, which gives Z when the reference is to line zero.
1F55
Jump to PAS1D at 1F61H on NZ, the reference naming a real line, which is treated exactly as a plain one.
1F57
Jump to PAS1F at 1F87H, the reference being ON ERROR GOTO 0, which turns error trapping off and names no line, so it is stepped over untouched.
1F59PAS1C
CP 0EH FE 0E
PAS1C (1F59H): compare Register A with 0EH, the unresolved line reference token, which is what every GOTO, GOSUB, THEN, RESTORE and RUN that names a line carries in front of its number.
1F5B
Jump back to PAS1A at 1F2FH on NZ, the byte being anything else, which reads the next byte of the line.
1F5D
PUSH DE D5
Push Register Pair DE, the number of the line being walked, which the message at 1F83H wants if the reference turns out to name no line.
1F5E
Call NUMPOSN at 5FAEH with the Zero Flag the comparison above set, which brings the referenced line number back in Register Pair DE and leaves the place to carry on from in IPOS at 7145H.
1F61PAS1D
PUSH HL E5
PAS1D (1F61H), which 1F55H also reaches: push Register Pair HL, the place in the line, which FIND below walks the program with.
1F62
Call FIND at 5AB4H, which looks for a line of the referenced number and comes back with the Carry Flag set and Register Pair BC addressing it when there is one.
1F65
Jump to UNDEF at 1F71H on NC, no line of that number being in the program, which reports it and carries the walk on rather than stopping.
1F67
Call RANGE at 1FBAH, which answers with the Carry Flag clear when the referenced number falls inside the block and in that case adds OFFSET at 1FCCH to Register Pair BC.
1F6A
Jump to PAS1E at 1F86H on Carry, the reference naming a line outside the block, which is left as the number it already is.
1F6C
DEC BC 0B
Decrement Register Pair BC, the address the line will stand at, by one, so that the address written is the line's link word less one, which is the form a resolved reference carries.
1F6D
LD A,0DH 3E 0D
Load Register A with 0DH, the token that says the two bytes after it are a line's address and not its number.
1F6F
Jump to PAS2A at 1FAAH, which writes that token and the address over the three bytes the reference occupies.
1F71UNDEF
UNDEF (1F71H): call 41E9H, which writes a carriage return only when the display is not already at the start of a line, so that the report begins on a line of its own.
1F74
LD HL,1F8BH 21 8B 1FLD HL,UNDEF$
Load Register Pair HL with 1F8BH, the address of the text Undef. line and the space after it.
1F77
PUSH DE D5
Push Register Pair DE, the referenced line number, which the text writer below destroys and which the number display wants back.
1F78
Call the text writer at 46A5H, which makes a temporary string of the bytes up to the 00H at 1F97H and sends them to the display.
1F7B
POP HL E1
Pop Register Pair HL, the referenced line number, which the display below writes as decimal digits.
1F7C
Call NUMDSP at 3139H, which writes the number in Register Pair HL to the display without a sign and without a trailing space.
1F7F
POP BC C1
Pop Register Pair BC, the place in the line that 1F61H pushed, which has to go back on the stack above the line number.
1F80
POP HL E1
Pop Register Pair HL, the number of the line the reference stands in, which 1F4FH or 1F5DH pushed.
1F81
PUSH HL E5
Push Register Pair HL, that line number again, so that PAS1F at 1F87H finds it where it expects it.
1F82
PUSH BC C5
Push Register Pair BC, the place in the line, so that PAS1E at 1F86H finds that where it expects it: the two pops and two pushes are a swap that gets the line number into Register Pair HL.
1F83
Call 3131H, which writes the word in and then the number in Register Pair HL, so that the whole report reads as the undefined number, in, and the line it was found in.
1F86PAS1E
POP HL E1
PAS1E (1F86H), which 1F6AH jumps to and 1FB9H returns to: pop Register Pair HL, the place in the line that 1F61H pushed.
1F87PAS1F
POP DE D1
PAS1F (1F87H), which 1F57H jumps to for an ON ERROR GOTO 0: pop Register Pair DE, the number of the line being walked.
1F88
DEC HL 2B
Decrement Register Pair HL by one, so that the increment inside NXTCHAR puts the text pointer back where it stood.
1F89PAS1G
PAS1G (1F89H), which 1F9AH reaches: jump back to PAS1A at 1F2FH, which reads the next byte of the line.
1F8B-1F97UNDEF$
DEFM "Undef. line " / DEFB 00H 55 6E 64 65 66 2E 20 6C 69 6E 65 20 00
UNDEF$ (1F8BH to 1F97H), the only text BASIC/OV2 carries of its own: the twelve characters Undef. line and a space, ended by the 00H at 1F97H that the text writer at 46A5H stops on. 1F74H is the one instruction that names it, and the number the reference asked for and the line it was found in are written after it by 1F7CH and 1F83H.
1F98PAS2
CP 0DH FE 0D
PAS2 (1F98H), which 1F3BH reaches when DOPASS1 at 2355H holds 00H: compare Register A with 0DH, the token the first pass wrote in front of every address it resolved.
1F9A
Jump back to PAS1G at 1F89H on NZ, the byte not being one of the first pass's marks, which reads the next byte of the line.
1F9C
PUSH DE D5
Push Register Pair DE, the number of the line being walked, which PAS1F at 1F87H pops back.
1F9D
Call NUMPOSN at 5FAEH with the Zero Flag the comparison above set, which brings the address the first pass wrote back in Register Pair DE and leaves the place to carry on from in IPOS at 7145H.
1FA0
PUSH HL E5
Push Register Pair HL, the place in the line, which PAS1E at 1F86H pops back.
1FA1
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the line's address into Register Pair HL so that its number can be read out of it.
1FA2
INC HL 23
Increment Register Pair HL by one, which with the two increments below reaches the line number from the address 1F6CH stored one short.
1FA3
INC HL 23
Increment Register Pair HL a second time, to the high byte of the line's link.
1FA4
INC HL 23
Increment Register Pair HL a third time, so that it addresses the low byte of the line's own number.
1FA5
LD C,(HL) 4E
Load Register C with the byte Register Pair HL addresses, the low byte of the number the line carries now, which the move and ADJ1 at 203DH have already given it.
1FA6
INC HL 23
Increment Register Pair HL to the high byte of that number.
1FA7
LD B,(HL) 46
Load Register B with the byte Register Pair HL addresses, so that Register Pair BC holds the line's new number.
1FA8
LD A,0EH 3E 0E
Load Register A with 0EH, the token that says the two bytes after it are a line number as it was typed, which puts the reference back into the form the tokenizer leaves.
1FAAPAS2A
LD HL,1F86H 21 86 1FLD HL,PAS1E
PAS2A (1FAAH), which 1F6FH also jumps to: load Register Pair HL with 1F86H, the address of PAS1E, which is the point the walk carries on from.
1FAD
PUSH HL E5
Push Register Pair HL, that address, so that the RET at 1FB9H goes to PAS1E at 1F86H.
1FAE
LD HL,(7145H) 2A 45 71LD HL,(IPOS)
Load Register Pair HL from IPOS at 7145H, the place in the line that the unpacking of the reference left, which stands one byte past the three the reference occupies.
1FB1
PUSH HL E5
Push Register Pair HL, that place, which the pop at 1FB8H balances. The value it brings back is thrown away by the pop at 1F86H, so the push is here to keep the depth right and for nothing else.
1FB2
DEC HL 2B
Decrement Register Pair HL to the high byte of the reference's two bytes.
1FB3
LD (HL),B 70
Store Register B into the byte Register Pair HL addresses, the high byte of the address or the number.
1FB4
DEC HL 2B
Decrement Register Pair HL to the low byte of those two.
1FB5
LD (HL),C 71
Store Register C into the byte Register Pair HL addresses, the low byte.
1FB6
DEC HL 2B
Decrement Register Pair HL to the token itself, the first of the three bytes.
1FB7
LD (HL),A 77
Store Register A into the byte Register Pair HL addresses, 0DH on the first pass and 0EH on the second.
1FB8
POP HL E1
Pop Register Pair HL, the place in the line pushed at 1FB1H, which balances that push.
1FB9
RET C9
Return to PAS1E at 1F86H, the address pushed at 1FADH, which pops the place in the line and the line number and carries the walk on.

1FBAH - RANGE: is a Line Number Inside the Block? (1FBAH-1FD2H)

Three callers and two answers. The Carry Flag clear says the number in Register Pair DE falls inside the block that is moving, from NUM1 2356H to NUM2 2358H with both ends counted, and in that case Register Pair BC comes back with OFFSET 1FCCH added to it, so that one call both tests the reference and works out where the line it names will stand. The Carry Flag set says the number is outside and leaves Register Pair BC alone. 1E68H uses it to refuse an insert point inside the block and 1F67H to decide whether a reference needs marking. Register Pair DE must come back untouched and so must Register Pair BC on the outside answer, which is why neither is used for the comparisons and why the equality case at 1FC7H skips the CCF rather than being folded into it.

1FBARANGE
LD HL,(2358H) 2A 58 23LD HL,(NUM2)
RANGE (1FBAH), which 1E68H and 1F67H call: load Register Pair HL from NUM2 at 2358H, the last line number of the block.
1FBD
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1FBE
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the number asked about from the last of the block, which sets the Carry Flag when the number stands above the block.
1FC0
RET C D8
Return on Carry, the number standing above the last line of the block and so outside it, with Register Pair BC and Register Pair DE as the caller left them.
1FC1
LD HL,(2356H) 2A 56 23LD HL,(NUM1)
Load Register Pair HL from NUM1 at 2356H, the first line number of the block.
1FC4
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1FC5
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the number asked about from the first of the block, which gives Z when it is the first line itself.
1FC7
Jump to RNG1 at 1FCBH on Z, the number being the first line of the block, which counts as inside it and must not reach the CCF below.
1FC9
CCF 3F
Complement the Carry Flag, so that a number standing below the first line of the block, which left no borrow, becomes the Carry Flag set that says outside.
1FCA
RET C D8
Return on Carry, the number standing below the first line of the block and so outside it, with Register Pair BC and Register Pair DE as the caller left them.
1FCBRNG1
LD HL,0000H 21 00 00
RNG1 (1FCBH), the inside answer: load Register Pair HL with the word OFFSET holds at 1FCCH, 0000H in the file, the distance every moved line's address changes by, which 1F18H wrote into this instruction's own operand.
1FCE
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the address FIND gave the line plus that distance, which is where the line will stand once the move is done.
1FCF
LD B,H 44
Load Register B from Register H, the high byte of that address.
1FD0
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC is the address the line will have.
1FD1
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag and so gives the answer that the number is inside the block.
1FD2
RET C9
Return to the caller with the Carry Flag clear and Register Pair BC holding the address the referenced line will stand at.

1FD3H - PAS1DUN and the Block Moved: the Shuffle, the Pointers and the Numbers (1FD3H-20BFH)

The move itself, and it is done in four steps because nothing in the program text may be left pointing at where a line used to be. First the block is lifted out whole into the free memory at LOPT 71A3H, which leaves a hole. Then the lines between the hole and the insert point are shuffled over it, an LDIR for a move up and an LDDR for a move down, and the instruction that does it is written at run time: 2022H and 2023H hold ED and B0 in the file and 201BH stores B8 over the second byte for the LDDR. Then the block is walked where it lies in free memory, every line in it getting its new link and its new number, the numbers running up from one past NUM3 1E9CH. Then it is put down in its new place and the lines of the shuffled region get their links adjusted, up by TOMOVE 235CH for a move down and down by it for a move up. Last of all ADJ4 20B9H clears DOPASS1 2355H and jumps back to TIME2 1F1DH, so that the second pass of the reference walk turns every address it marked back into the number the line now carries. The JR NC at 2024H reads a Carry Flag the downward path works out again at 2013H rather than the one 2007H put on the stack, and the two agree only because STRTLIN 1EA7H and NEWLIN 235EH can never be equal: 1E7CH refuses a move that would put the block where it already stands.

1FD3PAS1DUN
LD A,(2355H) 3A 55 23LD A,(DOPASS1)
PAS1DUN (1FD3H), which 1F28H reaches at the end of either pass: load Register A with the byte at DOPASS1 2355H, which says which pass has just finished.
1FD6
OR A B7
Set the flags from Register A with OR A, which gives Z when DOPASS1 at 2355H holds 00H and the second pass is the one that has finished.
1FD7
Jump to EXIT at 234EH on Z, both passes and the move itself being done, which puts the stack back from SAVSTK 2352H and jumps into READY 5920H.
1FDA
LD HL,(1EA7H) 2A A7 1ELD HL,(STRTLIN)
Load Register Pair HL with the word STRTLIN holds at 1EA7H, the first byte of the block that is to move.
1FDD
LD DE,(71A3H) ED 5B A3 71LD DE,(LOPT)
Load Register Pair DE from LOPT at 71A3H, the lowest free byte of memory, which is where the block is put while the shuffle runs.
1FE1
LD BC,(235CH) ED 4B 5C 23LD BC,(TOMOVE)
Load Register Pair BC from TOMOVE at 235CH, the length of the block in bytes, which 1EEBH worked out.
1FE5
LDIR ED B0
Copy the block to free memory with LDIR, which moves Register Pair BC bytes from the address in Register Pair HL to the address in Register Pair DE and leaves Register Pair DE one past the last byte written.
1FE7
LD (205FH),DE ED 53 5F 20LD (ENDPT),DE
Store Register Pair DE, that byte past the copy, into ENDPT at 205FH, the operand of the LD HL instruction at 205EH, which is what the walk at 203DH stops on.
1FEB
POP AF F1
Pop Register Pair AF, the direction flag that 1EFFH pushed, the Carry Flag set for a move to a higher address.
1FEC
PUSH AF F5
Push Register Pair AF straight back, the flag being wanted again at 2004H and this read being only to see it.
1FED
LD HL,(1EAAH) 2A AA 1ELD HL,(ENDLIN)
Load Register Pair HL with the word ENDLIN holds at 1EAAH, the address of the last line of the block.
1FF0
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, the low byte of that line's link.
1FF1
INC HL 23
Increment Register Pair HL to the high byte of that link.
1FF2
LD H,(HL) 66
Load Register H with the byte Register Pair HL addresses, that high byte.
1FF3
LD L,A 6F
Load Register L from Register A, the low byte, so that Register Pair HL addresses the first byte past the whole block.
1FF4
PUSH HL E5
Push Register Pair HL, that address, which the LDIR below reads as its source.
1FF5
PUSH HL E5
Push Register Pair HL a second time, so that the pop below can have it in another pair without losing it.
1FF6
POP BC C1
Pop Register Pair BC, the first byte past the block, which the subtraction below takes away from the insert point.
1FF7
LD HL,(235EH) 2A 5E 23LD HL,(NEWLIN)
Load Register Pair HL from NEWLIN at 235EH, the address the block is to be put at, which 1E8BH wrote.
1FFA
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
1FFB
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL, the byte past the block from the insert point, which for a move up is how many bytes have to be shuffled down over the hole.
1FFD
LD B,H 44
Load Register B from Register H, the high byte of that count.
1FFE
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC is the count the LDIR wants.
1FFF
POP HL E1
Pop Register Pair HL, the first byte past the block that 1FF4H pushed, which is the source of the shuffle for a move up.
2000
LD DE,(1EA7H) ED 5B A7 1ELD DE,(STRTLIN)
Load Register Pair DE with the word STRTLIN holds at 1EA7H, the first byte of the hole, which is where the shuffled bytes go for a move up.
2004
POP AF F1
Pop Register Pair AF, the direction flag again, which the instruction below must not be allowed to destroy before it is read.
2005
LD A,0B0H 3E B0
Load Register A with 0B0H, the second byte of an LDIR instruction, which is the one the shuffle of a move up wants. A load changes no flag, so the direction is still in them.
2007
PUSH AF F5
Push Register Pair AF, which puts the direction flag back on the stack because the downward path below spoils the flags and ADJ2 at 206DH needs it.
2008
Jump to DOMOV at 201BH on Carry, the block moving to a higher address, with Register Pair HL, Register Pair DE and Register Pair BC already set for the LDIR.
200A
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, the move being downward, which puts the first byte of the block into Register Pair HL and the byte past it into Register Pair DE.
200B
DEC HL 2B
Decrement Register Pair HL to the byte below the block, which is the highest byte the LDDR reads.
200C
DEC DE 1B
Decrement Register Pair DE to the last byte of the block, which is the highest byte the LDDR writes.
200D
PUSH HL E5
Push Register Pair HL, that source address, which the subtraction below is about to spoil.
200E
LD BC,(235EH) ED 4B 5E 23LD BC,(NEWLIN)
Load Register Pair BC from NEWLIN at 235EH, the address the block is to be put at, which for a downward move is the lowest byte that is shuffled.
2012
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
2013
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL, the insert point from the byte below the block, which leaves one short of the count and leaves the Carry Flag clear, which is what the JR NC at 2024H goes on.
2015
INC HL 23
Increment Register Pair HL to the true count of bytes to shuffle, which changes no flag and so leaves that Carry Flag standing.
2016
LD B,H 44
Load Register B from Register H, the high byte of the count.
2017
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC is the count the LDDR wants.
2018
POP HL E1
Pop Register Pair HL, the source address that 200DH pushed, the byte below the block.
2019
LD A,0B8H 3E B8
Load Register A with 0B8H, the second byte of an LDDR instruction, which is the one the shuffle of a move down wants.
201BDOMOV
LD (2023H),A 32 23 20LD (DIRECT),A
DOMOV (201BH), which 2008H also reaches: store Register A, B0H or B8H, into DIRECT at 2023H, which is the second byte of the instruction at 2022H and so decides whether that instruction copies up or down.
201E
LD (208CH),BC ED 43 8C 20LD (TOCNG),BC
Store Register Pair BC, the count of bytes being shuffled, into TOCNG at 208CH, the operand of the LD BC instruction at 208BH, which the pointer adjustment at 2090H reads.
2022
LDIR ED B0
The shuffle (2022H), the instruction 201BH has just written: move Register Pair BC bytes from the address in Register Pair HL to the address in Register Pair DE, ascending as an LDIR for a move up and descending as an LDDR for a move down, the file holding ED and B0 at 2022H and 2023H.
2024
Jump to ADJ0 at 202AH on NC, the move being downward, in which case the block goes at NEWLIN 235EH and ADJ2 at 2069H needs nothing more. B353: the flag read here is the one the subtraction at 2013H left and not the direction 2007H put on the stack, and the two agree only because 1E7CH refuses a move whose two addresses are equal.
2026
LD (2072H),DE ED 53 72 20LD (UPSTART),DE
Store Register Pair DE into UPSTART at 2072H, the operand of the LD DE instruction at 2071H: the LDIR has left Register Pair DE one past the shuffled bytes, which for a move up is where the block has to go.
202AADJ0
LD HL,(71A3H) 2A A3 71LD HL,(LOPT)
ADJ0 (202AH): load Register Pair HL from LOPT at 71A3H, the address the block was copied to, which the walk below starts at.
202D
PUSH HL E5
Push Register Pair HL, that address, which the subtraction below is about to spoil.
202E
LD DE,(1EA7H) ED 5B A7 1ELD DE,(STRTLIN)
Load Register Pair DE with the word STRTLIN holds at 1EA7H, the address the block was copied from.
2032
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
2033
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the block's old place from its place in free memory, which is the distance its own bytes have moved.
2035
LD (205AH),HL 22 5A 20LD (OFFSET1),HL
Store Register Pair HL into OFFSET1 at 205AH, the operand of the LD DE instruction at 2059H, which is how the walk below turns an old link into the next line's place in the copy.
2038
POP HL E1
Pop Register Pair HL, the address of the copy that 202DH pushed, which is the first line of the walk.
2039
LD BC,(1FCCH) ED 4B CC 1FLD BC,(OFFSET)
Load Register Pair BC from OFFSET at 1FCCH, the distance every moved line's address changes by, which is what each of their links has to gain.
203DADJ1
LD E,(HL) 5E
ADJ1 (203DH), the top of the walk through the copy: load Register E with the byte Register Pair HL addresses, the low byte of this line's old link.
203E
INC HL 23
Increment Register Pair HL to the high byte of that link.
203F
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the old link, an address in the program text.
2040
PUSH DE D5
Push Register Pair DE, that old link, which the end test at 205CH turns into the next line's place in the copy.
2041
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the old link into Register Pair HL for the addition below.
2042
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the old link plus OFFSET at 1FCCH, which is the address the next line will stand at once the move is done.
2043
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that new link into Register Pair DE and the place in the copy back into Register Pair HL.
2044
PUSH HL E5
Push Register Pair HL, the place in the copy, which the line number below wants the pair for.
2045
PUSH DE D5
Push Register Pair DE, the new link, which the line number below wants the pair for.
2046
LD DE,(1E9CH) ED 5B 9C 1ELD DE,(NUM3)
Load Register Pair DE from NUM3 at 1E9CH, the number the last line was given, which starts as the number the block is put after.
204A
INC DE 13
Increment Register Pair DE to the next number, so that the lines of the block run up one at a time from one past the insert line.
204B
LD (1E9CH),DE ED 53 9C 1ELD (NUM3),DE
Store Register Pair DE back into NUM3 at 1E9CH, so that the next turn of the walk gives the next line the number after this one.
204F
INC HL 23
Increment Register Pair HL to the low byte of this line's number, Register Pair HL having stood on the high byte of its link.
2050
LD (HL),E 73
Store Register E into the byte Register Pair HL addresses, the low byte of the new number.
2051
INC HL 23
Increment Register Pair HL to the high byte of the number.
2052
LD (HL),D 72
Store Register D into the byte Register Pair HL addresses, so that the line in the copy now carries its new number.
2053
POP DE D1
Pop Register Pair DE, the new link that 2045H pushed.
2054
POP HL E1
Pop Register Pair HL, the place in the copy that 2044H pushed, the high byte of the line's link.
2055
LD (HL),D 72
Store Register D into the byte Register Pair HL addresses, the high byte of the new link.
2056
DEC HL 2B
Decrement Register Pair HL to the low byte of the link.
2057
LD (HL),E 73
Store Register E into the byte Register Pair HL addresses, so that the line in the copy now carries its new link as well.
2058
POP HL E1
Pop Register Pair HL, the old link that 2040H pushed, which says where the next line stood in the program text.
2059
LD DE,0000H 11 00 00
Load Register Pair DE with the word OFFSET1 holds at 205AH, 0000H in the file and the distance the block's bytes moved to reach free memory, which 2035H wrote into this instruction's own operand.
205C
ADD HL,DE 19
Add Register Pair DE to Register Pair HL, the old link plus that distance, which is where the next line of the block stands in the copy.
205D
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that place into Register Pair DE for the comparison below.
205E
LD HL,0000H 21 00 00
Load Register Pair HL with the word ENDPT holds at 205FH, 0000H in the file and the byte past the end of the copy, which 1FE7H wrote into this instruction's own operand.
2061
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
2062
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the next line's place in the copy from the end of the copy, which gives Z when there is no next line.
2064
Jump to ADJ2 at 2069H on Z, every line of the copy having been given its new link and its new number.
2066
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the next line's place in the copy into Register Pair HL.
2067
Jump back to ADJ1 at 203DH, which does the same for that line.
2069ADJ2
LD DE,(235EH) ED 5B 5E 23LD DE,(NEWLIN)
ADJ2 (2069H): load Register Pair DE from NEWLIN at 235EH, the insert point, which is where the block goes for a move down.
206D
POP AF F1
Pop Register Pair AF, the direction flag that 2007H pushed, the Carry Flag set for a move up.
206E
PUSH AF F5
Push Register Pair AF straight back, because 2084H reads it again to decide which region of the program the pointer adjustment walks.
206F
Jump to ADJ2A at 2074H on NC, the move being downward, in which case NEWLIN 235EH is the destination and Register Pair DE already holds it.
2071
LD DE,0000H 11 00 00
Load Register Pair DE with the word UPSTART holds at 2072H, 0000H in the file and the place the shuffle left for the block, which 2026H wrote into this instruction's own operand.
2074ADJ2A
LD HL,(71A3H) 2A A3 71LD HL,(LOPT)
ADJ2A (2074H), which 206FH also reaches: load Register Pair HL from LOPT at 71A3H, the free memory the block was put in.
2077
LD BC,(235CH) ED 4B 5C 23LD BC,(TOMOVE)
Load Register Pair BC from TOMOVE at 235CH, the length of the block in bytes.
207B
LDIR ED B0
Copy the block back into the program with LDIR, which moves Register Pair BC bytes from the address in Register Pair HL to the address in Register Pair DE, so that the block now stands where it was asked for.
207D
LD HL,(1EA7H) 2A A7 1ELD HL,(STRTLIN)
Load Register Pair HL with the word STRTLIN holds at 1EA7H, the block's old place, which for a move up is the lowest byte of the shuffled region in its new position.
2080
LD BC,(235CH) ED 4B 5C 23LD BC,(TOMOVE)
Load Register Pair BC from TOMOVE at 235CH, the length of the block, which the downward case adds to the insert point below.
2084
POP AF F1
Pop Register Pair AF, the direction flag that 206EH pushed, for the last time.
2085
Jump to WASUP at 208BH on Carry, the move having been upward, with Register Pair HL already standing at the first line of the shuffled region.
2087
LD HL,(235EH) 2A 5E 23LD HL,(NEWLIN)
Load Register Pair HL from NEWLIN at 235EH, the insert point, the move having been downward so that the shuffled region now begins above the block.
208A
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the insert point plus the length of the block, which is the first line of the shuffled region for a move down.
208BWASUP
LD BC,0000H 01 00 00
WASUP (208BH), which 2085H also reaches: load Register Pair BC with the word TOCNG holds at 208CH, 0000H in the file and the count of bytes that were shuffled, which 201EH wrote into this instruction's own operand.
208E
PUSH AF F5
Push Register Pair AF, the direction flag, because the addition below destroys the flags and 2095H wants it back.
208F
PUSH HL E5
Push Register Pair HL, the first line of the shuffled region, which the addition below spoils.
2090
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, that address plus the count of shuffled bytes, which is the byte past the shuffled region.
2091
LD (20AFH),HL 22 AF 20LD (ENDPT1),HL
Store Register Pair HL into ENDPT1 at 20AFH, the operand of the LD HL instruction at 20AEH, which the walk at 20A5H stops on.
2094
POP HL E1
Pop Register Pair HL, the first line of the shuffled region that 208FH pushed.
2095
POP AF F1
Pop Register Pair AF, the direction flag that 208EH pushed, which the jump at 209AH reads.
2096
LD BC,(235CH) ED 4B 5C 23LD BC,(TOMOVE)
Load Register Pair BC from TOMOVE at 235CH, the length of the block, which is how far every line of the shuffled region has moved.
209A
Jump to ADJ3 at 20A5H on NC, the move having been downward, in which case the shuffled lines have gone up by the length of the block and Register Pair BC is already the amount to add.
209C
PUSH HL E5
Push Register Pair HL, the first line of the shuffled region, which the negation below spoils.
209D
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag so that the subtraction below gives a true zero.
209E
SBC HL,HL ED 62
Subtract Register Pair HL from itself with the Carry Flag clear, which leaves Register Pair HL holding 0000H whatever it held before.
20A0
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL, the length of the block from zero, which leaves the negative of it: the shuffled lines of a move up have come down by that much.
20A2
LD B,H 44
Load Register B from Register H, the high byte of that negative amount.
20A3
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC is what each link has to gain.
20A4
POP HL E1
Pop Register Pair HL, the first line of the shuffled region that 209CH pushed.
20A5ADJ3
LD E,(HL) 5E
ADJ3 (20A5H), the top of the walk through the shuffled region: load Register E with the byte Register Pair HL addresses, the low byte of this line's link.
20A6
INC HL 23
Increment Register Pair HL to the high byte of that link.
20A7
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the link as it stood before the shuffle.
20A8
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that link into Register Pair HL for the addition below.
20A9
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the old link plus the amount worked out above, which is where the next line stands now.
20AA
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the new link into Register Pair DE and the place in the text back into Register Pair HL.
20AB
LD (HL),D 72
Store Register D into the byte Register Pair HL addresses, the high byte of the new link.
20AC
DEC HL 2B
Decrement Register Pair HL to the low byte of the link.
20AD
LD (HL),E 73
Store Register E into the byte Register Pair HL addresses, so that this line now points at the next one where it really is.
20AE
LD HL,0000H 21 00 00
Load Register Pair HL with the word ENDPT1 holds at 20AFH, 0000H in the file and the byte past the shuffled region, which 2091H wrote into this instruction's own operand.
20B1
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
20B2
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the new link from the end of the region, which gives Z when the walk has reached it.
20B4
Jump to ADJ4 at 20B9H on Z, every line of the shuffled region having had its link put right.
20B6
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the new link into Register Pair HL and so addresses the next line.
20B7
Jump back to ADJ3 at 20A5H, which does the same for that line.
20B9ADJ4
XOR A AF
ADJ4 (20B9H): clear Register A with XOR A, making 00H, the value that says the second pass of the reference walk is the one to run.
20BA
LD (2355H),A 32 55 23LD (DOPASS1),A
Store Register A into DOPASS1 at 2355H, which the test at 1F39H reads to send the walk down the second pass.
20BD
Jump to TIME2 at 1F1DH, which stores Register A into DOPASS1 at 2355H a second time and walks the whole program again, turning every address the first pass marked back into the number the line carries now.

20C0H - DOFIND and KEYFIND: SEARCH, FIND and a Keyword Looked For (20C0H-212BH)

SEARCH and FIND are one piece of code and the only difference between them is what happens when a match is found. SHOW 21E8H reads DTYPE 21E9H, which this entry fills with the command token: 03H, SEARCH, shows the whole line and stops there; 04H, FIND, writes the line's number and carries on, so that FIND lists every line that matches and SEARCH walks them one at a time. What is searched for is read out of the line buffer at LBUF+1 6EFAH and not out of INBUF 7039H, which is the one place this overlay prefers the tokenized form of the command line to the characters as they were typed, and it has to: a keyword stands in the program text as one byte, so it can only be looked for as the byte the tokenizer made of it. Five cells in the enhancement package's own area remember what was looked for, so that a bare S or F picks up where the last one stopped: LSTTYP$ 83DBH, LSTLIN$ 83DCH, LSTNUM$ 83DEH, LSTKEY$ 83E0H and the eleven bytes of LSTVAR$ 83E1H. The first character settles which of the three searches runs: a quotation mark is refused outright, a letter goes to VARFIND 212CH, a digit to NUMFIND 221EH, and anything from 3AH up to a token goes to KEYFIND. KEYFIND is also the only code in the whole of the Disk BASIC that uses the alternate accumulator: no row of BASIC/CMD's 21978 bytes decodes as EX AF,AF', and KEY2 2118H uses it to hold the result of one comparison while a second is made.

20C0DOFIND
LD (21E9H),A 32 E9 21LD (DTYPE),A
DOFIND (20C0H), which 1E0BH reaches for SEARCH and FIND: store Register A, the command token 03H or 04H, into DTYPE at 21E9H, which is the operand of the LD A instruction at 21E8H and so what SHOW reads.
20C3
XOR A AF
Clear Register A with XOR A, making 00H, the value that says no line has been shown yet.
20C4
LD (21F1H),A 32 F1 21LD (FTIME),A
Store Register A into FTIME at 21F1H, the operand of the LD A instruction at 21F0H, which SHONUM reads to decide whether a comma and a space go in front of the number.
20C7
LD HL,6EFAH 21 FA 6E
Load Register Pair HL with 6EFAH, LBUF+1, the first byte of the tokenized command line, where CKABBR of the enhancement package wrote the command token over the abbreviation letter.
20CA
Call NXTCHAR at 5E93H, which steps past that token and brings the first byte of what is to be searched for back in Register A.
20CD
Jump to AGAIN at 2265H on Z, the line ending right after the command, which repeats the last search from the line it stopped at.
20D0
CP 22H FE 22
Compare Register A with 22H, a quotation mark, which would open a string for the search to look for.
20D2
Jump to BADLIN at 2346H on Z, a quoted string having been asked for, which neither of the three searches below can look for: a literal in the program text is not one byte and not a name.
20D5
CP 41H FE 41
Compare Register A with 41H, the letter A, the lowest character a variable name may begin with.
20D7
Jump to CPNUM at 20DDH on Carry, the character standing below A, which leaves a digit, a punctuation mark or a control character to be weighed below.
20D9
CP 5BH FE 5B
Compare Register A with 5BH, one past the letter Z, the highest character a variable name may begin with.
20DB
Jump to VARFIND at 212CH on Carry, the character being a letter from A to Z, so that a variable name is what is being looked for.
20DDCPNUM
CP 30H FE 30
CPNUM (20DDH): compare Register A with 30H, the digit zero, the lowest character a line number may begin with.
20DF
Jump to BADLIN at 2346H on Carry, the character standing below the digits: nothing from 00H to 2FH is the beginning of anything that can be searched for.
20E2
CP 3AH FE 3A
Compare Register A with 3AH, one past the digit nine, the highest character a line number may begin with.
20E4
Jump to NUMFIND at 221EH on Carry, the character being a digit, so that a reference to a line number is what is being looked for.
20E7KEYFIND
LD (83DBH),A 32 DB 83LD (LSTTYP$),A
KEYFIND (20E7H), which 20E4H falls past: store Register A, the token to look for, into LSTTYP$ at 83DBH, so that a bare S or F can repeat this search.
20EA
CP 0FFH FE FF
Compare Register A with 0FFH, the prefix the tokenizer puts in front of the fifty-one function tokens, which are two bytes where every other keyword is one.
20EC
LD B,0FFH 06 FF
Load Register B with 0FFH, which says that only one byte is being looked for. A load changes no flag, so the comparison above is still in them for the jump below.
20EE
Jump to KF1 at 20F2H on NZ, the token being an ordinary one byte keyword, with Register B left saying there is no second byte.
20F0
INC HL 23
Increment Register Pair HL to the second byte of the two byte token, the first having been FFH.
20F1
LD B,(HL) 46
Load Register B with the byte Register Pair HL addresses, that second byte, which is the half that tells one function from another.
20F2KF1
LD C,A 4F
KF1 (20F2H), which 20EEH also reaches: load Register C from Register A, the first byte of the token, which the search loop compares every byte of the program against.
20F3
LD A,B 78
Load Register A from Register B, the second byte or the FFH that stands for none, so that it can be stored below.
20F4
LD (83E0H),A 32 E0 83LD (LSTKEY$),A
Store Register A into LSTKEY$ at 83E0H, the second half of the token, which AGAIN reads at 228DH when it repeats a keyword search.
20F7
LD HL,(6E9EH) 2A 9E 6ELD HL,(PGMBGN)
Load Register Pair HL from PGMBGN at 6E9EH, the address of the first line of the program, so that the search starts at the top.
20FAKEYREP
DEC HL 2B
KEYREP (20FAH), which AGAIN jumps to at 2291H with Register Pair HL on the line after the last match: decrement Register Pair HL by one, which the increment inside GTPTR puts back.
20FBKEYLP
KEYLP (20FBH), the top of the search, one turn to a line: call GTPTR at 21DAH, which saves this line's link in NXTPO at 2207H and gives Z when the link is 0000H.
20FE
Jump to EXIT at 234EH on Z, the program having been walked to its end, which goes back to READY 5920H with nothing more shown.
2101
INC HL 23
Increment Register Pair HL to the low byte of this line's own number, Register Pair HL having been left on the high byte of its link.
2102
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, that low byte.
2103
INC HL 23
Increment Register Pair HL to the high byte of the number.
2104
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the number of the line being searched.
2105
LD (83DCH),DE ED 53 DC 83LD (LSTLIN$),DE
Store Register Pair DE into LSTLIN$ at 83DCH, so that SHOW has the number to write and a bare S or F can start again from this line.
2109KEYLP1
KEYLP1 (2109H), the top of the walk through one line: call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A.
210C
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
210D
Jump back to KEYLP at 20FBH on Z, this line having ended with no match in it, which goes on to the next line.
210F
CP 0FFH FE FF
Compare Register A with 0FFH, the two byte token prefix, which has to be weighed as a pair whatever is being looked for.
2111
Jump to KEY2 at 2118H on Z, the byte in the line being the prefix of a function token, so that both of its bytes are compared.
2113
CP C B9
Compare Register A with Register C, the first byte of the token being looked for, the byte in the line being an ordinary one.
2114
Jump to KEY3 at 2127H on Z, the one byte token in the line being the one asked for, which shows the line.
2116
Jump back to KEYLP1 at 2109H, the byte not matching, which reads the next byte of the line.
2118KEY2
CP C B9
KEY2 (2118H): compare Register A with Register C, which asks whether FFH itself is the first byte of the token being looked for, Register A holding FFH here.
2119
EX AF,AF' 08
Exchange Register Pair AF with its alternate, which puts the result of that comparison out of the way in the alternate accumulator while the second byte is read and compared.
211A
Call NXTCHAR at 5E93H, which brings the second byte of the two byte token back in Register A, and which is called whether or not the first byte matched so that the walk steps over the pair either way.
211D
OR A B7
Set the flags from Register A with OR A, which gives Z if the line ends after the prefix, which no line a tokenizer wrote ever does.
211E
Jump back to KEYLP at 20FBH on Z, the line having ended in the middle of a two byte token, which goes on to the next line and leaves the saved comparison in the alternate accumulator unread.
2120
CP B B8
Compare Register A with Register B, the second byte of the token being looked for, which is FFH when only one byte was asked for and so cannot match a function's second byte.
2121
EX AF,AF' 08
Exchange Register Pair AF with its alternate, which brings the first comparison back into the flags and puts the second one away.
2122
Jump back to KEYLP1 at 2109H on NZ, the first byte not having matched, which reads the next byte of the line.
2124
EX AF,AF' 08
Exchange Register Pair AF with its alternate a third time, which brings the second comparison back into the flags.
2125
Jump back to KEYLP1 at 2109H on NZ, the second byte not having matched, so that both halves of the token had to agree.
2127KEY3
KEY3 (2127H), which 2114H also reaches: call SHOW at 21E8H, which for FIND writes the line's number and returns and for SEARCH shows the whole line and never comes back.
212A
Jump back to KEYLP at 20FBH, SHOW having returned, which carries the search on at the line after the one just named.

212CH - VARFIND: a Variable Name Looked For (212CH-21D9H)

The longest of the three searches and the only one that has to understand what it walks past. A keyword and a line reference are each one byte in the program text and can be compared outright, but a variable name is characters, and those characters also occur inside string literals, inside REM text and inside longer names, so this search steps over all three. The name typed after the command is collected into LSTVAR$ 83E1H a character at a time while VALID 229DH says the character belongs to a name, which gives it a length from one to ten that is kept in Register C for the whole of the search and copied back into Register B at the top of every line, and that length is also what LSTTYP$ 83DBH holds, so that AGAIN at 2288H can tell a variable search from a keyword search by whether the saved type is below 80H. A match has to be the whole name and nothing more: when the last character agrees, 218EH to 21A2H decide whether what follows could make it a longer name, and a name of the full ten characters is accepted at once because no name can be longer. 216DH to 2176H is the one piece of this file that the 6.3.1 build puts in and the 6.3.0 build leaves out: BMOVE/ASM has it inside an IF on the build switch, with a jump to a patch area in the other branch, and what it adds is that the apostrophe form of REM and a two byte function token are both stepped over.

212CVARFIND
LD DE,83E1H 11 E1 83LD DE,LSTVAR$
VARFIND (212CH), which 20DBH reaches: load Register Pair DE with 83E1H, LSTVAR$, the eleven bytes of the enhancement package's area that the name being looked for is collected into.
212F
LD B,0AH 06 0A
Load Register B with 0AH, ten, the longest name BASIC keeps, which is also the count the collecting loop runs down.
2131VAR1
LD A,(HL) 7E
VAR1 (2131H), the top of the collecting loop: load Register A with the byte Register Pair HL addresses, one character of the name as it was typed.
2132
INC HL 23
Increment Register Pair HL to the character after it, which is read on the next turn.
2133
Call VALID at 229DH, which gives Z when the character is one a variable name may hold and NZ when it is not.
2136
Jump to VAR2 at 213CH on NZ, the character not belonging to a name, so that the name has ended and its length is known.
2138
LD (DE),A 12
Store Register A into the byte Register Pair DE addresses, which puts that character into LSTVAR$ at 83E1H and the ten bytes above it.
2139
INC DE 13
Increment Register Pair DE to the next byte of that area.
213A
Decrement Register B and jump back to VAR1 at 2131H while it is not zero, which collects up to ten characters and no more.
213CVAR2
EX DE,HL EB
VAR2 (213CH), which 2136H also reaches: exchange Register Pair DE with Register Pair HL, which puts the place in LSTVAR$ into Register Pair HL.
213D
LD (HL),00H 36 00
Store 00H into the byte Register Pair HL addresses, which ends the collected name, and which is why LSTVAR$ at 83E1H is eleven bytes for a name of ten.
213F
LD A,0AH 3E 0A
Load Register A with 0AH, ten, the count the loop above started from.
2141
SUB B 90
Subtract Register B from Register A, what is left of that count, which leaves the length of the name collected and gives Z when nothing was collected at all.
2142
Jump to BADLIN at 2346H on Z, no character of a name having been collected. Nothing can reach it: 20D5H and 20D9H have already proved the first character is a letter, which VALID accepts.
2145
LD (83DBH),A 32 DB 83LD (LSTTYP$),A
Store Register A, the length, into LSTTYP$ at 83DBH, which doubles as the kind of the last search: a value below 80H means a variable of that many characters.
2148
LD B,A 47
Load Register B from Register A, the length, which the match below counts down one character at a time.
2149
LD C,A 4F
Load Register C from Register A, the length again, which is kept for the whole search so that every line can set Register B back from it.
214A
LD HL,(6E9EH) 2A 9E 6ELD HL,(PGMBGN)
Load Register Pair HL from PGMBGN at 6E9EH, the address of the first line of the program, so that the search starts at the top.
214DVARREP
DEC HL 2B
VARREP (214DH), which AGAIN jumps to at 229AH with Register Pair HL on the line after the last match: decrement Register Pair HL by one, which the increment inside GTPTR puts back.
214EVARLP
VARLP (214EH), the top of the search, one turn to a line: call GTPTR at 21DAH, which saves this line's link in NXTPO at 2207H and gives Z when the link is 0000H.
2151
Jump to EXIT at 234EH on Z, the program having been walked to its end, which goes back to READY 5920H.
2154
LD B,C 41
Load Register B from Register C, the length of the name, because a part match on the line before will have left Register B somewhere in the middle of it.
2155
INC HL 23
Increment Register Pair HL to the low byte of this line's own number, Register Pair HL having been left on the high byte of its link.
2156
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, that low byte.
2157
INC HL 23
Increment Register Pair HL to the high byte of the number.
2158
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the number of the line being searched.
2159
LD (83DCH),DE ED 53 DC 83LD (LSTLIN$),DE
Store Register Pair DE into LSTLIN$ at 83DCH, so that SHOW has the number to write and a bare S or F can start again from this line.
215DVARLP3
LD DE,83E1H 11 E1 83LD DE,LSTVAR$
VARLP3 (215DH), which the four places that give up on a part match reach: load Register Pair DE with 83E1H, LSTVAR$, which puts the comparison back at the first character of the name.
2160VARLP1
VARLP1 (2160H), the top of the walk through one line: call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A.
2163
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
2164
Jump back to VARLP at 214EH on Z, this line having ended, which goes on to the next line of the program.
2166
CP 8FH FE 8F
Compare Register A with 8FH, the token for REM, whose text is characters the tokenizer never looked at and which must not be searched.
2168VP0
VP0 (2168H), which 216FH also reaches: call DUMPLIN at 21D3H on Z, which reads the rest of the line and throws it away, returning with the Zero Flag set because it stops on the 00H.
216B
Jump back to VARLP at 214EH on Z, a REM having been stepped over, which goes on to the next line of the program.
216D
CP 84H FE 84
Compare Register A with 84H, the token for the apostrophe form of REM, which the tokenizer stores as a colon, a REM and this byte.
216F
Jump back to VP0 at 2168H on Z, the rest of the line being a remark as well, and the Zero Flag that this comparison set is what makes the conditional call there run.
2171
CP 0FFH FE FF
Compare Register A with 0FFH, the prefix of a two byte function token, whose second byte may read as a letter and must not be taken for the start of a name.
2173
Jump to VP0A at 2178H on NZ, the byte being an ordinary one, which weighs it as a character.
2175
INC HL 23
Increment Register Pair HL past the second byte of the two byte token, which is the whole of what this branch of the build switch adds.
2176
Jump back to VARLP1 at 2160H, the function token having been stepped over, which reads the byte after it.
2178VP0A
CP 22H FE 22
VP0A (2178H), which 2173H also reaches: compare Register A with 22H, a quotation mark, which opens a string literal whose characters must not be searched.
217A
Jump to BYSTR at 21B1H on Z, a string literal having begun, which runs to its closing quotation mark.
217C
CP 41H FE 41
Compare Register A with 41H, the letter A, the lowest character a name may begin with.
217E
Jump back to VARLP1 at 2160H on Carry, the byte standing below A and so beginning no name, which reads the next byte of the line.
2180
CP 5BH FE 5B
Compare Register A with 5BH, one past the letter Z, the highest character a name may begin with.
2182
Jump back to VARLP1 at 2160H on NC, the byte standing above Z and so beginning no name, which reads the next byte of the line.
2184VARLP2
EX DE,HL EB
VARLP2 (2184H), which 21AFH also reaches: exchange Register Pair DE with Register Pair HL, which puts the place in LSTVAR$ into Register Pair HL and the place in the line into Register Pair DE.
2185
CP (HL) BE
Compare Register A with the byte Register Pair HL addresses, the character of the name being looked for against the character of the line, which gives Z when they are the same.
2186
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the place in the line back into Register Pair HL with the flags of that comparison untouched.
2187
Jump to BYVAR at 21BDH on NZ, the characters differing, which steps over the whole of the name in the line rather than trying the rest of it.
2189
INC DE 13
Increment Register Pair DE to the next character of the name being looked for.
218A
DEC B 05
Decrement Register B, one character of the name matched, which gives Z when the whole of it has.
218B
Jump to VAR3 at 21A9H on NZ, the name having more characters to match, which reads the next byte of the line.
218E
CP 28H FE 28
Compare Register A with 28H, an opening parenthesis, which is the last character of the name when an array was asked for and which VALID counts as part of a name.
2190
Jump to VAR5 at 2195H on Z, the name itself having ended with a parenthesis, in which case nothing that follows it in the line can make the name longer.
2192
LD A,C 79
Load Register A from Register C, the length of the name, which the comparison below weighs. From here on Register A is that length and no longer a character of the line.
2193
CP 0AH FE 0A
Compare Register A with 0AH, ten, the longest name BASIC keeps, which gives Z when the name fills the whole of it.
2195VAR5
VAR5 (2195H), which 2190H also reaches: call SHOW at 21E8H on Z, which for FIND writes the line's number and returns and for SEARCH shows the whole line and never comes back.
2198
Jump back to VARLP at 214EH on Z, the line having been named, which carries the search on at the line after it.
219A
INC HL 23
Increment Register Pair HL to the byte after the name in the line, which decides whether what was matched is the whole name there.
219B
LD B,A 47
Load Register B from Register A, which saves the length and not a character: 2192H put Register C into Register A, so the value kept here is the length of the name. B352: the source means to keep the character of the line here, and because it keeps the length instead the comparison at 21BEH can never find 28H when BYVAR is reached from 21A2H.
219C
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, the byte after the name in the line.
219D
DEC HL 2B
Decrement Register Pair HL back to the last character of the name, so that the walk carries on from where it stood.
219E
Call VALID at 229DH, which gives Z when that byte is one a name may hold, in which case the name in the line is longer than the one asked for.
21A1
LD A,B 78
Load Register A from Register B, which puts the length back into Register A, the source calling it the character although 2192H had already overwritten that.
21A2
Jump to BYVAR at 21BDH on Z, the name in the line being longer than the one asked for, which steps over the rest of it.
21A4
Call SHOW at 21E8H, the name in the line being exactly the one asked for, which for FIND writes its number and returns and for SEARCH shows the line and never comes back.
21A7
Jump back to VARLP at 214EH, the line having been named, which carries the search on at the line after it.
21A9VAR3
VAR3 (21A9H): call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A for the next character of the name.
21AC
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
21AD
Jump back to VARLP at 214EH on Z, the line having ended in the middle of the name, which goes on to the next line.
21AF
Jump back to VARLP2 at 2184H, which compares this byte with the next character of the name.
21B1BYSTR
BYSTR (21B1H), the walk through a string literal: call NXTCHAR at 5E93H, which brings the next byte of the literal back in Register A.
21B4
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
21B5
Jump back to VARLP at 214EH on Z, the line having ended inside an unclosed literal, which goes on to the next line.
21B7
CP 22H FE 22
Compare Register A with 22H, a quotation mark, which is the only thing that closes a literal.
21B9
Jump to VARLP3 at 215DH on Z, the literal having closed, which puts the comparison back at the first character of the name and reads on.
21BB
Jump back to BYSTR at 21B1H, the byte being part of the literal, which reads the next one.
21BDBYVAR
LD B,C 41
BYVAR (21BDH), which 2187H and 21A2H reach: load Register B from Register C, the length of the name, which puts the comparison back to its full count.
21BE
CP 28H FE 28
Compare Register A with 28H, an opening parenthesis, which would mean the name in the line is an array and its subscripts may hold the name being looked for. Reached from 21A2H, Register A holds a length of one to ten and this can never be Z.
21C0
Jump to VARLP3 at 215DH on Z, a parenthesis standing here, which puts the comparison back at the first character and reads the subscripts.
21C2BYV1
BYV1 (21C2H), the walk over the rest of a name: call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A.
21C5
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
21C6
Jump back to VARLP at 214EH on Z, the line having ended, which goes on to the next line of the program.
21C8
CP 28H FE 28
Compare Register A with 28H, an opening parenthesis, which opens the subscripts of an array and whose contents may hold the name.
21CA
Jump to VARLP3 at 215DH on Z, the subscripts having begun, which puts the comparison back at the first character and reads them.
21CC
Call VALID at 229DH, which gives Z while the byte still belongs to the name being stepped over and NZ once it does not.
21CF
Jump to VARLP3 at 215DH on NZ, the name in the line having ended, which puts the comparison back at the first character and carries on from here.
21D1
Jump back to BYV1 at 21C2H, the byte still belonging to the name, which reads the next one.
21D3DUMPLIN
DUMPLIN (21D3H), which the conditional call at 2168H reaches for a REM: call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A.
21D6
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
21D7
Jump back to DUMPLIN at 21D3H on NZ, the remark not having ended, which reads the next byte of it.
21D9
RET C9
Return to 216BH with the Zero Flag set, Register A holding 00H and Register Pair HL on the 00H that ends the line, which is what makes the jump there go round to the next line.

21DAH - GTPTR, SHOW and NUMFIND: the Line Named and a Line Number Looked For (21DAH-2264H)

GTPTR is the one routine all three searches share and SHOW is where SEARCH and FIND part company. GTPTR reads a line's link, keeps it in NXTPO 2207H so that SHOW can leave the walk standing one byte before the next line, and answers with the Zero Flag set when the link is 0000H and the program has ended. SHOW reads DTYPE 21E9H: 03H goes to SHOLIN 2211H, which never returns, making the line found the current line and handing a full stop to NOBRK@ 80F4H, the key handler of the enhancement package, which is what lists a line at command level; 04H goes to SHONUM 21EEH, which does return, writing the line's number with NUMDSP 3139H and a comma and a space in front of every number after the first, which is what FTIME 21F1H is for. So SEARCH stops at its first match and a bare S picks the walk up again, while FIND writes the whole list in one line and 2268H refuses to repeat it. NUMFIND is the third search, and it looks for a line number in two ways at once: the first comparison of every line is against the line's own number, so FIND of a number names that line as well as every line that refers to it, and then NUMLP2 2253H walks the line for the 0EH token and compares each referenced number. The number being looked for is kept on the stack and not in a cell, and the two EX (SP),HL of 2241H and 2247H swap it with the place in the line, which is how one pair serves both.

21DAGTPTR
INC HL 23
GTPTR (21DAH), which 20FBH, 214EH and 2233H call with Register Pair HL one byte below a line: increment Register Pair HL to the low byte of that line's link.
21DB
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, the low byte of the link, which is the address of the next line of the program.
21DC
LD (2207H),A 32 07 22LD (NXTPO),A
Store Register A into NXTPO at 2207H, the low byte of the operand of the LD HL instruction at 2206H, so that SHOW can put the walk back one byte below the next line.
21DF
PUSH AF F5
Push Register Pair AF, the low byte of the link, because the load below needs Register A and the Or at 21E6H wants that byte again.
21E0
INC HL 23
Increment Register Pair HL to the high byte of the link.
21E1
LD A,(HL) 7E
Load Register A with the byte Register Pair HL addresses, that high byte.
21E2
LD (2208H),A 32 08 22
Store Register A into the byte at 2208H, the high byte of that same operand, so that NXTPO at 2207H now holds the whole address of the next line.
21E5
POP AF F1
Pop Register Pair AF, the low byte of the link that 21DFH pushed.
21E6
OR (HL) B6
Or Register A with the byte Register Pair HL addresses, the high byte again, which sets the Zero Flag only when both bytes are 00H and so the program has ended.
21E7
RET C9
Return to the caller with the Zero Flag saying whether the program has ended and Register Pair HL on the high byte of this line's link, which is one below its number.
21E8SHOW
LD A,00H 3E 00
SHOW (21E8H), which 2127H, 2195H, 21A4H and 224EH call: load Register A with the byte DTYPE holds at 21E9H, 00H in the file and the command token, which 20C0H wrote into this instruction's own operand.
21EA
CP 03H FE 03
Compare Register A with 03H, the token for SEARCH, which shows the whole of the line it found.
21EC
Jump to SHOLIN at 2211H on Z, the command being SEARCH, which never comes back to the search that called it.
21EESHONUM
PUSH DE D5
SHONUM (21EEH), the answer for FIND: push Register Pair DE, which the three searches all need kept and which the text writer below destroys.
21EF
PUSH BC C5
Push Register Pair BC, which holds the token or the length the search is matching on and which the display below destroys.
21F0
LD A,00H 3E 00
Load Register A with the byte FTIME holds at 21F1H, 00H in the file, which 20C4H clears before the search and which says whether any number has been written yet.
21F2
OR A B7
Set the flags from Register A with OR A, which gives Z when no number has been written and so this is the first of them.
21F3
LD A,01H 3E 01
Load Register A with 01H, the value that says a number has now been written. A load changes no flag, so the test above is still in them for the jump below.
21F5
LD (21F1H),A 32 F1 21LD (FTIME),A
Store Register A into FTIME at 21F1H, which is the operand of the instruction at 21F0H, so that every number after this one gets a comma in front of it.
21F8
Jump to SHO1 at 2200H on Z, this being the first number of the list, which wants no separator in front of it.
21FA
LD HL,220EH 21 0E 22LD HL,COMSTR
Load Register Pair HL with 220EH, the address of COMSTR, the comma and the space that go between two numbers of the list.
21FD
Call the text writer at 46A5H, which makes a temporary string of those two characters and sends them to the display.
2200SHO1
LD HL,(83DCH) 2A DC 83LD HL,(LSTLIN$)
SHO1 (2200H), which 21F8H also reaches: load Register Pair HL from LSTLIN$ at 83DCH, the number of the line the search has just matched.
2203
Call NUMDSP at 3139H, which writes that number to the display as decimal digits with no sign and no trailing space.
2206
LD HL,0000H 21 00 00
Load Register Pair HL with the word NXTPO holds at 2207H, 0000H in the file and the address of the next line of the program, which GTPTR wrote into this instruction's own operand a byte at a time.
2209
DEC HL 2B
Decrement Register Pair HL to one byte below that line, which is where every one of the three searches wants the walk left.
220A
XOR A AF
Clear Register A with XOR A, making 00H, which sets the Zero Flag that VAR5 at 2198H and 21A2H read to mean that the line has been shown.
220B
POP BC C1
Pop Register Pair BC, the token or the length that 21EFH pushed.
220C
POP DE D1
Pop Register Pair DE, the pair that 21EEH pushed, with the Zero Flag the clear above set left standing, a pop changing no flag.
220D
RET C9
Return to the search with the Zero Flag set, Register Pair HL one byte below the next line of the program and the number written to the display.
220E-2210COMSTR
DEFM ", " / DEFB 00H 2C 20 00
COMSTR (220EH to 2210H), the separator FIND writes between two line numbers: a comma, a space and the 00H at 2210H that the text writer at 46A5H stops on. 21FAH is the one instruction that names it, and it is written in front of every number of the list but the first.
2211SHOLIN
LD DE,(83DCH) ED 5B DC 83LD DE,(LSTLIN$)
SHOLIN (2211H), the answer for SEARCH: load Register Pair DE from LSTLIN$ at 83DCH, the number of the line the search has matched.
2215
LD (7192H),DE ED 53 92 71LD (CURLIN),DE
Store Register Pair DE into CURLIN at 7192H, which makes that line the current one, because the key handler below lists the current line and reads the number from there.
2219
LD A,2EH 3E 2E
Load Register A with 2EH, a full stop, which is the key NOBRK@ 80F4H takes to mean list the current line.
221B
Jump to DOLINE at 2342H, which loads Register Pair HL with NOBRK@ 80F4H, puts the stack back from SAVSTK 2352H and jumps into it, so that the line is listed and BASIC goes back to command level.
221ENUMFIND
NUMFIND (221EH), which 20E4H reaches for a digit: call NUM2DE at 5F9AH, which reads the number out of the command line into Register Pair DE and gives NZ when anything follows it.
2221
Jump to EXIT at 234EH on NZ, something standing after the number. B354: this goes back to READY 5920H with no message of any kind where MOVE and COPY both give Illegal function call for the same fault, so a FIND or a SEARCH with anything after its number does nothing and says nothing.
2224
LD (83DEH),DE ED 53 DE 83LD (LSTNUM$),DE
Store Register Pair DE, the number being looked for, into LSTNUM$ at 83DEH, so that a bare S can repeat the search from the line it stopped at.
2228
LD HL,(6E9EH) 2A 9E 6ELD HL,(PGMBGN)
Load Register Pair HL from PGMBGN at 6E9EH, the address of the first line of the program, so that the search starts at the top.
222B
LD A,0EH 3E 0E
Load Register A with 0EH, the token the tokenizer leaves in front of a line number as it was typed, which is what a reference to a line looks like in the text.
222D
LD (83DBH),A 32 DB 83LD (LSTTYP$),A
Store Register A into LSTTYP$ at 83DBH, which doubles as the kind of the last search and which 2284H compares with 0EH to know it was a number.
2230NUMREP
DEC HL 2B
NUMREP (2230H), which AGAIN jumps to at 2286H with Register Pair HL on the line after the last match: decrement Register Pair HL by one, which the increment inside GTPTR puts back.
2231
LD C,A 4F
Load Register C from Register A, the token 0EH, which the walk through each line compares every byte against.
2232
PUSH DE D5
Push Register Pair DE, the number being looked for, which is kept on the stack for the whole of the search and is never popped: EXIT 234EH puts the Stack Pointer back from SAVSTK 2352H.
2233NUMLP
NUMLP (2233H), the top of the search, one turn to a line: call GTPTR at 21DAH, which saves this line's link in NXTPO at 2207H and gives Z when the link is 0000H.
2236
Jump to EXIT at 234EH on Z, the program having been walked to its end, which goes back to READY 5920H.
2239
INC HL 23
Increment Register Pair HL to the low byte of this line's own number, Register Pair HL having been left on the high byte of its link.
223A
LD E,(HL) 5E
Load Register E with the byte Register Pair HL addresses, that low byte.
223B
INC HL 23
Increment Register Pair HL to the high byte of the number.
223C
LD D,(HL) 56
Load Register D with the byte Register Pair HL addresses, so that Register Pair DE holds the number of the line being searched.
223D
LD (83DCH),DE ED 53 DC 83LD (LSTLIN$),DE
Store Register Pair DE into LSTLIN$ at 83DCH, so that SHOW has the number to write and a bare S can start again from this line. The comparison below is reached with Register Pair DE holding it, which is why a line is named by its own number as well as by a reference to one.
2241NUMLP1
EX (SP),HL E3
NUMLP1 (2241H), which 2263H also reaches: exchange Register Pair HL with the word the Stack Pointer addresses, which brings the number being looked for into Register Pair HL and leaves the place in the line on the stack.
2242
PUSH HL E5
Push Register Pair HL, that number, because the subtraction below destroys it and the next turn of the search needs it.
2243
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
2244
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL, the number in hand from the number being looked for, which gives Z when the two are the same.
2246
POP HL E1
Pop Register Pair HL, the number being looked for, with the flags of that subtraction left standing.
2247
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer addresses, which puts that number back on the stack and brings the place in the line back into Register Pair HL.
2248
LD DE,(83DCH) ED 5B DC 83LD DE,(LSTLIN$)
Load Register Pair DE from LSTLIN$ at 83DCH, the number of the line being searched, so that Register Pair DE means the same thing at both entries to this comparison.
224C
Jump to NUMLP2 at 2253H on NZ, the two numbers differing, which walks the line looking for a reference to compare instead.
224E
Call SHOW at 21E8H, the numbers being the same, which for FIND writes this line's number and returns and for SEARCH shows the line and never comes back.
2251
Jump back to NUMLP at 2233H, SHOW having left Register Pair HL one byte below the next line, which carries the search on there.
2253NUMLP2
NUMLP2 (2253H), the walk through one line: call NXTCHAR at 5E93H, which brings the next byte of the line back in Register A.
2256
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H that ends the line.
2257
Jump back to NUMLP at 2233H on Z, this line holding no reference to the number, which goes on to the next line of the program.
2259
CP C B9
Compare Register A with Register C, the 0EH token, which is the only thing a reference to a line number begins with.
225A
Jump back to NUMLP2 at 2253H on NZ, the byte being anything else, which reads the next byte of the line.
225C
Call NUM2DE at 5F9AH, which reads the referenced number out of the two bytes after the token into Register Pair DE.
225F
LD HL,(7145H) 2A 45 71LD HL,(IPOS)
Load Register Pair HL from IPOS at 7145H, the place in the line that the unpacking of the reference left, which stands one byte past the three it occupies.
2262
DEC HL 2B
Decrement Register Pair HL by one, so that the increment inside NXTCHAR puts the walk back where it stood.
2263
Jump back to NUMLP1 at 2241H, which compares the referenced number with the one being looked for.

2265H - AGAIN and VALID: the Search Repeated and a Character of a Name (2265H-22C4H)

AGAIN is what makes a bare S useful, and the five cells of the enhancement package's own area are the whole of how it works. LSTTYP$ 83DBH says what kind of search the last one was and the three kinds are told apart by its value: 0EH is a line number, anything from 80H up is a keyword token, and anything below that is the length of a variable name, which is why the collector at 212CH stores the length there and not a kind of its own. LSTLIN$ 83DCH says which line the last search stopped at, and FIND 5AB4H is called on it so that the walk can be picked up at the line after, which is why a SEARCH shows the matches one at a time and why 227CH gives Illegal function call when that line has since been deleted. A bare F is refused outright at 2268H: FIND writes every match in one go and there is nothing left to carry on from. VALID is the test the collector and the three places that step over a name all use, and it counts an opening parenthesis as part of a name, which is why a search for a subscripted array can be typed with the parenthesis and why 218EH has a case for a name that ends in one.

2265AGAIN
LD A,(21E9H) 3A E9 21LD A,(DTYPE)
AGAIN (2265H), which 20CDH reaches when nothing was typed after the command: load Register A with the byte DTYPE holds at 21E9H, the command token 03H or 04H.
2268
CP 04H FE 04
Compare Register A with 04H, the token for FIND, which writes every line it matches in one list and leaves nothing to be carried on.
226A
Jump to EXIT at 234EH on Z, a bare F having been typed, which goes back to READY 5920H without a message: the source says a find cannot be done again.
226D
LD A,(83DBH) 3A DB 83LD A,(LSTTYP$)
Load Register A with the byte at LSTTYP$ 83DBH, the kind of the last search, which the enhancement package clears to 00H when BASIC starts.
2270
OR A B7
Set the flags from Register A with OR A, which gives Z when LSTTYP$ at 83DBH holds 00H and so no search has been made in this session.
2271
Jump to BADLIN at 2346H on Z, there having been no earlier search to repeat, which gives error 5, Illegal function call.
2274
PUSH AF F5
Push Register Pair AF, the kind of the last search, because FIND below destroys Register A and the three way test needs it back.
2275
LD DE,(83DCH) ED 5B DC 83LD DE,(LSTLIN$)
Load Register Pair DE from LSTLIN$ at 83DCH, the number of the line the last search stopped at.
2279
Call FIND at 5AB4H, which looks for that line and comes back with Register Pair HL addressing the line above it, which is where the search is to be picked up.
227C
Jump to BADLIN at 2346H on NC, that line no longer standing in the program, which is what happens when it has been deleted or renumbered between the two commands.
227F
POP AF F1
Pop Register Pair AF, the kind of the last search that 2274H pushed.
2280
LD DE,(83DEH) ED 5B DE 83LD DE,(LSTNUM$)
Load Register Pair DE from LSTNUM$ at 83DEH, the number the last search looked for, which only a number search reads.
2284
CP 0EH FE 0E
Compare Register A with 0EH, the value LSTTYP$ at 83DBH carries for a search for a line number.
2286
Jump to NUMREP at 2230H on Z, the last search having been for a line number, with Register Pair DE already holding it and Register Pair HL on the line to carry on from.
2288
CP 80H FE 80
Compare Register A with 80H, the lowest keyword token, which separates a keyword search from a variable search: LSTTYP$ at 83DBH holds a length of one to ten for a variable.
228A
Jump to AGN1 at 2294H on Carry, the value standing below 80H and so being the length of a variable name.
228C
LD C,A 4F
Load Register C from Register A, the keyword token, which the search loop compares every byte of the program against.
228D
LD A,(83E0H) 3A E0 83LD A,(LSTKEY$)
Load Register A with the byte at LSTKEY$ 83E0H, the second half of a two byte token, which 20F4H stored and which is FFH when the token has only one byte.
2290
LD B,A 47
Load Register B from Register A, that second half, which is what KEYLP1 compares the byte after an FFH prefix against.
2291
Jump to KEYREP at 20FAH, which picks the keyword search up at the line after the one the last one stopped at.
2294AGN1
LD B,A 47
AGN1 (2294H): load Register B from Register A, the length of the name, which the match counts down one character at a time.
2295
LD C,A 4F
Load Register C from Register A, the length again, which is kept for the whole search so that every line can set Register B back from it.
2296
LD DE,83E1H 11 E1 83LD DE,LSTVAR$
Load Register Pair DE with 83E1H, LSTVAR$, the name the last search collected, which is still there with its 00H after it.
2299
PUSH DE D5
Push Register Pair DE, that address, which nothing ever pops. B355: VARREP 214DH and the loop below it keep no word on the stack, so the word stays there until EXIT 234EH puts the Stack Pointer back from SAVSTK 2352H; the push is the one NUMREP makes at 2232H and has no part to play here.
229A
Jump to VARREP at 214DH, which picks the variable search up at the line after the one the last one stopped at.
229DVALID
CP 2EH FE 2E
VALID (229DH), which 2133H, 219EH and 21CCH call, answering Z when the character in Register A may stand in a variable name: compare Register A with 2EH, a full stop, which BASIC allows inside a name.
229F
RET Z C8
Return on Z, the character being a full stop and so part of a name.
22A0
CP 41H FE 41
Compare Register A with 41H, the letter A, the lowest letter of the alphabet.
22A2
Jump to VAL1 at 22A8H on Carry, the character standing below A, which weighs it as a digit or a special character instead.
22A4
CP 5BH FE 5B
Compare Register A with 5BH, one past the letter Z, the highest letter of the alphabet.
22A6
Jump to VALZ at 22B4H on Carry, the character being a letter from A to Z, which is the commonest answer of all and the one that needs the Zero Flag set for it.
22A8VAL1
CP 30H FE 30
VAL1 (22A8H): compare Register A with 30H, the digit zero, the lowest digit.
22AA
Jump to SPCL at 22B0H on Carry, the character standing below the digits, which leaves only the five special characters to try.
22AC
CP 3AH FE 3A
Compare Register A with 3AH, one past the digit nine, the highest digit.
22AE
Jump to VALZ at 22B4H on Carry, the character being a digit, which may stand in a name after its first character.
22B0SPCL
SPCL (22B0H): call CKSPCL at 22B6H, which answers Z for each of the four type declaration characters and for an opening parenthesis.
22B3
RET C9
Return to the caller with the answer CKSPCL gave, which a JP 22B6H would have done in the same three bytes without a return address being used at all.
22B4VALZ
CP A BF
VALZ (22B4H), which 22A6H and 22AEH reach: compare Register A with itself, which always sets the Zero Flag and changes nothing, the shortest way of saying that the character belongs to a name.
22B5
RET C9
Return to the caller with the Zero Flag set, the character being a letter or a digit.
22B6CKSPCL
CP 21H FE 21
CKSPCL (22B6H), which 22B0H calls: compare Register A with 21H, an exclamation mark, which marks a name as single precision.
22B8
RET Z C8
Return on Z, the character being the single precision mark and so the last character of a name.
22B9
CP 23H FE 23
Compare Register A with 23H, a hash, which marks a name as double precision.
22BB
RET Z C8
Return on Z, the character being the double precision mark.
22BC
CP 24H FE 24
Compare Register A with 24H, a dollar sign, which marks a name as a string.
22BE
RET Z C8
Return on Z, the character being the string mark.
22BF
CP 25H FE 25
Compare Register A with 25H, a per cent sign, which marks a name as an integer.
22C1
RET Z C8
Return on Z, the character being the integer mark.
22C2
CP 28H FE 28
Compare Register A with 28H, an opening parenthesis, which opens the subscripts of an array and which this routine counts as part of the name.
22C4
RET C9
Return to the caller with the Zero Flag of that last comparison, which is the whole answer when the character is none of the four marks.

22C5H - COPY: One Line Copied to a New Number (22C5H-233FH)

COPY does not copy anything itself: it builds the text of the new line in INBUF 7039H and hands it to BASIC's own line entry at 5993H as though it had been typed. That is why the new line is entered exactly as a typed line would be, with the same checks and the same errors, and why 59AFH's test of FILEX 6E98H counts COPY as the keyboard. The line asked for is read with FIND 5AB4H, its tokenized text is moved into LBUF 6EFAH, UNTOKE 7A0DH turns it back into characters at INBUF, room for a five character line number is made in front of it with an LDDR, the new number is written into that room by @HEXDEC, and the whole line is shown on the display before it is entered. Two off by one steps cancel each other exactly. 2304H gives UNTOKE a pointer one byte below the text it copied, so the first character UNTOKE writes is the colon that 840AH of the enhancement package keeps at 6EF9H; and the length 2314H works out is one short of what UNTOKE wrote, so the LDDR at 2319H copies everything except that colon. The field @HEXDEC writes is five characters right justified with leading spaces and it writes no terminator, which is why the room made is five and the clearing loop blanks six: the sixth is the space between the number and the text. COPY ends by jumping out of the overlay for good, so the three ways it can fail all go to ILLEG 2340H.

22C5COPY
LD HL,7039H 21 39 70LD HL,INBUF
COPY (22C5H), which 1E06H reaches: load Register Pair HL with 7039H, INBUF, where the command line stands as it was typed, so that the two numbers are read as characters and not as tokens.
22C8
Call NXTCHAR at 5E93H, which steps past the C of the command and brings the first character of the first number back in Register A.
22CB
Jump to ILLEG at 2340H on Z, the line ending after the command, which gives error 5, Illegal function call.
22CD
Call NUM2DE at 5F9AH, which reads the number of the line to copy into Register Pair DE and gives Z when the line has ended after it.
22D0
Jump to ILLEG at 2340H on Z, the line having ended after the first number, where COPY wants a second.
22D2
LD A,D 7A
Load Register A from Register D, the high byte of the number read.
22D3
OR E B3
Or Register A with Register E, its low byte, which gives Z when the whole number is 0000H.
22D4
Jump to ILLEG at 2340H on Z, the number being zero, which no line of a program may carry.
22D6
PUSH HL E5
Push Register Pair HL, the place in the command line, which FIND below walks the program with.
22D7
Call FIND at 5AB4H, which looks for the line to copy and comes back with the Carry Flag set and Register Pair BC addressing it when there is one, and Register Pair HL addressing the line above it.
22DA
Jump to ILLEG at 2340H on NC, no line of that number standing in the program, so that there is nothing to copy.
22DC
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
22DD
INC BC 03
Increment Register Pair BC past the low byte of the line's link, the first of the two steps to its number.
22DE
INC BC 03
Increment Register Pair BC a second time, so that it addresses the low byte of the line's own number.
22DF
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL, that address from the start of the line above, which leaves the length of the number and the text and the 00H that ends it.
22E1
DEC HL 2B
Decrement Register Pair HL by one, the first of the two steps that take the two bytes of the line number off that length.
22E2
DEC HL 2B
Decrement Register Pair HL a second time, so that Register Pair HL holds the length of the tokenized text and the 00H after it, which is what has to be copied.
22E3
EX (SP),HL E3
Exchange Register Pair HL with the word the Stack Pointer addresses, which puts that length on the stack and brings the place in the command line back into Register Pair HL.
22E4
Call NXTCHAR at 5E93H, which steps past the comma and brings the first character of the second number back in Register A.
22E7
Jump to ILLEG at 2340H on Z, the line ending after the first number and its comma, where the new number has to stand.
22E9
Call NUM2DE at 5F9AH, which reads the new number into Register Pair DE and gives NZ when anything follows it.
22EC
Jump to ILLEG at 2340H on NZ, something standing after the second number: COPY takes two and no more.
22EE
LD A,D 7A
Load Register A from Register D, the high byte of the new number.
22EF
OR E B3
Or Register A with Register E, its low byte, which gives Z when the whole number is 0000H.
22F0
Jump to ILLEG at 2340H on Z, the new number being zero, which no line of a program may carry.
22F2
PUSH BC C5
Push Register Pair BC, the address of the line being copied, which FIND below destroys.
22F3
Call FIND at 5AB4H, which looks for a line of the new number and comes back with the Carry Flag set when one already exists.
22F6
POP HL E1
Pop Register Pair HL, the address of the line being copied that 22F2H pushed, FIND having left the new line's place in Register Pair BC where nothing reads it.
22F7
Jump to ILLEG at 2340H on Carry, a line of the new number already standing in the program, which COPY will not write over.
22F9
POP BC C1
Pop Register Pair BC, the length that 22E3H put on the stack, which is the count of bytes to be copied.
22FA
PUSH DE D5
Push Register Pair DE, the new line number, which @HEXDEC at 2329H writes into the room made for it.
22FB
INC HL 23
Increment Register Pair HL past the low byte of the line's link, the first of the four steps to its text.
22FC
INC HL 23
Increment Register Pair HL a second time: with the two increments 22DDH made to the other pair, Register Pair HL now addresses the low byte of the line's number, and the two taken off the length at 22E1H are what skip it.
22FD
LD DE,6EFAH 11 FA 6E
Load Register Pair DE with 6EFAH, LBUF+1, the byte above the colon the enhancement package keeps at 6EF9H, which is where the tokenized text is put.
2300
PUSH DE D5
Push Register Pair DE, that address, which MAKLIN below pops to give UNTOKE its pointer.
2301
LDIR ED B0
Copy the text with LDIR, which moves Register Pair BC bytes from the address in Register Pair HL to the address in Register Pair DE, so that the tokenized line and its 00H now stand at 6EFAH.
2303MAKLIN
POP HL E1
MAKLIN (2303H): pop Register Pair HL, the address 2300H pushed, which is the first byte of the copied text.
2304
DEC HL 2B
Decrement Register Pair HL to 6EF9H, LBUF itself, which holds the colon 840AH of the enhancement package put there: UNTOKE reads the byte it is given before it steps, so that colon is the first character it writes and the LDDR below is what drops it again.
2305
Call UNTOKE at 7A0DH, which turns the tokenized line back into characters at INBUF 7039H and comes back with Register Pair BC addressing the 00H it wrote at the end of them.
2308
PUSH BC C5
Push Register Pair BC, that end address, which the LDDR below reads as its source.
2309
LD HL,0005H 21 05 00
Load Register Pair HL with 0005H, five, the width of the field @HEXDEC writes and so the room the line number needs in front of the text.
230C
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, the end of the characters plus five, which is where the end of them has to be moved to.
230D
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts that destination into Register Pair DE for the LDDR.
230E
LD H,B 60
Load Register H from Register B, the high byte of the end of the characters.
230F
LD L,C 69
Load Register L from Register C, its low byte, so that Register Pair HL addresses that end again.
2310
LD BC,7039H 01 39 70LD BC,INBUF
Load Register Pair BC with 7039H, INBUF, the first byte UNTOKE wrote, which the subtraction below measures from.
2313
OR A B7
Set the flags from Register A with OR A, which clears the Carry Flag for the subtraction below.
2314
SBC HL,BC ED 42
Subtract Register Pair BC from Register Pair HL, the start of the buffer from the end of the characters, which is one short of what UNTOKE wrote and so exactly the count that leaves the colon at 7039H behind.
2316
LD B,H 44
Load Register B from Register H, the high byte of that count.
2317
LD C,L 4D
Load Register C from Register L, its low byte, so that Register Pair BC is the count the LDDR wants.
2318
POP HL E1
Pop Register Pair HL, the end of the characters that 2308H pushed, which is the highest byte the LDDR reads.
2319
LDDR ED B8
Move the characters up with LDDR, which copies Register Pair BC bytes from the address in Register Pair HL down to the address in Register Pair DE, so that the text and its 00H now begin five bytes higher and the colon is left behind.
231B
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the lowest byte written into Register Pair HL for the clearing loop below.
231C
LD B,06H 06 06
Load Register B with 06H, six, the five bytes of the number field and the one space that has to stand between the number and the text.
231ECLRLP
LD (HL),20H 36 20
CLRLP (231EH), the clearing loop: store 20H, a space, into the byte Register Pair HL addresses.
2320
DEC HL 2B
Decrement Register Pair HL to the byte below it, the loop running downward from 703EH to 7039H.
2321
Decrement Register B and jump back to CLRLP at 231EH while it is not zero, which blanks the six bytes and leaves Register Pair HL on 7038H.
2323
POP DE D1
Pop Register Pair DE, the new line number that 22FAH pushed.
2324
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL, which puts the number into Register Pair HL for @HEXDEC and 7038H into Register Pair DE.
2325
INC DE 13
Increment Register Pair DE to 7039H, INBUF itself, which is where the number's field begins.
2326
PUSH DE D5
Push Register Pair DE, that address, which 232FH pops as the start of the line for the display.
2327
LD A,61H 3E 61
Load Register A with 61H, 97, the number of @HEXDEC, the supervisor call that writes a value as decimal digits in a field of five.
2329
RST 28H EF
Issue RST 28H, calling @HEXDEC at 06F6H, which writes the number in Register Pair HL right justified with leading spaces into the five bytes at 7039H and leaves Register Pair DE on 703EH, the space the clearing loop put there.
232AENDL
INC DE 13
ENDL (232AH), the scan for the end of the line: increment Register Pair DE, which on the first turn steps from the separator space to the first character of the text.
232B
LD A,(DE) 1A
Load Register A with the byte Register Pair DE addresses, one character of the line.
232C
OR A B7
Set the flags from Register A with OR A, which gives Z for the 00H the LDDR moved to the end of the text.
232D
Jump back to ENDL at 232AH on NZ, the line not having ended, which reads the next character.
232F
POP HL E1
Pop Register Pair HL, 7039H, which 2326H pushed, the first byte of the line that is about to be shown.
2330
PUSH DE D5
Push Register Pair DE, the address of the 00H that ends the line, which has to be put back after the display.
2331
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, which is what @DSPLY stops on where the line ends in a 00H.
2333
LD (DE),A 12
Store Register A into the byte Register Pair DE addresses, which turns that 00H into a carriage return for the display alone.
2334
LD A,0AH 3E 0A
Load Register A with 0AH, ten, the number of @DSPLY, the supervisor call that writes the text at Register Pair HL to the display.
2336
RST 28H EF
Issue RST 28H, calling @DSPLY at 052DH, which shows the whole of the new line, its number and its text, so that the user sees what COPY has made before it is entered.
2337
POP DE D1
Pop Register Pair DE, the address of the line's last byte that 2330H pushed.
2338
XOR A AF
Clear Register A with XOR A, making 00H, the byte the line entry wants at the end of a line.
2339
LD (DE),A 12
Store Register A into the byte Register Pair DE addresses, which puts the 00H back over the carriage return.
233A
LD HL,7038H 21 38 70
Load Register Pair HL with 7038H, the byte below INBUF, which is where the line entry expects the text pointer to stand, the colon at 6EF9H no longer being in the way.
233D
Jump to 5993H, the line entered into the program, which tokenizes the line in INBUF and puts it in the program exactly as it would a line typed at the Ready prompt. Nothing comes back: that routine ends at command level.

2340H - The Four Exits and the Storage (2340H-235FH)

No command of this overlay ever returns to its caller, and these twelve bytes are why. Each of the four exits loads Register Pair HL with an address in BASIC/CMD, falls into EXIT1 2351H, which puts the Stack Pointer back from SAVSTK 2352H as the first instruction of the overlay left it, and jumps through Register Pair HL. The three 0DDH bytes at 2345H, 2349H and 234DH are what makes the chain work: entered at one of the labels, the LD HL takes the address wanted and the 0DDH below it turns the next LD HL,nn into an LD IX,nn, so Register Pair HL is carried through the exits beneath it untouched. Executed from 2342H the real instruction sequence is LD HL,80F4H, LD IX,5F95H, LD IX,425CH, LD IX,5920H, which is one address taken and three thrown into a register nothing reads. The four addresses are NOBRK@ 80F4H, the key handler of the enhancement package, which lists a line; FUNCERR 5F95H, error 5, Illegal function call; OMERR 425CH, error 7, Out of memory; and READY 5920H, which simply prints the prompt. The eleven bytes of storage above them are the whole of what BASIC/OV2 keeps, and they stand at 2355H to 235FH inside what B296 writes over: MORC reads six whole sectors for a file of 1376 bytes, so 2360H to 23FFH takes 160 bytes of whatever followed the file on the diskette, and that region is also LOWBUF$ 2300H, the resident system's low memory disk buffer, whose top 160 bytes this overlay does not occupy.

2340ILLEG
ILLEG (2340H), which the eight error jumps of COPY all reach: jump to BADLIN at 2346H, two bytes away. Every one of those jumps could have named 2346H itself, 22CBH being the furthest at 79H bytes and a relative jump reaching 7FH.
2342DOLINE
LD HL,80F4H 21 F4 80LD HL,NOBRK@
DOLINE (2342H), which SHOLIN jumps to at 221BH with Register A holding a full stop: load Register Pair HL with 80F4H, NOBRK@, the key handler of the enhancement package, which lists the line CURLIN 7192H names.
2345
DEFB 0DDH DD
The first of the three prefix bytes: entered at DOLINE above, this byte turns the LD HL at 2346H into LD IX,5F95H, so that Register Pair HL keeps 80F4H through BADLIN and the two exits under it. Nothing jumps to 2345H and nothing reads Index Register IX afterwards.
2346BADLIN
LD HL,5F95H 21 95 5FLD HL,FUNCERR
BADLIN (2346H), which twenty jumps of this overlay reach: load Register Pair HL with 5F95H, FUNCERR, which gives error 5, Illegal function call, and is the only error MOVE, COPY, FIND and SEARCH report between them apart from Out of memory.
2349
DEFB 0DDH DD
The second prefix byte: it turns the LD HL at 234AH into LD IX,425CH, so that Register Pair HL keeps whatever the exit above put there. Nothing jumps to 2349H.
234ANOMEM
LD HL,425CH 21 5C 42LD HL,OMERR
NOMEM (234AH), which 1EF2H alone reaches: load Register Pair HL with 425CH, OMERR, which gives error 7, Out of memory, when the block MOVE has to shift is longer than the free memory between LOPT 71A3H and HIPT 7178H.
234D
DEFB 0DDH DD
The third prefix byte: it turns the LD HL at 234EH into LD IX,5920H, so that Register Pair HL keeps 425CH. Nothing jumps to 234DH.
234EEXIT
LD HL,5920H 21 20 59LD HL,READY
EXIT (234EH), which 1FD7H, 20FEH, 2151H, 221EH, 2233H, 2236H and 226AH reach: load Register Pair HL with 5920H, READY, which prints the prompt and goes to command level with no message of any kind.
2351EXIT1
LD SP,0000H 31 00 00
EXIT1 (2351H), which all four exits fall into: load the Stack Pointer with the word SAVSTK holds at 2352H, 0000H in the file, which the first instruction of the overlay stored there as BASIC's own CLEAR left it, so that every push this overlay has left on the stack goes with it.
2354
JP (HL) E9
Jump through Register Pair HL to the address the exit taken put there, which is in BASIC/CMD in every case and never comes back.
2355DOPASS1
DEFB 00H 00
DOPASS1 (2355H), the flag that says which pass of the line reference walk is running, 00H in the file: 1F1DH stores a value that is not 00H for the first pass, 20BAH and 1F1DH store 00H for the second, and 1F36H and 1FD3H read it. The 00H the file carries is the second pass, which is why 1F1BH has to set a bit before the first.
2356-2357NUM1
DEFW 0000H 00 00
NUM1 (2356H), the first line number of the block MOVE is to shift, 0000H in the file: 1E11H writes it and 1E76H and RANGE at 1FC1H read it. It is the lower end of the range RANGE tests a reference against, and the end that counts as inside.
2358-2359NUM2
DEFW 0000H 00 00
NUM2 (2358H), the last line number of the block, 0000H in the file: 1E1DH writes it and RANGE at 1FBAH reads it as the first of its two comparisons. It too counts as inside the block.
235A-235BLTM
DEFW 0000H 00 00
LTM (235AH), the count of lines in the block, 0000H in the file: 1ECEH is the only instruction in the whole of BASIC/OV2 that names 235AH, and nothing ever reads what it leaves there. The count the walk at 1EAFH works out is used in Register Pair BC at 1EC9H and stored here for nothing.
235C-235DTOMOVE
DEFW 0000H 00 00
TOMOVE (235CH), the length of the block in bytes, 0000H in the file: 1EEBH writes it and 1EF0H, 1F11H, 1FE1H, 2077H, 2080H and 2096H read it. It is what the memory test weighs against the free memory, what both block copies count, and the amount every line of the shuffled region moves by.
235E-235FNEWLIN
DEFW 0000H 00 00
NEWLIN (235EH), the address in the program text the block is to be moved to, 0000H in the file: 1E8BH writes it and 1EF8H, 1FF7H, 200EH, 2069H and 2087H read it. It is the link of the line NUM3 1E9CH names, so the block goes immediately after that line.