LDOS 5.3.1 for the Model III - BASIC/OV2 Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 BASIC/OV2 Disassembly - CMD"X", the Cross Reference of a BASIC Program (Model III)

BASIC/OV2 lists the variables of the BASIC program in memory and the line numbers it refers to, each with the lines where it is met: CMD"X [devspec or filespec] [-V or -L or =entry] [<title>]". BASIC/CMD runs it with @RUN when CMD is given an X and a space (its 547CH); the file loads over BASIC/CMD at 5200H, and when it is done it runs BASIC/CMD again with an asterisk, back to the program in memory with its variables (568DH).

The file is a load module of 1647 bytes: a copyright record, the code and data 5200H-581BH in seven load blocks, and the transfer address 5200H.

The Parameters

ParameterCellMeaning in the code
devspec, filespec5847H, 5793HFirst, when it starts with an asterisk or a letter: the device or file for the listing, opened with @INIT; a file gets /TXT when it has no extension (5200H). Without it the listing goes to the video.
-V, -L5843HA minus sign and a letter: V lists only the variables, L only the line numbers; any other letter lists both.
=entry5824H, 5844HAn equals sign and a variable name or a line number: only that entry is listed.
<title>5722HThe text between the angle brackets, at most 58 characters, at the top of each page. The whole command line is folded to upper case first, so the title is in capitals.

Only the first of a minus sign and an equals sign is read (5570H).

How It Works

The scanner (538AH) takes the entries of a line one at a time as seven characters: a variable is its first two characters, its type character and a parenthesis for an array (AB$( for ABC$(1)); a line number after THEN, ELSE, RESUME, GOTO, GOSUB, RUN or ERL is five digits with zeros in front, without its own leading zeros, so 0 is never taken (5414H). Strings in quotes, remarks, DATA items, constants and the numbers of other statements are passed over. Each pass over the whole program (5273H) finds the lowest entry above the last one listed and the lines that have it, kept as a list above the end of the arrays (5515H); the entry is then listed (52EFH), so the line numbers come first, in order, then the variables in alphabetical order.

Each entry has a rule line above it and a reference column of a colon, its first five characters and a colon, followed by its lines, eight to an output line. A new page (a form feed, the title and the heading) comes after 50 lines before an entry or after 55 lines within one (54AEH). BREAK ends the listing and SHIFT @ pauses it after any byte sent (55F6H).

About This Page

The Model III file is the Model I file of the same release with the same code at the same addresses; its 12 different bytes are operands that name the Model III resident area: @FEXT 444BH (5234H; Model I 4473H), @KITSK 4285H (5621H; Model I 4300H), KFLAG$ 429FH (5661H, 5674H, 5679H; Model I 4423H), CFCB$ 4485H (5693H; Model I 4480H) and INBUF$ 4225H (569DH; Model I 4318H).

\n\t\t\t\t\t\t\t\t

Every byte of the file is shown at its address. The ROM routines named are those of the Model III ROM, version 3.1, at the same addresses as in the Level II ROM of the Model I, version 1.3; jumps into the ROM link to its page. Found in the code: an error writing the listing file goes to 5656H, whose CALL 5648H unwinds the stack wrongly and returns to the address saved from Index Register IY, a place in the program text, so @ERROR is not reached; the list of line numbers may grow up to the bottom of string space (40A0H), and the stack this file runs on lies below it (5515H); an error on a device is not reported; the character after the < of the title is copied before it is tested (55CCH); the CALL 56D8H at 5347H moves Index Register IX for nothing; the routine at 55EEH is never called, and the L at 56A5H is not read.

Memory Map

Load Blocks

The file starts with a copyright record (type 1FH), then 7 load blocks with 1564 bytes, 5200H-581BH, and the transfer address 5200H.

AddressContents
5200H-52FFH256 bytes
5300H-53FFH256 bytes
5400H-54FFH256 bytes
5500H-55FFH256 bytes
5600H-56FFH256 bytes
5700H-57FFH256 bytes
5800H-581BH28 bytes

The Parts of the File

AddressContents
5200H-5372HThe start, the output, the options, the passes and the listing of an entry.
5374H-5571HThe routines of the entries: compare, copy, fill, the scanner, the classes of the bytes, the fields, the list of line numbers.
5570H-56A4HThe options, sending a text, the keyboard, BREAK and the way back to BASIC.
56A5H-5720HThe name BASIC/CMD, upper case, a line number as text, the next line, the tokens, the DOS errors, closing the file.
5721H-581BHThe title buffer, the heading, the pieces of the rule, the messages and the banner.
581CH-5866HNot in the file: the entries, the field, the cells and the control block.
5900H-59FFHNot in the file: the buffer of the listing file.
(40FDH) + 5 upNot in the file: the list of line numbers, up to the address in 40A0H.

Sections of the Disassembly

AddressContents
5200HThe Start: the Banner and the Output
5246HThe Options, the Title and the Heading
5273HOne Pass: the Next Entry
52EFHListing One Entry
534DHThe End of the Listing
5360HComparing Two Entries
5374HCopying an Entry
537BHAn Empty Entry
538AHThe Scanner: the Next Entry of a Line
5406HA String in Quotes
5414HA Line Number after a Token
5472HClassing a Byte
54AEHEnding an Output Line, a New Page
54F6HA Field of the Output Line
5515HThe List of Line Numbers
5555HThe Next Line Number of the List
5570HThe Options
55E4HSending a Text
564DHA File or a Device
5656HAn Error Writing the File
5661HThe Keyboard Flags
567EHBREAK
568DHBack to BASIC
56B0HUpper Case
56C8HA Line Number as Text
56D8HThe Next Line by Its Text
56F2HTokens Followed by Line Numbers
5708HA DOS Error
5710HClosing the Listing File
5721HThe Texts and the Work Cells

Memory BASIC/OV2 Uses

AddressContents
001BH, 002BH, 0049HThe ROM: $PUT (a byte to the device at Register Pair DE), the scan of the keyboard, the wait for a key.
0A9AH, 0FD9H, 1034HThe ROM: a number to 4121H-4122H as an integer, the number turned into text, the sign of the text (4130H).
401DH, 4025HDODCB$ and PRDCB$, the control blocks of the video and the printer.
40A0H-40A1HThe bottom of string space: the limit of the list of line numbers.
40A4H-40A5HThe start of the program text. Each line: +00H-+01H the link, +02H-+03H the number, +04H the text, 00H; two 00H bytes end the program.
40FDH-40FEHThe end of the arrays: the list of line numbers starts 5 bytes above it.
4121H-4122H, 40AFH, 40D8H, 4130HThe ROM's cells used by 56C8H: the integer, its type, the format, the text of the number.
4285H@KITSK, the hook of the keyboard task, called after each byte sent.
4225HINBUF$: the text after X (from BASIC/CMD); 2AH is written at 4225H for BASIC/CMD.
4409H, 441CH, 4420H, 4428H, 4433H, 4467H, 444BH@ERROR, @FSPEC, @INIT, @CLOSE, @RUN, @DSPLY, @FEXT.
429FHKFLAG$: bit 0 BREAK, bit 1 SHIFT @, bit 2 ENTER.
4485HCFCB$: the control block with BASIC/CMD for @RUN.

Variables

The data of the file and the cells and the buffers above it, then the operand BASIC/OV2 changes while it runs.

Data in the File and the Memory Above It

Address
Size
Contents
56A5H
1 byte
DEFM "L"
56A5H: 4CH, the letter L before the name; 5690H copies from 56A6H, so no code reads it.
56A6H-56AEH
9 bytes
DEFM "BASIC/CMD"
56A6H-56AEH: the name of the file 568DH runs, copied to CFCB$ (4485H).
56AFH
1 byte
DEFB 03H
56AFH: 03H, the end of the name in the control block.
5721H
1 byte
DEFB 0CH
5721H: 0CH, a form feed, sent before the title at each new page (54C3H).
5722H
1 byte
DEFB 00H
5722H: the first byte of the title buffer, 00H for no title (5578H); 55C9H copies the title here with 0DH and 00H after it.
5723H-575EH
60 bytes
DEFB 20H x 60
5723H-575EH: the rest of the title buffer, spaces in the file; a title of up to 58 characters and its 0DH and 00H end at 575DH at most.
575FH
1 byte
DEFB 00H
575FH: 00H, the last byte of the title buffer.
5760H
1 byte
DEFB 0DH
5760H: 0DH, a new line before the heading (5264H, 54C9H).
5761H-5788H
40 bytes
DEFM " Ref Line Numbers"
5761H-5788H: the heading over the reference column and the line numbers.
5789H
1 byte
DEFB 00H
5789H: 00H, the end of the heading for 55F6H.
578AH-578BH
2 bytes
DEFM "-" / DEFB 00H
578AH-578BH: a minus sign and 00H, sent five times by 54E1H in the rule line.
578CH-578DH
2 bytes
DEFM "+" / DEFB 00H
578CH-578DH: a plus sign and 00H, the left corner of the rule line (54D9H).
578EH
1 byte
DEFM "+"
578EH: a plus sign, the right corner of the rule line (54EBH), followed by the 0DH at 578FH.
578FH-5790H
2 bytes
DEFB 0DH,00H
578FH-5790H: 0DH and 00H, a new line, sent by 5246H, 54B1H, 54D3H and 5681H.
5791H-5792H
2 bytes
DEFB 0CH,00H
5791H-5792H: 0CH and 00H, the form feed at the end of the listing (5357H).
5793H
1 byte
DEFB 00H
5793H: the kind of output: 00H the video, 2AH a device, a letter a file (523DH); read at 524CH and 5710H.
5794H
1 byte
DEFB 00H
5794H: the count of lines on the page: up by one for each 0DH sent, 00H after a 0CH (55F6H); read at 54AEH and 54B9H.
5795H-579AH
6 bytes
DEFM "Break" / DEFB 00H
5795H-579AH: the text shown on the video by 5687H after BREAK.
579BH-579DH
3 bytes
DEFM "TXT"
579BH-579DH: the default extension of the listing file, for @FEXT (5231H).
579EH-579FH
2 bytes
DEFB 1CH,1FH
579EH-579FH: the start of the banner (5209H): 1CH puts the cursor home, 1FH clears the screen from there.
57A0H-57D4H
53 bytes
DEFM "BASIC Cross Reference Listing Utility - Version 1.22" / DEFB 0AH
57A0H-57D4H: the first line of the banner and 0AH, a line feed.
57D5H-580AH
54 bytes
DEFM "Copyright 1987 by MISOSYS, Inc., All rights reserved" / DEFB 0DH
57D5H-580AH: the second line of the banner and 0DH, the end of the banner.
580BH-581BH
17 bytes
DEFB 0DH / DEFM "Out of memory." / DEFB 0DH,00H
580BH-581BH: the text of 554CH when the list of line numbers reaches the bottom of string space.
581CH-5823H
8 bytes
DEFS 8
581CH-5823H: not in the file. The last entry listed: seven characters and 00H, spaces at the start (526DH); copied from 5824H by 5303H.
5824H-582BH
8 bytes
DEFS 8
5824H-582BH: not in the file. The lowest entry of the pass above the last one listed (FFH x 7 at the start of each pass, 5285H), or the entry named after an equals sign (5570H).
582CH-5833H
8 bytes
DEFS 8
582CH-5833H: not in the file. The entry the scanner took last (5295H, 538AH).
5834H-583BH
8 bytes
DEFS 8
5834H-583BH: not in the file. The field of seven characters being sent: the reference column between colons, or a line number (54FAH).
583CH-583DH
2 bytes
DEFS 2
583CH-583DH: not in the file. The pointer into the list of line numbers, 5 bytes above the end of the arrays at the start (5515H).
583EH-583FH
2 bytes
DEFS 2
583EH-583FH: not in the file. The last line number read from the list, for passing over repeats (5555H).
5840H
1 byte
DEFS 1
5840H: not in the file. The found flag: 01H when the pass found an entry to list (52EAH).
5841H
1 byte
DEFS 1
5841H: not in the file. The count of the fields sent on the output line (54F6H, 54FAH).
5842H
1 byte
DEFS 1
5842H: not in the file. The line number list flag: 01H after a line number, so the next call of the scanner looks for another (5440H).
5843H
1 byte
DEFS 1
5843H: not in the file. The letter after a minus sign: V for the names only, L for the line numbers only (558CH).
5844H
1 byte
DEFS 1
5844H: not in the file. The named flag: 01H after an equals sign with a name or a line number (55BAH).
5845H-5846H
2 bytes
DEFS 2
5845H-5846H: not in the file. The pointer to the options in the command line (5213H, 5229H), read at 5258H.
5847H-5866H
32 bytes
DEFS 32
5847H-5866H: not in the file. The control block of the listing's device or file (@FSPEC, @INIT, @CLOSE); bit 7 of 5847H is set while a file is open.
5900H-59FFH
256 bytes
DEFS 256
5900H-59FFH: not in the file. The buffer of the listing file (5237H).

Operands Changed While It Runs

Address
Size
Contents
55FBH-55FCH
2 bytes
The control block of the output for 55F6H (0000H in the file): 401DH, the video, by 55E4H; 5847H, the listing's device or file, by 5255H; 4025H, the printer, by 55EEH, which no code calls.

Disassembly

5200H - The Start: the Banner and the Output

The transfer address. BASIC/CMD runs this file with @RUN for CMD"X text" (its 547CH): the file loads over BASIC/CMD at 5200H and is entered with Register Pair HL at the text after the X, which BASIC/CMD copied to 4226H with a 0DH after it. The banner is shown and the text folded to upper case. When the text starts with an asterisk or a character from A up, it is the device or file for the listing: @FSPEC reads it into the control block at 5847H, a file gets the extension TXT when it has none, and @INIT opens it with the buffer 5900H. 5793H keeps the first byte of the specification (2AH for a device).

5200
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the command line after the X.
5201
CP 20H FE 20
Compare Register A against 20H, a space: the Z FLAG for a space.
5203
If the NZ FLAG is set (not a space), JUMP to 5208H with Register Pair HL at the first character of the parameters.
5205
INC HL 23
INCrement Register Pair HL past the space to the next character of the command line.
5206
LOOP BACK to 5200H for the next character of the command line.
5208
PUSH HL E5
Save Register Pair HL (the start of the parameters) to the stack.
5209
LD HL,579EH 21 9E 57
Point Register Pair HL to 579EH, the banner: 1CH (cursor home), 1FH (clear to the end of the screen) and the name and copyright lines, ended by 0DH at 580AH.
520C
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL up to its 0DH.
520F
POP HL E1
Restore Register Pair HL (the start of the parameters) from the stack.
5210
GOSUB to 56B0H to fold the text at Register Pair HL to upper case up to its 0DH; the title is folded too.
5213
LD (5845H),HL 22 45 58
Store Register Pair HL (the start of the parameters) at 5845H-5846H, where 5570H reads the options when no device or file is given.
5216
LD A,(HL) 7E
Load Register A with the first character of the parameters at Register Pair HL.
5217
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: the start of a device specification, such as the printer's.
5219
If the Z FLAG is set (an asterisk), JUMP to 5220H to read the device.
521B
CP 41H FE 41
Compare Register A against 41H, the letter A: the CARRY FLAG below it.
521D
If the CARRY FLAG is set (no device or file, such as a minus sign, an equals sign or the end), JUMP to 5246H: the listing goes to the video.
5220
LD DE,5847H 11 47 58
Point Register Pair DE to 5847H, the control block for the listing's device or file.
5223
GOSUB to 441CH, @FSPEC, to read the file specification at Register Pair HL into the control block at Register Pair DE: the Z FLAG when it is good, Register Pair HL after it.
5226
If the NZ FLAG is set (a bad specification), JUMP to 5708H to give the error with @ERROR and go back to BASIC.
5229
LD (5845H),HL 22 45 58
Store Register Pair HL (the text after the specification) at 5845H-5846H, where 5570H reads the options.
522C
LD A,(DE) 1A
Load Register A with the first byte of the control block at Register Pair DE (5847H), the first character of the specification.
522D
CP 2AH FE 2A
Compare Register A against 2AH, an asterisk: a device has no extension.
522F
If the Z FLAG is set (a device), JUMP to 5237H.
5231
LD HL,579BH 21 9B 57
Point Register Pair HL to 579BH, the text TXT, the default extension of the listing file.
5234
GOSUB to 444BH, @FEXT, to give the specification in the control block at Register Pair DE the extension at Register Pair HL when it has none.
5237
LD HL,5900H 21 00 59
Point Register Pair HL to 5900H, the 256 byte buffer of the listing file.
523A
LD B,00H 06 00
Load Register B with 00H, the record length: 256 byte records.
523C
LD A,(DE) 1A
Load Register A with the first byte of the control block at Register Pair DE: 2AH for a device, a letter for a file.
523D
LD (5793H),A 32 93 57
Store Register A at 5793H, the kind of output: 00H for the video, 2AH for a device, a letter for a file (5710H closes only a file).
5240
GOSUB to 4420H, @INIT, to open the device or file named at Register Pair DE, created when it does not exist, with the buffer at Register Pair HL and the record length in Register B.
5243
If the NZ FLAG is set (it cannot be opened), JUMP to 5708H to give the error with @ERROR and go back to BASIC.

5246H - The Options, the Title and the Heading

A new line on the video, then the output of 55F6H is pointed at the control block 5847H when a device or file was given (it is the video's, 401DH, from 55E4H otherwise). 5570H reads -V, -L, =name and the title in angle brackets. The title and the heading are sent, 581CH (the last entry listed) is set to seven spaces, below every entry, and the list of line numbers is emptied.

5246
LD HL,578FH 21 8F 57
Point Register Pair HL to 578FH, the text 0DH, a new line.
5249
GOSUB to 55E4H to point the output at the video's control block (401DH) and send the text at Register Pair HL.
524C
LD A,(5793H) 3A 93 57
Load Register A with the kind of output from 5793H.
524F
OR A B7
OR Register A with itself: the Z FLAG for 00H, no device or file given.
5250
If the Z FLAG is set (the video), JUMP to 5258H.
5252
LD HL,5847H 21 47 58
Point Register Pair HL to 5847H, the control block of the listing's device or file.
5255
LD (55FBH),HL 22 FB 55
Store Register Pair HL (5847H) at 55FBH-55FCH, the operand of LD DE at 55FAH: 55F6H now sends every byte to the device or file.
5258
LD HL,(5845H) 2A 45 58
Load Register Pair HL with the text of the options from 5845H-5846H.
525B
GOSUB to 5570H to read the options at Register Pair HL: 5843H the letter after a minus sign, 5824H and 5844H a name or number after an equals sign, 5722H the title.
525E
LD HL,5722H 21 22 57
Point Register Pair HL to 5722H, the title (00H alone when none was given).
5261
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
5264
LD HL,5760H 21 60 57
Point Register Pair HL to 5760H, the heading: 0DH, Ref and Line Numbers.
5267
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
526A
LD HL,581CH 21 1C 58
Point Register Pair HL to 581CH, the last entry listed.
526D
GOSUB to 537BH to fill the seven bytes at Register Pair HL with spaces and put 00H after them: lower than any entry.
5270
GOSUB to 5515H to point 583CH at the start of the list of line numbers (5 bytes above the end of the arrays): the list is empty.

5273H - One Pass: the Next Entry

Each pass reads every line of the program from 40A4H and takes each entry of it (a line number after a reference token, or a variable name) as seven characters at 582CH (538AH). With -V only names are taken, with -L only line numbers. The pass looks for the lowest entry above the last one listed (581CH): a new lowest entry goes into 5824H and the list of line numbers starts again; each line where that entry is met is added to the list (552FH). With =name (5844H) only the named entry is taken. 5840H is set when an entry is found.

5273
XOR A AF
Load Register A with 00H (XOR A), for two flags.
5274
LD (5840H),A 32 40 58
Store Register A (00H) at 5840H, the found flag: no entry found in this pass yet.
5277
LD (5842H),A 32 42 58
Store Register A (00H) at 5842H, the line number list flag of the scanner: not in a list of line numbers.
527A
LD A,(5844H) 3A 44 58
Load Register A with the named flag from 5844H: 01H when =name was given.
527D
OR A B7
OR Register A with itself: the NZ FLAG for a named entry.
527E
If the NZ FLAG is set (=name given), JUMP to 5288H: 5824H holds the name to look for.
5280
LD HL,5824H 21 24 58
Point Register Pair HL to 5824H, the lowest entry of the pass so far.
5283
LD A,FFH 3E FF
Load Register A with FFH, above any character of an entry.
5285
GOSUB to 537DH to fill the seven bytes at Register Pair HL with Register A (FFH) and put 00H after them: higher than any entry.
5288
LD IX,(40A4H) DD 2A A4 40
Load Index Register IX with 40A4H-40A5H, the start of the program text: the first line.
528C
GOSUB to 56E8H to test the link of the line at Index Register IX: the Z FLAG for 0000H, the end of the program.
528F
If the Z FLAG is set (the end), JUMP to 52EFH to list the entry found by the pass.
5291
PUSH IX DD E5
Save Index Register IX (the line) to the stack.
5293
POP IY FD E1
Restore Index Register IY from the stack: Index Register IY = the line, the pointer the scanner moves through its text.
5295
LD HL,582CH 21 2C 58
Point Register Pair HL to 582CH, the buffer for the next entry of the line.
5298
PUSH HL E5
Save Register Pair HL (582CH, the entry buffer) to the stack for 529FH.
5299
GOSUB to 537BH to fill the seven bytes at Register Pair HL with spaces and put 00H after them.
529C
GOSUB to 538AH to take the next entry of the line at Index Register IY into the buffer at Register Pair HL.
529F
POP HL E1
Restore Register Pair HL (582CH, the start of the entry) from the stack.
52A0
LD A,(HL) 7E
Load Register A with the first character of the entry at Register Pair HL.
52A1
CP 20H FE 20
Compare Register A against 20H, a space: the Z FLAG when no entry was taken, the end of the line.
52A3
If the NZ FLAG is set (an entry), JUMP to 52AAH.
52A5
GOSUB to 56D8H to move Index Register IX to the next line by its text.
52A8
LOOP BACK to 528CH for the next line of the program at Index Register IX.
52AA
LD A,(5843H) 3A 43 58
Load Register A with the letter of the option from 5843H: V, L or 00H.
52AD
CP 56H FE 56
Compare Register A against 56H, the letter V: only the variables.
52AF
If the NZ FLAG is set (not V), JUMP to 52B8H.
52B1
LD A,(HL) 7E
Load Register A with the first character of the entry at Register Pair HL.
52B2
CP 41H FE 41
Compare Register A against 41H, the letter A: the CARRY FLAG for a digit, a line number.
52B4
If the CARRY FLAG is set (a line number with -V), JUMP to 5295H for the next entry.
52B6
JUMP to 52C1H to compare the name with the entries of the pass.
52B8
CP 4CH FE 4C
Compare Register A (the letter of the option) against 4CH, the letter L: only the line numbers.
52BA
If the NZ FLAG is set (neither V nor L), JUMP to 52C1H: every entry is taken.
52BC
LD A,(HL) 7E
Load Register A with the first character of the entry at Register Pair HL.
52BD
CP 3AH FE 3A
Compare Register A against 3AH, after the digit 9: the NO CARRY FLAG for a letter, a name.
52BF
If the NO CARRY FLAG is set (a name with -L), JUMP to 5295H for the next entry.
52C1
LD DE,5824H 11 24 58
Point Register Pair DE to 5824H, the lowest entry so far or the named entry.
52C4
GOSUB to 5360H to compare the entry at Register Pair HL with the one at Register Pair DE: the Z FLAG when they are the same.
52C7
If the Z FLAG is set (the same entry), JUMP to 52E5H to add this line to the list.
52C9
LD A,(5844H) 3A 44 58
Load Register A with the named flag from 5844H.
52CC
OR A B7
OR Register A with itself: the NZ FLAG for a named entry.
52CD
If the NZ FLAG is set (only the named entry is wanted), JUMP to 5295H for the next entry.
52CF
LD DE,581CH 11 1C 58
Point Register Pair DE to 581CH, the last entry listed.
52D2
GOSUB to 5360H to compare the entry at Register Pair HL with the one at Register Pair DE: the CARRY FLAG when the last entry listed is lower.
52D5
If the NO CARRY FLAG is set (the entry is listed already), JUMP to 5295H for the next entry.
52D7
LD DE,5824H 11 24 58
Point Register Pair DE to 5824H, the lowest entry so far.
52DA
GOSUB to 5360H to compare the entry at Register Pair HL with the one at Register Pair DE: the CARRY FLAG when the lowest so far is lower.
52DD
If the CARRY FLAG is set (the entry is not lower), JUMP to 5295H for the next entry.
52DF
GOSUB to 5374H to copy the entry at Register Pair HL to Register Pair DE (5824H): the new lowest entry.
52E2
GOSUB to 5515H to empty the list of line numbers: the lines of the old lowest entry are dropped.
52E5
GOSUB to 552FH to add the number of the line at Index Register IX to the list, or end with Out of memory.
52E8
LD A,01H 3E 01
Load Register A with 01H, for the found flag.
52EA
LD (5840H),A 32 40 58
Store Register A (01H) at 5840H, the found flag: this pass has an entry to list.
52ED
LOOP BACK to 5295H for the next entry of the line.

52EFH - Listing One Entry

The list is ended with 0000H. With no entry found, the listing ends (5354H). Else the entry becomes the last one listed (581CH), a rule line is drawn (a new page first after 50 lines), the reference column is sent as a colon, the first five characters of the entry and a colon, and then the line numbers of the list, a line number once even when the entry is met more than once in a line, eight to an output line; a further output line starts with an empty reference column.

52EF
GOSUB to 5521H to end the list with 0000H and point 583CH back at its start.
52F2
LD A,(5840H) 3A 40 58
Load Register A with the found flag from 5840H.
52F5
OR A B7
OR Register A with itself: the Z FLAG when the pass found no entry.
52F6
If the Z FLAG is set (no more entries), JUMP to 5354H to end the listing.
52F9
XOR A AF
Load Register A with 00H (XOR A), for the scanner's flag.
52FA
LD (5842H),A 32 42 58
Store Register A (00H) at 5842H, the line number list flag of the scanner.
52FD
LD HL,5824H 21 24 58
Point Register Pair HL to 5824H, the entry found by the pass.
5300
LD DE,581CH 11 1C 58
Point Register Pair DE to 581CH, the last entry listed.
5303
GOSUB to 5374H to copy the entry at Register Pair HL to Register Pair DE: the next pass looks above it.
5306
GOSUB to 54B9H to draw a rule line, with a new page, the title and the heading first after 50 lines.
5309
GOSUB to 54F6H to start a new output line: the field at 5834H is made a colon, five spaces and a colon, and Register Pair HL points to it.
530C
PUSH HL E5
Save Register Pair HL (5834H, the field) to the stack.
530D
LD HL,5828H 21 28 58
Point Register Pair HL to 5828H, the fifth character of the entry.
5310
LD DE,5839H 11 39 58
Point Register Pair DE to 5839H, the sixth byte of the field, before its last colon.
5313
LD BC,0005H 01 05 00
Load Register Pair BC with 0005H, five characters.
5316
LDDR ED B8
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE, last byte first: 5824H-5828H to 5835H-5839H, the first five characters of the entry between the colons.
5318
POP HL E1
Restore Register Pair HL (5834H, the field) from the stack.
5319
GOSUB to 55F6H to send the reference column at Register Pair HL to the listing's output.
531C
GOSUB to 5555H to read the next line number of the list into Register Pair HL, passing over a repeat of the one before: the Z FLAG at the end of the list.
531F
If the Z FLAG is set (the end of the list), JUMP to 534DH.
5322
PUSH HL E5
Save Register Pair HL (the line number) to the stack.
5323
GOSUB to 54FAH to clear the field at 5834H and count it in 5841H: Register A = the count of fields on the output line.
5326
CP 0AH FE 0A
Compare Register A against 0AH: the NO CARRY FLAG for the tenth field, past eight line numbers.
5328
If the CARRY FLAG is set (room on the line), JUMP to 5336H.
532A
GOSUB to 54AEH to end the output line, with a new page after 55 lines.
532D
GOSUB to 54F6H to start a new output line with the field at 5834H made a colon, five spaces and a colon.
5330
GOSUB to 55F6H to send the empty reference column at Register Pair HL to the listing's output.
5333
GOSUB to 54FAH to clear the field at 5834H for the line number and count it in 5841H.
5336
POP HL E1
Restore Register Pair HL (the line number) from the stack.
5337
GOSUB to 56C8H to turn the line number in Register Pair HL into decimal text: Register Pair DE returns at its first digit.
533A
DEC DE 1B
DECrement Register Pair DE to the space before the digits (4130H).
533B
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL = the text of the number.
533C
LD DE,5834H 11 34 58
Point Register Pair DE to 5834H, the field of seven characters for the line number.
533F
PUSH DE D5
Save Register Pair DE (5834H, the field) to the stack for 5343H.
5340
GOSUB to 5374H to copy the text at Register Pair HL up to its 00H into the field at Register Pair DE, over its spaces.
5343
POP HL E1
Restore Register Pair HL (5834H, the field) from the stack.
5344
GOSUB to 55F6H to send the field at Register Pair HL, the line number in seven places, to the listing's output.
5347
GOSUB to 56D8H, the move to the next program line, on Index Register IX; nothing in the listing reads Index Register IX, and 5288H loads it again.
534A
JUMP to 531CH for the next line number of the list.

534DH - The End of the Listing

After an entry: the next pass, unless =name was given. At the end: a rule line and a form feed, then the file is closed and BASIC/CMD run again.

534D
LD A,(5844H) 3A 44 58
Load Register A with the named flag from 5844H.
5350
OR A B7
OR Register A with itself: the Z FLAG when no =name was given.
5351
If the Z FLAG is set (all entries), JUMP to 5273H for the next pass.
5354
GOSUB to 54CFH to draw the rule line below the last entry.
5357
LD HL,5791H 21 91 57
Point Register Pair HL to 5791H, the text 0CH, a form feed.
535A
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
535D
JUMP to 568DH to close the listing file and run BASIC/CMD again.

5360H - Comparing Two Entries

Compares the text at Register Pair HL with the text at Register Pair DE up to the 00H of either: the Z FLAG when they are the same, else the CARRY FLAG when the text at Register Pair DE is the lower. Both are kept.

5360
PUSH HL E5
Save Register Pair HL to the stack, to be kept.
5361
PUSH DE D5
Save Register Pair DE to the stack, to be kept.
5362
XOR A AF
Load Register A with 00H (XOR A), to test the byte at Register Pair HL.
5363
CP (HL) BE
Compare Register A (00H) against the byte at Register Pair HL: the Z FLAG (CARRY FLAG clear) at its 00H.
5364
If the Z FLAG is set (the end), JUMP to 5371H: the texts are the same.
5366
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE.
5367
OR A B7
OR Register A with itself: the Z FLAG (CARRY FLAG clear) at its 00H.
5368
If the Z FLAG is set (the end), JUMP to 5371H: the texts are the same.
536A
CP (HL) BE
Compare Register A (the byte at Register Pair DE) against the byte at Register Pair HL: the CARRY FLAG when it is the lower.
536B
If the NZ FLAG is set (they differ), JUMP to 5371H with the CARRY FLAG of the compare.
536D
INC HL 23
INCrement Register Pair HL to the next byte of the text at Register Pair HL.
536E
INC DE 13
INCrement Register Pair DE to the next byte of the text at Register Pair DE.
536F
LOOP BACK to 5362H for the next pair of bytes.
5371
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
5372
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
5373
RET C9
RETURN to the caller with the Z FLAG and the CARRY FLAG of the comparison.

5374H - Copying an Entry

Copies the bytes at Register Pair HL to Register Pair DE up to the 00H, which is not copied. Register Pair BC is counted down by the LDI.

5374
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
5375
OR A B7
OR Register A with itself: the Z FLAG at the 00H ending the text.
5376
RET Z C8
If the Z FLAG is set (the end), RETURN with Register Pair HL at the 00H.
5377
LDI ED A0
Copy the byte at Register Pair HL to Register Pair DE, INCrement both and DECrement Register Pair BC (LDI).
5379
LOOP BACK to 5374H for the next byte of the text at Register Pair HL.

537BH - An Empty Entry

537BH fills the seven bytes at Register Pair HL with spaces, 537DH with the byte in Register A, and puts 00H in the eighth. Register Pair HL and Register Pair BC are kept.

537B
LD A,20H 3E 20
Load Register A with 20H, a space, the filler of 537BH.
537D
PUSH HL E5
Save Register Pair HL (the start of the field) to the stack, to be kept.
537E
PUSH BC C5
Save Register Pair BC to the stack, to be kept.
537F
LD B,07H 06 07
Load Register B with 07H, the seven characters of a field.
5381
LD (HL),A 77
Store Register A (the filler) at Register Pair HL.
5382
INC HL 23
INCrement Register Pair HL to the next byte of the field.
5383
DECrement Register B and LOOP BACK to 5381H for the seven bytes.
5385
XOR A AF
Load Register A with 00H (XOR A), the end of the field.
5386
LD (HL),A 77
Store Register A (00H) at Register Pair HL, the eighth byte.
5387
POP BC C1
Restore Register Pair BC from the stack, as it was on entry.
5388
POP HL E1
Restore Register Pair HL (the start of the field) from the stack.
5389
RET C9
RETURN to the caller with Register Pair HL at the field.

538AH - The Scanner: the Next Entry of a Line

Reads the text of the line from Index Register IY +04H on and puts the next entry in the field at Register Pair HL, leaving Index Register IY after it for the next call; nothing is stored at the end of the line. Passed over: a string in quotes, the rest of a line after REM (93H), DATA (88H) up to a colon, a constant after an ampersand, a number (and its letters, such as an exponent), and every other byte. After THEN, ELSE, RESUME, GOTO, GOSUB, RUN or ERL each line number is taken (5414H); 5842H tells the next call that more line numbers may follow. A name is its first two characters, then its type character (%, $, # or !) and a ( for an array; the other characters of a long name are passed over.

538A
LD A,(5842H) 3A 42 58
Load Register A with the line number list flag from 5842H: 01H after a line number taken from a list.
538D
OR A B7
OR Register A with itself: the NZ FLAG for 01H.
538E
If the NZ FLAG is set (in a list of line numbers), JUMP to 5416H for the next number of the list.
5391
JUMP to 5395H to read the byte at Index Register IY +04H.
5393
INC IY FD 23
INCrement Index Register IY to the next byte of the text.
5395
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H; the text of a line starts after its link and its number.
5398
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
5399
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
539A
CP 93H FE 93
Compare Register A against 93H, the token of REM.
539C
RET Z C8
If the Z FLAG is set (REM), RETURN with nothing stored: the rest of the line is a remark.
539D
CP 22H FE 22
Compare Register A against 22H, a quote, the start of a string.
539F
If the Z FLAG is set (a quote), JUMP to 5406H to pass over the string.
53A1
GOSUB to 56F2H to test Register A for a token followed by line numbers: the Z FLAG for THEN, ELSE, RESUME, GOTO, GOSUB, RUN or ERL.
53A4
If the Z FLAG is set (such a token), JUMP to 5414H to take the line number after it.
53A7
CP 88H FE 88
Compare Register A against 88H, the token of DATA.
53A9
If the Z FLAG is set (DATA), JUMP to 53C3H to pass over the items.
53AB
CP 26H FE 26
Compare Register A against 26H, an ampersand: a constant such as &H1F.
53AD
If the NZ FLAG is set (not an ampersand), JUMP to 53D5H.
53AF
INC IY FD 23
INCrement Index Register IY to the next byte of the text.
53B1
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
53B4
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
53B5
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
53B6
CP 2EH FE 2E
Compare Register A against 2EH, a period, part of a number.
53B8
If the Z FLAG is set (a period), LOOP BACK to 53AFH.
53BA
GOSUB to 5479H to class the byte at Index Register IY +04H: Register A = 00H for any byte that is not a digit, a letter, a type character or an open parenthesis.
53BD
OR A B7
OR Register A with itself: the NZ FLAG for a digit, a letter, a type character or a parenthesis.
53BE
If the NZ FLAG is set (part of the constant), LOOP BACK to 53AFH.
53C0
JUMP to 5395H to read the byte at Index Register IY +04H after the constant.
53C3
INC IY FD 23
INCrement Index Register IY to the next byte of the DATA items.
53C5
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
53C8
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
53C9
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
53CA
CP 3AH FE 3A
Compare Register A against 3AH, a colon, the end of the DATA statement.
53CC
If the Z FLAG is set (a colon), JUMP to 5393H to go on after it.
53CE
CP 80H FE 80
Compare Register A against 80H: the CARRY FLAG for a byte below the tokens.
53D0
If the CARRY FLAG is set (not a token), LOOP BACK to 53C3H.
53D2
JUMP to 5395H: a token ends the passing over the DATA items.
53D5
GOSUB to 5479H to class the byte at Index Register IY +04H: Register A = 01H a digit, 02H a letter.
53D8
CP 01H FE 01
Compare Register A (the class) against 01H, a digit.
53DA
If the Z FLAG is set (a digit), JUMP to 53AFH to pass over the number.
53DC
CP 02H FE 02
Compare Register A (the class) against 02H, a letter.
53DE
If the NZ FLAG is set (not a letter), JUMP to 5393H to go on with the next byte.
53E0
GOSUB to 5472H to store the first letter at Register Pair HL, step Register Pair HL and Index Register IY, and class the next byte into Register A.
53E3
RET Z C8
If the Z FLAG is set (the next byte ends the name), RETURN with the name of one letter.
53E4
CP 03H FE 03
Compare Register A against 03H, a type character.
53E6
If the Z FLAG is set (%, $, # or !), JUMP to 53FBH to store it.
53E8
If the NO CARRY FLAG is set (04H, an open parenthesis), JUMP to 5401H to store it.
53EA
LD A,(IY+04H) FD 7E 04
Load Register A with the second character of the name at Index Register IY +04H.
53ED
LD (HL),A 77
Store Register A (the second character) at Register Pair HL.
53EE
INC HL 23
INCrement Register Pair HL to the next byte of the entry.
53EF
INC IY FD 23
INCrement Index Register IY to the next byte of the text: from the third character on the name is not stored.
53F1
GOSUB to 5479H to class the byte at Index Register IY +04H into Register A.
53F4
RET Z C8
If the Z FLAG is set (the end of the name), RETURN with the name stored.
53F5
CP 03H FE 03
Compare Register A against 03H, a type character: the CARRY FLAG for a digit or a letter.
53F7
If the CARRY FLAG is set (more of the name), LOOP BACK to 53EFH to pass over it.
53F9
If the NZ FLAG is set (04H, an open parenthesis), JUMP to 5401H to store it.
53FB
GOSUB to 5472H to store the type character at Register Pair HL, step Register Pair HL and Index Register IY, and class the next byte into Register A.
53FE
CP 04H FE 04
Compare Register A against 04H, an open parenthesis.
5400
RET NZ C0
If the NZ FLAG is set (no parenthesis), RETURN with the name and its type stored.
5401
LD A,(IY+04H) FD 7E 04
Load Register A with the open parenthesis at Index Register IY +04H.
5404
LD (HL),A 77
Store Register A (the open parenthesis) at Register Pair HL: the name is an array.
5405
RET C9
RETURN to the caller with the entry stored and Index Register IY at the parenthesis.

5406H - A String in Quotes

Passes over the text up to the closing quote, then goes on after it (5393H); the end of the line returns with nothing stored.

5406
INC IY FD 23
INCrement Index Register IY to the next byte of the string.
5408
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
540B
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
540C
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
540D
CP 22H FE 22
Compare Register A against 22H, the closing quote.
540F
If the NZ FLAG is set (not a quote), LOOP BACK to 5406H.
5411
JUMP to 5393H to go on after the closing quote.

5414H - A Line Number after a Token

Spaces, commas, the = token (D5H) and the digit 0 are passed over, so a line number is taken without its leading zeros and 0 alone is not taken. Up to five digits are stored and the number is moved right with zeros in front, five digits wide, so that line numbers sort by their value and before the names. 5842H is set to 01H so the next call looks for a further number of the list. Any other byte goes back to the scanner (5395H).

5414
INC IY FD 23
INCrement Index Register IY to the next byte of the text.
5416
XOR A AF
Load Register A with 00H (XOR A), for the line number list flag.
5417
LD (5842H),A 32 42 58
Store Register A (00H) at 5842H, the line number list flag.
541A
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
541D
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
541E
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
541F
CP 20H FE 20
Compare Register A against 20H, a space between the token and the number.
5421
If the Z FLAG is set (a space), JUMP to 5414H to pass over it.
5423
CP 2CH FE 2C
Compare Register A against 2CH, a comma, between the numbers of ON n GOTO.
5425
If the Z FLAG is set (a comma), JUMP to 5414H to pass over it.
5427
CP D5H FE D5
Compare Register A against D5H, the token of =, as in ERL=n.
5429
If the Z FLAG is set (the = token), JUMP to 5414H to pass over it.
542B
CP 30H FE 30
Compare Register A against 30H, the digit 0, which is passed over here.
542D
If the NZ FLAG is set (not a 0), JUMP to 5438H.
542F
INC IY FD 23
INCrement Index Register IY past the 0 to the next byte of the text.
5431
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
5434
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
5435
RET Z C8
If the Z FLAG is set (the end of the line), RETURN with nothing stored.
5436
LOOP BACK to 542BH to pass over further zeros.
5438
GOSUB to 5479H to class the byte at Index Register IY +04H: Register A = 01H for a digit.
543B
CP 01H FE 01
Compare Register A (the class) against 01H, a digit.
543D
If the NZ FLAG is set (not a digit), JUMP to 5395H: the line numbers end and the scanner reads this byte.
5440
LD (5842H),A 32 42 58
Store Register A (01H) at 5842H, the line number list flag: the next call goes on with the list.
5443
PUSH HL E5
Save Register Pair HL (the start of the entry) to the stack.
5444
LD B,05H 06 05
Load Register B with 05H, at most five digits.
5446
PUSH BC C5
Save Register Pair BC (Register B = the digits left) to the stack.
5447
GOSUB to 5472H to store the digit at Register Pair HL, step Register Pair HL and Index Register IY, and class the next byte into Register A.
544A
POP BC C1
Restore Register Pair BC (Register B = the digits left) from the stack.
544B
CP 01H FE 01
Compare Register A (the class of the next byte) against 01H, a digit.
544D
If the NZ FLAG is set (the number ends), JUMP to 5453H to move it right.
544F
DECrement Register B and LOOP BACK to 5446H while digits are left to store.
5451
POP HL E1
Restore Register Pair HL (the start of the entry) from the stack.
5452
RET C9
RETURN to the caller with five digits stored; a sixth digit starts the next number.
5453
POP HL E1
Restore Register Pair HL (the start of the entry) from the stack.
5454
DEC B 05
DECrement Register B: the count of places to move the number right (5 less the digits).
5455
RET Z C8
If the Z FLAG is set (five digits), RETURN with the number as it is.
5456
INC HL 23
INCrement Register Pair HL to the second byte of the entry.
5457
INC HL 23
INCrement Register Pair HL to the third byte of the entry.
5458
INC HL 23
INCrement Register Pair HL to the fourth byte of the entry, the last of the four to move.
5459
PUSH HL E5
Save Register Pair HL (the fourth byte) to the stack.
545A
POP DE D1
Restore Register Pair DE from the stack: Register Pair DE = the fourth byte.
545B
INC DE 13
INCrement Register Pair DE to the fifth byte of the entry.
545C
PUSH HL E5
Save Register Pair HL (the fourth byte) to the stack.
545D
PUSH DE D5
Save Register Pair DE (the fifth byte) to the stack.
545E
PUSH BC C5
Save Register Pair BC (Register B = the places left to move) to the stack.
545F
LD BC,0004H 01 04 00
Load Register Pair BC with 0004H, the first four bytes of the entry.
5462
LDDR ED B8
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE, last byte first: the first four bytes move one place right.
5464
POP BC C1
Restore Register Pair BC (Register B = the places left to move) from the stack.
5465
POP DE D1
Restore Register Pair DE (the fifth byte) from the stack.
5466
POP HL E1
Restore Register Pair HL (the fourth byte) from the stack.
5467
PUSH HL E5
Save Register Pair HL (the fourth byte) to the stack.
5468
DEC HL 2B
DECrement Register Pair HL to the third byte of the entry.
5469
DEC HL 2B
DECrement Register Pair HL to the second byte of the entry.
546A
DEC HL 2B
DECrement Register Pair HL to the first byte of the entry.
546B
LD A,30H 3E 30
Load Register A with 30H, the digit 0, to fill the first place.
546D
LD (HL),A 77
Store Register A (the digit 0) at Register Pair HL, the first byte of the entry.
546E
POP HL E1
Restore Register Pair HL (the fourth byte) from the stack.
546F
DECrement Register B and LOOP BACK to 545CH until the number is five digits wide.
5471
RET C9
RETURN to the caller with the line number stored with zeros in front.

5472H - Classing a Byte

5472H stores the byte at Index Register IY +04H at Register Pair HL, steps both and goes on to 5479H. 5479H classes the byte at Index Register IY +04H into Register C and Register A: 01H a digit, 02H a letter A-Z, 03H a type character (%, $, # or !), 04H an open parenthesis, 00H any other byte (a token, a lower case letter, a sign); the Z FLAG for 00H.

5472
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
5475
LD (HL),A 77
Store Register A (the byte) at Register Pair HL in the entry.
5476
INC HL 23
INCrement Register Pair HL to the next byte of the entry.
5477
INC IY FD 23
INCrement Index Register IY to the next byte of the text.
5479
LD C,01H 0E 01
Load Register C with 01H, the class of a digit.
547B
LD A,(IY+04H) FD 7E 04
Load Register A with the byte of the text at Index Register IY +04H.
547E
CP 80H FE 80
Compare Register A against 80H: the NO CARRY FLAG for a token.
5480
If the NO CARRY FLAG is set (a token), JUMP to 54A9H for the class 00H.
5482
CP 30H FE 30
Compare Register A against 30H, the digit 0: the CARRY FLAG below it.
5484
If the CARRY FLAG is set (below 0), JUMP to 548AH.
5486
CP 3AH FE 3A
Compare Register A against 3AH, after the digit 9: the CARRY FLAG for a digit.
5488
If the CARRY FLAG is set (a digit), JUMP to 54ABH with Register C = 01H.
548A
INC C 0C
INCrement Register C to 02H, the class of a letter.
548B
CP 41H FE 41
Compare Register A against 41H, the letter A: the CARRY FLAG below it.
548D
If the CARRY FLAG is set (below A), JUMP to 5493H.
548F
CP 5BH FE 5B
Compare Register A against 5BH, after the letter Z: the CARRY FLAG for a letter.
5491
If the CARRY FLAG is set (a letter), JUMP to 54ABH with Register C = 02H.
5493
INC C 0C
INCrement Register C to 03H, the class of a type character.
5494
CP 25H FE 25
Compare Register A against 25H, the type character % (integer).
5496
If the Z FLAG is set (%), JUMP to 54ABH with Register C = 03H.
5498
CP 24H FE 24
Compare Register A against 24H, the type character $ (string).
549A
If the Z FLAG is set ($), JUMP to 54ABH with Register C = 03H.
549C
CP 23H FE 23
Compare Register A against 23H, the type character # (double precision).
549E
If the Z FLAG is set (#), JUMP to 54ABH with Register C = 03H.
54A0
CP 21H FE 21
Compare Register A against 21H, the type character ! (single precision).
54A2
If the Z FLAG is set (!), JUMP to 54ABH with Register C = 03H.
54A4
INC C 0C
INCrement Register C to 04H, the class of an open parenthesis.
54A5
CP 28H FE 28
Compare Register A against 28H, an open parenthesis, after the name of an array.
54A7
If the Z FLAG is set (a parenthesis), JUMP to 54ABH with Register C = 04H.
54A9
LD C,00H 0E 00
Load Register C with 00H, the class of any other byte.
54AB
LD A,C 79
Copy Register C (the class) into Register A, for the caller's tests.
54AC
OR A B7
OR Register A with itself: the Z FLAG for the class 00H.
54AD
RET C9
RETURN to the caller with the class in Register A and Register C.

54AEH - Ending an Output Line, a New Page

54AEH ends the output line with 0DH, but from 55 lines on (5794H) it starts a new page. 54B9H starts a new page from 50 lines on: a rule line, a form feed and the title (5721H), the heading (5760H), then the rule line of 54CFH; below 50 lines only that rule line. 54CFH sends 0DH, a plus sign, five minus signs, a plus sign and 0DH; Index Register IX and Index Register IY are kept.

54AE
LD A,(5794H) 3A 94 57
Load Register A with the count of lines on the page from 5794H.
54B1
LD HL,578FH 21 8F 57
Point Register Pair HL to 578FH, the text 0DH, the end of the output line. LD does not change the flags.
54B4
CP 37H FE 37
Compare Register A against 37H, 55 lines: the CARRY FLAG below it.
54B6
If the CARRY FLAG is set (fewer than 55 lines), JUMP to 55F6H to send the 0DH and return from there.
54B9
LD A,(5794H) 3A 94 57
Load Register A with the count of lines on the page from 5794H.
54BC
CP 32H FE 32
Compare Register A against 32H, 50 lines: the CARRY FLAG below it.
54BE
If the CARRY FLAG is set (fewer than 50 lines), JUMP to 54CFH for the rule line alone.
54C0
GOSUB to 54CFH to draw the rule line at the foot of the page.
54C3
LD HL,5721H 21 21 57
Point Register Pair HL to 5721H, the text 0CH (a form feed, which starts the count of lines again) and the title after it.
54C6
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54C9
LD HL,5760H 21 60 57
Point Register Pair HL to 5760H, the heading: 0DH, Ref and Line Numbers.
54CC
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54CF
PUSH IY FD E5
Save Index Register IY to the stack, to be kept.
54D1
PUSH IX DD E5
Save Index Register IX to the stack, to be kept.
54D3
LD HL,578FH 21 8F 57
Point Register Pair HL to 578FH, the text 0DH, a new line.
54D6
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54D9
LD HL,578CH 21 8C 57
Point Register Pair HL to 578CH, the text of a plus sign, the left corner of the rule.
54DC
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54DF
LD B,05H 06 05
Load Register B with 05H, the five minus signs above the reference column.
54E1
LD HL,578AH 21 8A 57
Point Register Pair HL to 578AH, the text of a minus sign.
54E4
PUSH BC C5
Save Register Pair BC (Register B = the minus signs left) to the stack.
54E5
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54E8
POP BC C1
Restore Register Pair BC (Register B = the minus signs left) from the stack.
54E9
DECrement Register B and LOOP BACK to 54E1H for the five minus signs.
54EB
LD HL,578EH 21 8E 57
Point Register Pair HL to 578EH, the text of a plus sign and 0DH, the right corner and the end of the rule line.
54EE
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
54F1
POP IX DD E1
Restore Index Register IX from the stack, as it was on entry.
54F3
POP IY FD E1
Restore Index Register IY from the stack, as it was on entry.
54F5
RET C9
RETURN to the caller with the rule line sent.

54F6H - A Field of the Output Line

54F6H starts an output line (the count of fields at 5841H to 00H). 54FAH clears the field at 5834H to seven spaces and counts it; the first field of a line, the reference column, gets a colon at each end (5834H and 583AH). Returns Register A = the count of fields and Register Pair HL = 5834H.

54F6
XOR A AF
Load Register A with 00H (XOR A), for the count of fields.
54F7
LD (5841H),A 32 41 58
Store Register A (00H) at 5841H, the count of the fields sent on the output line.
54FA
LD HL,5834H 21 34 58
Point Register Pair HL to 5834H, the field of seven characters.
54FD
GOSUB to 537BH to fill the seven bytes at Register Pair HL with spaces and put 00H after them.
5500
LD A,(5841H) 3A 41 58
Load Register A with the count of fields from 5841H.
5503
INC A 3C
INCrement Register A, the count of fields with this one.
5504
LD (5841H),A 32 41 58
Store Register A (the count of fields with this one) at 5841H.
5507
CP 01H FE 01
Compare Register A against 01H: the Z FLAG for the first field of the line.
5509
RET NZ C0
If the NZ FLAG is set (a line number field), RETURN with Register A = the count.
550A
PUSH AF F5
Save Register Pair AF (Register A = 01H) to the stack.
550B
LD A,3AH 3E 3A
Load Register A with 3AH, a colon, for the edges of the reference column.
550D
LD (583AH),A 32 3A 58
Store Register A (a colon) at 583AH, the seventh character of the field.
5510
LD (5834H),A 32 34 58
Store Register A (a colon) at 5834H, the first character of the field.
5513
POP AF F1
Restore Register Pair AF (Register A = 01H) from the stack.
5514
RET C9
RETURN to the caller with Register A = 01H and Register Pair HL = 5834H.

5515H - The List of Line Numbers

5515H points 583CH at the start of the list, 5 bytes above the end of the arrays (40FDH). 5521H ends the list with 0000H, clears the last number read (583EH) and points 583CH back at the start. 552FH adds the number of the line at Index Register IX to the list; when the list would go above the bottom of string space (40A0H), Out of memory is shown on the video and the listing ends. The list may grow up to the address in 40A0H, and the stack this file runs on lies below that address (the ROM sets the Stack Pointer from 40A0H at 1B9AH).

5515
LD HL,(40FDH) 2A FD 40
Load Register Pair HL with 40FDH-40FEH, the end of the arrays, the start of the free memory.
5518
INC HL 23
INCrement Register Pair HL, the first of five bytes left free above the arrays.
5519
INC HL 23
INCrement Register Pair HL, the second of the five bytes left free.
551A
INC HL 23
INCrement Register Pair HL, the third of the five bytes left free.
551B
INC HL 23
INCrement Register Pair HL, the fourth of the five bytes left free.
551C
INC HL 23
INCrement Register Pair HL, the fifth: Register Pair HL = the start of the list.
551D
LD (583CH),HL 22 3C 58
Store Register Pair HL (the start of the list) at 583CH-583DH, the pointer of the list.
5520
RET C9
RETURN to the caller with the list empty or ready to be read from its start.
5521
LD HL,(583CH) 2A 3C 58
Load Register Pair HL with the pointer of the list from 583CH-583DH, its end.
5524
XOR A AF
Load Register A with 00H (XOR A), for the end mark.
5525
LD (HL),A 77
Store Register A (00H) at Register Pair HL, the low byte of the end mark.
5526
INC HL 23
INCrement Register Pair HL to the high byte of the end mark.
5527
LD (HL),A 77
Store Register A (00H) at Register Pair HL, the high byte: the list ends with 0000H.
5528
LD H,A 67
Load Register H with Register A (00H), the high byte of 0000H.
5529
LD L,A 6F
Load Register L with Register A (00H): Register Pair HL = 0000H.
552A
LD (583EH),HL 22 3E 58
Store Register Pair HL (0000H) at 583EH-583FH, the last line number read: no line number is a repeat of it.
552D
JUMP to 5515H to point the list pointer back at its start.
552F
LD HL,(583CH) 2A 3C 58
Load Register Pair HL with the pointer of the list from 583CH-583DH, the next free place.
5532
LD A,(IX+02H) DD 7E 02
Load Register A with the low byte of the line's number at Index Register IX +02H.
5535
LD (HL),A 77
Store Register A (the low byte) at Register Pair HL in the list.
5536
INC HL 23
INCrement Register Pair HL to the next byte of the list.
5537
LD A,(IX+03H) DD 7E 03
Load Register A with the high byte of the line's number at Index Register IX +03H.
553A
LD (HL),A 77
Store Register A (the high byte) at Register Pair HL in the list.
553B
INC HL 23
INCrement Register Pair HL to the next free place of the list.
553C
PUSH HL E5
Save Register Pair HL (the next free place) to the stack.
553D
PUSH DE D5
Save Register Pair DE to the stack, to be kept.
553E
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE = the next free place.
553F
LD HL,(40A0H) 2A A0 40
Load Register Pair HL with 40A0H-40A1H, the bottom of string space.
5542
SBC HL,DE ED 52
SUBtract Register Pair DE (the next free place) from Register Pair HL with the CARRY FLAG, clear here: the CARRY FLAG when the list has passed the bottom of string space.
5544
POP DE D1
Restore Register Pair DE from the stack, as it was.
5545
POP HL E1
Restore Register Pair HL (the next free place) from the stack.
5546
If the CARRY FLAG is set (no room), JUMP to 554CH to show Out of memory.
5548
LD (583CH),HL 22 3C 58
Store Register Pair HL (the next free place) at 583CH-583DH, the pointer of the list.
554B
RET C9
RETURN to the caller with the line number in the list.
554C
LD HL,580BH 21 0B 58
Point Register Pair HL to 580BH, the text 0DH, Out of memory. and 0DH.
554F
GOSUB to 55E4H to point the output at the video's control block (401DH) and send the text at Register Pair HL.
5552
JUMP to 568DH to close the listing file and run BASIC/CMD again.

5555H - The Next Line Number of the List

Reads the next number from the list at 583CH into Register Pair HL, passing over a number equal to the one before (an entry met twice in a line); returns the NZ FLAG with the number, or the Z FLAG at the end mark 0000H. A program line numbered 0 would end the list there, its number being the same as the end mark.

5555
LD HL,(583CH) 2A 3C 58
Load Register Pair HL with the pointer of the list from 583CH-583DH.
5558
LD E,(HL) 5E
Load Register E with the low byte of the next number at Register Pair HL.
5559
INC HL 23
INCrement Register Pair HL to the high byte of the number.
555A
LD D,(HL) 56
Load Register D with the high byte of the number at Register Pair HL: Register Pair DE = the line number.
555B
INC HL 23
INCrement Register Pair HL to the next number of the list.
555C
LD A,E 7B
Load Register A with Register E, the low byte of the line number.
555D
OR D B2
OR Register A with Register D, the high byte: the Z FLAG for 0000H, the end mark; the CARRY FLAG is cleared.
555E
RET Z C8
If the Z FLAG is set (the end of the list), RETURN with the Z FLAG.
555F
LD (583CH),HL 22 3C 58
Store Register Pair HL (the next number of the list) at 583CH-583DH, the pointer of the list.
5562
LD HL,(583EH) 2A 3E 58
Load Register Pair HL with the last line number read from 583EH-583FH.
5565
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL = the new number, Register Pair DE = the one before.
5566
LD (583EH),HL 22 3E 58
Store Register Pair HL (the new number) at 583EH-583FH, the last line number read.
5569
PUSH HL E5
Save Register Pair HL (the new number) to the stack.
556A
SBC HL,DE ED 52
SUBtract Register Pair DE (the number before) from Register Pair HL with the CARRY FLAG (clear from 555DH): the Z FLAG when they are equal.
556C
POP HL E1
Restore Register Pair HL (the new number) from the stack. POP does not change the flags.
556D
If the Z FLAG is set (the same line again), LOOP BACK to 5555H for the next number.
556F
RET C9
RETURN to the caller with the NZ FLAG and the line number in Register Pair HL.

5570H - The Options

Register Pair HL points at the text after the device or file. A minus sign stores the letter after it at 5843H (V for the names only, L for the line numbers only; any other letter keeps both). An equals sign takes the name or line number after it into 5824H the way the scanner takes an entry, and sets 5844H; a byte after it that is neither a digit nor a letter names nothing. Only the first of a minus sign and an equals sign is read. Then the text from the first < is the title, up to > or 0DH, at most 58 characters, copied to 5722H with 0DH and 00H after it; the character after the < is copied before any test.

5570
PUSH HL E5
Save Register Pair HL (the text of the options) to the stack.
5571
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, for the two option cells.
5574
LD (5843H),HL 22 43 58
Store Register Pair HL (0000H) at 5843H-5844H: no letter after a minus sign (5843H), no named entry (5844H).
5577
XOR A AF
Load Register A with 00H (XOR A), for the title.
5578
LD (5722H),A 32 22 57
Store Register A (00H) at 5722H, the first byte of the title: no title.
557B
POP HL E1
Restore Register Pair HL (the text of the options) from the stack.
557C
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
557D
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
557F
RET Z C8
If the Z FLAG is set (no options), RETURN to the caller.
5580
CP 2DH FE 2D
Compare Register A against 2DH, a minus sign, before V or L.
5582
If the NZ FLAG is set (not a minus sign), JUMP to 5590H.
5584
INC HL 23
INCrement Register Pair HL to the letter after the minus sign.
5585
LD DE,5843H 11 43 58
Point Register Pair DE to 5843H, the cell of the letter of the option.
5588
LD A,(HL) 7E
Load Register A with the letter at Register Pair HL.
5589
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
558B
RET Z C8
If the Z FLAG is set (nothing after the minus sign), RETURN to the caller.
558C
LD (DE),A 12
Store Register A (the letter, upper case from 56B0H) at Register Pair DE, 5843H.
558D
JUMP to 55BDH to look for the title after the letter of the option.
5590
CP 3DH FE 3D
Compare Register A against 3DH, an equals sign, before a name or a line number.
5592
If the NZ FLAG is set (not an equals sign), JUMP to 55BDH to look for the title.
5595
INC HL 23
INCrement Register Pair HL to the character after the equals sign.
5596
PUSH HL E5
Save Register Pair HL (the text after the equals sign) to the stack, for 55B4H or 55B7H.
5597
DEC HL 2B
DECrement Register Pair HL, one of four bytes back.
5598
DEC HL 2B
DECrement Register Pair HL, two of four bytes back.
5599
DEC HL 2B
DECrement Register Pair HL, three of four bytes back.
559A
DEC HL 2B
DECrement Register Pair HL, four bytes back: the scanner reads at its pointer +04H.
559B
PUSH HL E5
Save Register Pair HL (the text after the equals sign less 4) to the stack.
559C
POP IY FD E1
Restore Index Register IY from the stack: Index Register IY +04H = the character after the equals sign.
559E
LD HL,5824H 21 24 58
Point Register Pair HL to 5824H, the field for the named entry.
55A1
GOSUB to 537BH to fill the seven bytes at Register Pair HL with spaces and put 00H after them.
55A4
GOSUB to 5479H to class the character at Index Register IY +04H: Register A = 01H a digit, 02H a letter.
55A7
LD DE,55B7H 11 B7 55
Point Register Pair DE to 55B7H, where the scanner's routines are to return.
55AA
PUSH DE D5
Save Register Pair DE (55B7H) to the stack as the return address of the JP below.
55AB
DEC A 3D
DECrement Register A (the class): the Z FLAG for 01H, a digit.
55AC
If the Z FLAG is set (a digit), JUMP to 5416H to take the line number into 5824H; it returns to 55B7H.
55AF
DEC A 3D
DECrement Register A (the class): the Z FLAG for 02H, a letter.
55B0
If the Z FLAG is set (a letter), JUMP to 53D5H to take the name into 5824H; it returns to 55B7H.
55B3
POP DE D1
Restore Register Pair DE from the stack: the return address 55B7H is dropped.
55B4
POP HL E1
Restore Register Pair HL (the text after the equals sign) from the stack.
55B5
JUMP to 55BDH to look for the title: nothing is named.
55B7
POP HL E1
Restore Register Pair HL (the text after the equals sign) from the stack, the scanner having taken the entry.
55B8
LD A,01H 3E 01
Load Register A with 01H, for the named flag.
55BA
LD (5844H),A 32 44 58
Store Register A (01H) at 5844H, the named flag: only the entry in 5824H is listed.
55BD
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
55BE
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
55C0
RET Z C8
If the Z FLAG is set (no title), RETURN to the caller.
55C1
INC HL 23
INCrement Register Pair HL to the next character. INC of a register pair does not change the flags.
55C2
CP 3CH FE 3C
Compare Register A against 3CH, the less than sign before the title.
55C4
If the NZ FLAG is set (not the less than sign), LOOP BACK to 55BDH.
55C6
LD BC,003AH 01 3A 00
Load Register Pair BC with 003AH: Register C = 58, the most characters of the title.
55C9
LD DE,5722H 11 22 57
Point Register Pair DE to 5722H, the title buffer.
55CC
LDI ED A0
Copy the character at Register Pair HL to Register Pair DE, INCrement both and DECrement Register Pair BC (LDI).
55CE
LD A,C 79
Load Register A with Register C, the room left in the title.
55CF
OR A B7
OR Register A with itself: the Z FLAG when 58 characters are copied.
55D0
If the Z FLAG is set (the title is full), JUMP to 55DDH.
55D2
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL.
55D3
CP 0DH FE 0D
Compare Register A against 0DH, the end of the command line.
55D5
If the Z FLAG is set (the end), JUMP to 55DDH.
55D7
CP 3EH FE 3E
Compare Register A against 3EH, the greater than sign after the title.
55D9
If the Z FLAG is set (the end of the title), JUMP to 55DDH.
55DB
LOOP BACK to 55CCH for the next character of the title.
55DD
LD A,0DH 3E 0D
Load Register A with 0DH, the end of the title line.
55DF
LD (DE),A 12
Store Register A (0DH) at Register Pair DE, after the title.
55E0
INC DE 13
INCrement Register Pair DE to the next byte of the title buffer.
55E1
XOR A AF
Load Register A with 00H (XOR A), the end of the text for 55F6H.
55E2
LD (DE),A 12
Store Register A (00H) at Register Pair DE, after the 0DH.
55E3
RET C9
RETURN to the caller with the title at 5722H.

55E4H - Sending a Text

55E4H points the output at the video's control block (401DH), 55EEH at the printer's (4025H; no code calls 55EEH), then 55F6H sends the text at Register Pair HL, up to its 00H, a byte at a time to the device or file whose control block address is the operand at 55FBH, with ROM 001BH. Each 0DH counts a line in 5794H, a 0CH starts the count again. After each byte the keyboard task is run, BREAK ends the listing (567EH) and SHIFT @ pauses it until a key other than SHIFT @ (BREAK then ends it). An error on a device is not reported; an error on a file goes to 5656H. Register Pair DE, Register Pair HL and Index Register IY are kept.

55E4
PUSH HL E5
Save Register Pair HL (the text) to the stack.
55E5
LD HL,401DH 21 1D 40
Point Register Pair HL to 401DH, DODCB$, the control block of the video.
55E8
LD (55FBH),HL 22 FB 55
Store Register Pair HL (401DH) at 55FBH-55FCH, the operand of LD DE at 55FAH: the output goes to the video.
55EB
POP HL E1
Restore Register Pair HL (the text) from the stack.
55EC
JUMP to 55F6H to send the text at Register Pair HL.
55EE
PUSH HL E5
Save Register Pair HL (the text) to the stack. No code jumps or calls to 55EEH.
55EF
LD HL,4025H 21 25 40
Point Register Pair HL to 4025H, PRDCB$, the control block of the printer. Not reached.
55F2
LD (55FBH),HL 22 FB 55
Store Register Pair HL (4025H) at 55FBH-55FCH, the operand of LD DE at 55FAH: the output would go to the printer. Not reached.
55F5
POP HL E1
Restore Register Pair HL (the text) from the stack. Not reached.
55F6
PUSH IY FD E5
Save Index Register IY to the stack, to be kept.
55F8
PUSH HL E5
Save Register Pair HL (the start of the text) to the stack, to be kept.
55F9
PUSH DE D5
Save Register Pair DE to the stack, to be kept.
55FA
LD DE,0000H 11 00 00
Load Register Pair DE with the control block of the output, the operand at 55FBH-55FCH (0000H in the file): 401DH by 55E4H, or 5847H by 5255H.
55FD
LD A,(HL) 7E
Load Register A with the byte of the text at Register Pair HL.
55FE
OR A B7
OR Register A with itself: the Z FLAG at the 00H ending the text.
55FF
If the Z FLAG is set (the end), JUMP to 5648H to return.
5601
CP 0DH FE 0D
Compare Register A against 0DH, the end of a line.
5603
If the NZ FLAG is set (not 0DH), JUMP to 560DH.
5605
PUSH HL E5
Save Register Pair HL (the place in the text) to the stack.
5606
LD HL,5794H 21 94 57
Point Register Pair HL to 5794H, the count of lines on the page.
5609
INC (HL) 34
INCrement the count of lines at Register Pair HL (5794H).
560A
POP HL E1
Restore Register Pair HL (the place in the text) from the stack.
560B
JUMP to 5617H to send the 0DH, counted as a line.
560D
CP 0CH FE 0C
Compare Register A against 0CH, a form feed, the start of a page.
560F
If the NZ FLAG is set (not a form feed), JUMP to 5617H.
5611
PUSH AF F5
Save Register Pair AF (Register A = 0CH) to the stack.
5612
XOR A AF
Load Register A with 00H (XOR A), for the count of lines.
5613
LD (5794H),A 32 94 57
Store Register A (00H) at 5794H, the count of lines: a new page.
5616
POP AF F1
Restore Register Pair AF (Register A = 0CH) from the stack.
5617
GOSUB to 001BH, the ROM's $PUT, to send the byte in Register A to the device or file whose control block is at Register Pair DE: the NZ FLAG with Register A = the error number on an error.
561A
If the NZ FLAG is set (an error), GOSUB to 564DH to test bit 7 of the first byte of the control block at Register Pair DE: the NZ FLAG for an open file.
561D
If the NZ FLAG is set (an error on a file), JUMP to 5656H.
561F
PUSH HL E5
Save Register Pair HL (the place in the text) to the stack.
5620
PUSH DE D5
Save Register Pair DE (the control block) to the stack.
5621
GOSUB to 4285H, @KITSK, the hook of the keyboard task.
5624
GOSUB to 5661H to read KFLAG$ (429FH) into Register A, draining the keyboard when BREAK or SHIFT @ was pressed: the NZ FLAG for BREAK.
5627
If the NZ FLAG is set (BREAK), JUMP to 563CH, the LD A,01H inside the LD DE at 563BH, to end the listing.
5629
BIT 1,A CB 4F
Test bit 1 of Register A (KFLAG$), SHIFT @ pressed: the pause.
562B
If the Z FLAG is set (no pause), JUMP to 563AH with Register A = 00H to go on.
562D
GOSUB to 0049H, the ROM's wait for a key, which returns it in Register A.
5630
CP 60H FE 60
Compare Register A against 60H, SHIFT @ again.
5632
If the Z FLAG is set (SHIFT @), LOOP BACK to 562DH to wait for another key.
5634
GOSUB to 5673H to clear bits 0-2 of KFLAG$ (429FH), the keys pressed.
5637
DEC A 3D
DECrement Register A (the key): the Z FLAG for 01H, BREAK.
5638
If the Z FLAG is set (BREAK), JUMP to 563CH, the LD A,01H inside the LD DE at 563BH.
563A
XOR A AF
Load Register A with 00H (XOR A): go on with the text.
563B
LD DE,013EH 11 3E 01
Load Register Pair DE with 013EH, a skip: entered at 563CH the bytes 3EH 01H are LD A,01H (BREAK), and 563EH restores Register Pair DE in both cases.
563E
POP DE D1
Restore Register Pair DE (the control block) from the stack.
563F
POP HL E1
Restore Register Pair HL (the place in the text) from the stack.
5640
CP 01H FE 01
Compare Register A against 01H: the Z FLAG for BREAK (01H from 563CH).
5642
If the Z FLAG is set (BREAK), JUMP to 567EH to end the listing with Break.
5645
INC HL 23
INCrement Register Pair HL to the next byte of the text.
5646
LOOP BACK to 55FDH for the next byte of the text at Register Pair HL.
5648
POP DE D1
Restore Register Pair DE from the stack, as it was on entry.
5649
POP HL E1
Restore Register Pair HL from the stack, as it was on entry.
564A
POP IY FD E1
Restore Index Register IY from the stack, as it was on entry.
564C
RET C9
RETURN to the caller with the text sent and the registers as they were.

564DH - A File or a Device

Tests bit 7 of the first byte of the control block at Register Pair DE, set for an open file: the NZ FLAG for a file, the Z FLAG for a device. Register A and Register Pair BC are kept.

564D
PUSH BC C5
Save Register Pair BC to the stack, to be kept.
564E
PUSH AF F5
Save Register Pair AF (Register A = the error number) to the stack.
564F
LD A,(DE) 1A
Load Register A with the first byte of the control block at Register Pair DE.
5650
LD B,A 47
Copy Register A (the first byte of the control block) into Register B.
5651
POP AF F1
Restore Register Pair AF (Register A = the error number) from the stack.
5652
BIT 7,B CB 78
Test bit 7 of Register B: the NZ FLAG for an open file.
5654
POP BC C1
Restore Register Pair BC from the stack. POP does not change the flags.
5655
RET C9
RETURN to the caller with the NZ FLAG for a file.

5656H - An Error Writing the File

Meant to give the error with @ERROR and end the listing. The CALL 5648H takes 565BH as the saved Register Pair DE, the saved Register Pair DE as Register Pair HL and the saved Register Pair HL as Index Register IY, and returns to the address saved from Index Register IY at 55F6H, a place in the program text: 565BH is not reached.

5656
OR 80H F6 80
OR Register A (the error number) with 80H: bit 7 asks @ERROR to return.
5658
GOSUB to 5648H, meant to restore the registers 55F6H saved: its three POPs and RET use this call's return address and those registers, and it returns to the address saved from Index Register IY.
565B
GOSUB to 4409H, @ERROR, to display the error whose number is in Register A. Not reached, since 5658H does not return here.
565E
JUMP to 568DH to close the listing file and run BASIC/CMD again. Not reached.

5661H - The Keyboard Flags

Loads KFLAG$ (429FH) into Register A; when bit 0 (BREAK) or bit 1 (SHIFT @) is set, the keys waiting are read away with ROM 002BH. Returns the NZ FLAG for BREAK (bit 0). 5673H clears bits 0-2 of KFLAG$; Register Pair AF is kept.

5661
LD A,(429FH) 3A 9F 42
Load Register A with KFLAG$ from 429FH, the keyboard flags: bit 0 BREAK, bit 1 SHIFT @, bit 2 ENTER.
5664
PUSH AF F5
Save Register Pair AF (Register A = KFLAG$) to the stack.
5665
AND 03H E6 03
Keep bits 0 and 1 of Register A (AND 03H): BREAK and SHIFT @.
5667
If the Z FLAG is set (neither), JUMP to 566FH.
5669
GOSUB to 002BH, the ROM's scan of the keyboard: Register A = the key pressed, 00H for none.
566C
OR A B7
OR Register A with itself: the NZ FLAG for a key.
566D
If the NZ FLAG is set (a key was waiting), LOOP BACK to 5669H.
566F
POP AF F1
Restore Register Pair AF (Register A = KFLAG$) from the stack.
5670
BIT 0,A CB 47
Test bit 0 of Register A (KFLAG$), BREAK: the NZ FLAG for BREAK.
5672
RET C9
RETURN to the caller with the NZ FLAG for BREAK and Register A = KFLAG$.
5673
PUSH AF F5
Save Register Pair AF to the stack, to be kept.
5674
LD A,(429FH) 3A 9F 42
Load Register A with KFLAG$ from 429FH, the keyboard flags.
5677
AND F8H E6 F8
Clear bits 0-2 of Register A (AND F8H): BREAK, SHIFT @ and ENTER.
5679
LD (429FH),A 32 9F 42
Store Register A at 429FH, KFLAG$, with the three keys cleared.
567C
POP AF F1
Restore Register Pair AF from the stack, as it was on entry.
567D
RET C9
RETURN to the caller with KFLAG$ cleared and Register Pair AF as it was.

567EH - BREAK

The keys are cleared, the output line is ended, Break is shown on the video, then the listing is closed and BASIC/CMD run again (568DH). The stack of 55F6H is left as it is, since nothing returns.

567E
GOSUB to 5673H to clear bits 0-2 of KFLAG$ (429FH), the keys pressed.
5681
LD HL,578FH 21 8F 57
Point Register Pair HL to 578FH, the text 0DH, the end of the output line.
5684
GOSUB to 55F6H to send the text at Register Pair HL to the listing's output.
5687
LD HL,5795H 21 95 57
Point Register Pair HL to 5795H, the text Break.
568A
GOSUB to 55E4H to point the output at the video's control block (401DH) and send the text at Register Pair HL.

568DH - Back to BASIC

The listing file is closed (5710H), the name BASIC/CMD put in the control block at 4485H and 2AH (an asterisk) over the first byte of the command line at 4225H; @RUN loads BASIC/CMD and runs it with Register Pair HL at 4225H, and BASIC with an asterisk goes back to the program in memory with its variables.

568D
GOSUB to 5710H to close the listing file when the output is a file.
5690
LD HL,56A6H 21 A6 56
Point Register Pair HL to 56A6H, the text BASIC/CMD and 03H.
5693
LD DE,4485H 11 85 44
Point Register Pair DE to 4485H, CFCB$, the control block for the file to run.
5696
PUSH DE D5
Save Register Pair DE (4485H) to the stack, for @RUN.
5697
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the 11 bytes 56A6H-56B0H: the name, its 03H and the first byte of 56B0H.
569A
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (56A6H) to Register Pair DE (4485H): CFCB$ holds BASIC/CMD and 03H.
569C
POP DE D1
Restore Register Pair DE (4485H, the control block) from the stack.
569D
LD HL,4225H 21 25 42
Point Register Pair HL to 4225H, INBUF$, the command line buffer.
56A0
LD (HL),2AH 36 2A
Store 2AH, an asterisk, at Register Pair HL (4225H): the command line of BASIC/CMD starts with it.
56A2
JUMP to 4433H, @RUN, to load the file named at Register Pair DE (BASIC/CMD) and run it with Register Pair HL (4225H) as its command line.
56A5
DEFM "L" 4C
56A5H: 4CH, the letter L before the name; 5690H copies from 56A6H, so no code reads it.
56A6-56AE
DEFM "BASIC/CMD" 42 41 53 49 43 2F 43 4D 44
56A6H-56AEH: the name of the file 568DH runs, copied to CFCB$ (4485H).
56AF
DEFB 03H 03
56AFH: 03H, the end of the name in the control block.

56B0H - Upper Case

Turns the lower case letters (61H-7AH) of the text at Register Pair HL into upper case, up to the first control character; Register Pair AF and Register Pair HL are kept.

56B0
PUSH AF F5
Save Register Pair AF to the stack, to be kept. Its byte F5H is also the eleventh byte 5697H copies to 448FH.
56B1
PUSH HL E5
Save Register Pair HL (the start of the text) to the stack, to be kept.
56B2
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
56B3
CP 20H FE 20
Compare Register A against 20H: the CARRY FLAG for a control character, the end of the text.
56B5
If the CARRY FLAG is set (the end), JUMP to 56C5H.
56B7
CP 61H FE 61
Compare Register A against 61H, the letter a: the CARRY FLAG below it.
56B9
If the CARRY FLAG is set (below a), JUMP to 56C2H: the character is kept.
56BB
CP 7BH FE 7B
Compare Register A against 7BH, the byte after the letter z: the NO CARRY FLAG above z.
56BD
If the NO CARRY FLAG is set (above z), JUMP to 56C2H: the character is kept.
56BF
SUB 20H D6 20
SUBtract 20H from Register A: the lower case letter becomes upper case.
56C1
LD (HL),A 77
Store Register A (the upper case letter) at Register Pair HL.
56C2
INC HL 23
INCrement Register Pair HL to the next character.
56C3
LOOP BACK to 56B2H for the next character of the text at Register Pair HL.
56C5
POP HL E1
Restore Register Pair HL (the start of the text) from the stack.
56C6
POP AF F1
Restore Register Pair AF from the stack, as it was on entry.
56C7
RET C9
RETURN to the caller with Register Pair AF and Register Pair HL as they were.

56C8H - A Line Number as Text

The ROM's LINPRT (0FAFH) without its display: Register Pair HL goes to the ROM's number buffer as text (at 4130H, a space for the sign first, ended by 00H). Returns Register Pair DE at the first digit (4131H); Register Pair HL is kept.

56C8
PUSH HL E5
Save Register Pair HL (the number) to the stack.
56C9
GOSUB to 0A9AH, the ROM: Register Pair HL to 4121H-4122H as an integer, the type at 40AFH = 2.
56CC
XOR A AF
Load Register A with 00H (XOR A): no format for the number.
56CD
GOSUB to 1034H, the ROM: 40D8H = Register A (00H) and a space at 4130H, the sign of the number in the buffer; Register Pair HL returns 4130H.
56D0
OR (HL) B6
OR Register A with the byte at Register Pair HL (the space at 4130H), as the ROM does at 0FB6H before 0FD9H.
56D1
GOSUB to 0FD9H, the ROM's turning of the number into text from 4131H, ended by 00H; Register Pair HL returns 4130H.
56D4
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair DE = 4130H, the sign of the text.
56D5
INC DE 13
INCrement Register Pair DE to 4131H, the first digit.
56D6
POP HL E1
Restore Register Pair HL (the number) from the stack.
56D7
RET C9
RETURN to the caller with Register Pair DE at the digits.

56D8H - The Next Line by Its Text

Moves Index Register IX past the link and the number (4 bytes) and past the text to the 00H after it: Index Register IX = the next line. Then 56E8H: the Z FLAG when the link of the line at Index Register IX is 0000H, the end mark of the program.

56D8
INC IX DD 23
INCrement Index Register IX past the low byte of the link.
56DA
INC IX DD 23
INCrement Index Register IX past the high byte of the link.
56DC
INC IX DD 23
INCrement Index Register IX past the low byte of the line's number.
56DE
INC IX DD 23
INCrement Index Register IX past the high byte of the line's number, to the text.
56E0
LD A,(IX+00H) DD 7E 00
Load Register A with the byte of the text at Index Register IX +00H.
56E3
INC IX DD 23
INCrement Index Register IX to the next byte; the OR below tests the byte loaded into Register A.
56E5
OR A B7
OR Register A with itself: the Z FLAG for the 00H ending the line.
56E6
If the NZ FLAG is set (not the end), LOOP BACK to 56E0H: Index Register IX ends at the next line.
56E8
LD A,(IX+00H) DD 7E 00
Load Register A with the low byte of the link at Index Register IX +00H.
56EB
OR A B7
OR Register A with itself: the NZ FLAG when the low byte is not 00H.
56EC
RET NZ C0
If the NZ FLAG is set (a line), RETURN with the NZ FLAG.
56ED
LD A,(IX+01H) DD 7E 01
Load Register A with the high byte of the link at Index Register IX +01H.
56F0
OR A B7
OR Register A with itself: the Z FLAG when the link is 0000H.
56F1
RET C9
RETURN to the caller with the Z FLAG at the end of the program.

56F2H - Tokens Followed by Line Numbers

Returns the Z FLAG when Register A holds the token of THEN (CAH), ELSE (95H), RESUME (9FH), GOTO (8DH), GOSUB (91H), RUN (8EH) or ERL (C2H). The line numbers after RESTORE, LIST, EDIT and DELETE are not taken.

56F2
CP CAH FE CA
Compare Register A against CAH, the token of THEN.
56F4
RET Z C8
If the Z FLAG is set (THEN), RETURN with the Z FLAG.
56F5
CP 95H FE 95
Compare Register A against 95H, the token of ELSE.
56F7
RET Z C8
If the Z FLAG is set (ELSE), RETURN with the Z FLAG.
56F8
CP 9FH FE 9F
Compare Register A against 9FH, the token of RESUME.
56FA
RET Z C8
If the Z FLAG is set (RESUME), RETURN with the Z FLAG.
56FB
CP 8DH FE 8D
Compare Register A against 8DH, the token of GOTO.
56FD
RET Z C8
If the Z FLAG is set (GOTO), RETURN with the Z FLAG.
56FE
CP 91H FE 91
Compare Register A against 91H, the token of GOSUB.
5700
RET Z C8
If the Z FLAG is set (GOSUB), RETURN with the Z FLAG.
5701
CP 8EH FE 8E
Compare Register A against 8EH, the token of RUN.
5703
RET Z C8
If the Z FLAG is set (RUN), RETURN with the Z FLAG.
5704
CP C2H FE C2
Compare Register A against C2H, the token of ERL.
5706
RET Z C8
If the Z FLAG is set (ERL), RETURN with the Z FLAG.
5707
RET C9
RETURN to the caller with the NZ FLAG: Register A is none of the seven tokens.

5708H - A DOS Error

From @FSPEC or @INIT: the error number in Register A is given to @ERROR with bit 6 (the short message) and bit 7 (return) set, then the listing ends.

5708
OR C0H F6 C0
OR Register A (the error number) with C0H: bit 6 the short message, bit 7 return to the program.
570A
GOSUB to 4409H, @ERROR, to display the error whose number is in Register A.
570D
JUMP to 568DH to close the listing file and run BASIC/CMD again.

5710H - Closing the Listing File

When 5793H holds a letter (41H or above), the output is a file: 5793H is cleared and the control block at 5847H closed with @CLOSE, its result not tested. The video (00H) and a device (2AH) are not closed. After an @INIT error the control block of a file not opened is given to @CLOSE too.

5710
LD A,(5793H) 3A 93 57
Load Register A with the kind of output from 5793H.
5713
CP 41H FE 41
Compare Register A against 41H, the letter A: the CARRY FLAG for the video or a device.
5715
RET C D8
If the CARRY FLAG is set (not a file), RETURN with nothing closed.
5716
XOR A AF
Load Register A with 00H (XOR A), for the kind of output.
5717
LD (5793H),A 32 93 57
Store Register A (00H) at 5793H: the file is not closed twice.
571A
LD DE,5847H 11 47 58
Point Register Pair DE to 5847H, the control block of the listing file.
571D
GOSUB to 4428H, @CLOSE, to close the file whose control block is at Register Pair DE.
5720
RET C9
RETURN to the caller; the result of @CLOSE is not tested.

5721H - The Texts and the Work Cells

The title buffer with the form feed before it, the heading, the pieces of the rule line, the kind of output and the count of lines, the messages, the default extension and the banner. Every text sent by 55F6H ends with 00H; the banner is shown with @DSPLY and ends with 0DH. The cells from 581CH on, the control block at 5847H and the buffer at 5900H are not in the file.

5721
DEFB 0CH 0C
5721H: 0CH, a form feed, sent before the title at each new page (54C3H).
5722
DEFB 00H 00
5722H: the first byte of the title buffer, 00H for no title (5578H); 55C9H copies the title here with 0DH and 00H after it.
5723-575E
DEFB 20H x 60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5723H-575EH: the rest of the title buffer, spaces in the file; a title of up to 58 characters and its 0DH and 00H end at 575DH at most.
575F
DEFB 00H 00
575FH: 00H, the last byte of the title buffer.
5760
DEFB 0DH 0D
5760H: 0DH, a new line before the heading (5264H, 54C9H).
5761-5788
DEFM " Ref Line Numbers" 20 20 52 65 66 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4C 69 6E 65 20 4E 75 6D 62 65 72 73
5761H-5788H: the heading over the reference column and the line numbers.
5789
DEFB 00H 00
5789H: 00H, the end of the heading for 55F6H.
578A-578B
DEFM "-" / DEFB 00H 2D 00
578AH-578BH: a minus sign and 00H, sent five times by 54E1H in the rule line.
578C-578D
DEFM "+" / DEFB 00H 2B 00
578CH-578DH: a plus sign and 00H, the left corner of the rule line (54D9H).
578E
DEFM "+" 2B
578EH: a plus sign, the right corner of the rule line (54EBH), followed by the 0DH at 578FH.
578F-5790
DEFB 0DH,00H 0D 00
578FH-5790H: 0DH and 00H, a new line, sent by 5246H, 54B1H, 54D3H and 5681H.
5791-5792
DEFB 0CH,00H 0C 00
5791H-5792H: 0CH and 00H, the form feed at the end of the listing (5357H).
5793
DEFB 00H 00
5793H: the kind of output: 00H the video, 2AH a device, a letter a file (523DH); read at 524CH and 5710H.
5794
DEFB 00H 00
5794H: the count of lines on the page: up by one for each 0DH sent, 00H after a 0CH (55F6H); read at 54AEH and 54B9H.
5795-579A
DEFM "Break" / DEFB 00H 42 72 65 61 6B 00
5795H-579AH: the text shown on the video by 5687H after BREAK.
579B-579D
DEFM "TXT" 54 58 54
579BH-579DH: the default extension of the listing file, for @FEXT (5231H).
579E-579F
DEFB 1CH,1FH 1C 1F
579EH-579FH: the start of the banner (5209H): 1CH puts the cursor home, 1FH clears the screen from there.
57A0-57D4
DEFM "BASIC Cross Reference Listing Utility - Version 1.22" / DEFB 0AH 42 41 53 49 43 20 43 72 6F 73 73 20 52 65 66 65 72 65 6E 63 65 20 4C 69 73 74 69 6E 67 20 55 74 69 6C 69 74 79 20 2D 20 56 65 72 73 69 6F 6E 20 31 2E 32 32 0A
57A0H-57D4H: the first line of the banner and 0AH, a line feed.
57D5-580A
DEFM "Copyright 1987 by MISOSYS, Inc., All rights reserved" / DEFB 0DH 43 6F 70 79 72 69 67 68 74 20 31 39 38 37 20 20 62 79 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64 0D
57D5H-580AH: the second line of the banner and 0DH, the end of the banner.
580B-581B
DEFB 0DH / DEFM "Out of memory." / DEFB 0DH,00H 0D 4F 75 74 20 6F 66 20 6D 65 6D 6F 72 79 2E 0D 00
580BH-581BH: the text of 554CH when the list of line numbers reaches the bottom of string space.
581C-5823
DEFS 8
581CH-5823H: not in the file. The last entry listed: seven characters and 00H, spaces at the start (526DH); copied from 5824H by 5303H.
5824-582B
DEFS 8
5824H-582BH: not in the file. The lowest entry of the pass above the last one listed (FFH x 7 at the start of each pass, 5285H), or the entry named after an equals sign (5570H).
582C-5833
DEFS 8
582CH-5833H: not in the file. The entry the scanner took last (5295H, 538AH).
5834-583B
DEFS 8
5834H-583BH: not in the file. The field of seven characters being sent: the reference column between colons, or a line number (54FAH).
583C-583D
DEFS 2
583CH-583DH: not in the file. The pointer into the list of line numbers, 5 bytes above the end of the arrays at the start (5515H).
583E-583F
DEFS 2
583EH-583FH: not in the file. The last line number read from the list, for passing over repeats (5555H).
5840
DEFS 1
5840H: not in the file. The found flag: 01H when the pass found an entry to list (52EAH).
5841
DEFS 1
5841H: not in the file. The count of the fields sent on the output line (54F6H, 54FAH).
5842
DEFS 1
5842H: not in the file. The line number list flag: 01H after a line number, so the next call of the scanner looks for another (5440H).
5843
DEFS 1
5843H: not in the file. The letter after a minus sign: V for the names only, L for the line numbers only (558CH).
5844
DEFS 1
5844H: not in the file. The named flag: 01H after an equals sign with a name or a line number (55BAH).
5845-5846
DEFS 2
5845H-5846H: not in the file. The pointer to the options in the command line (5213H, 5229H), read at 5258H.
5847-5866
DEFS 32
5847H-5866H: not in the file. The control block of the listing's device or file (@FSPEC, @INIT, @CLOSE); bit 7 of 5847H is set while a file is open.
5900-59FF
DEFS 256
5900H-59FFH: not in the file. The buffer of the listing file (5237H).