50FE
XOR A AF
Load Register A with 00H (XOR A with itself).
50FF
LD (4288H),A 32 88 42
Store Register A (00H) at 4288H, SYS0/SYS's slot of the overlay in 4D00H-51FFH: the next RST 28H for SYS13/SYS reads it from the diskette again, with the default parameters at 4D00H-4D0BH.
5102
LD BC,4D00H 01 00 4D
Load Register Pair BC with 4D00H, the address of the first parameter (the first new line number).
5105
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the first character after RENUM.
5106
OR A B7
OR Register A (that character) with itself to set the flags: the Z FLAG is set for 00H, the end of the line.
5107
If the Z FLAG is set (RENUM with nothing after it), JUMP to 5130H for SYNTAX ERROR.
5109
LD A,04H 3E 04
Load Register A with 04H, the number of parameters that may be given.
PARAMETER LOOP
Register Pair BC = the parameter's address (4D00H, 4D02H, 4D04H, 4D06H), Register Pair HL = the text; the count is kept in the alternate Register A'.
510B
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': the count of parameters left goes to Register A'.
510C
DEC HL 2B
Decrement Register Pair HL, the text pointer, so that the RST 10H that follows reads the current character again.
510D
RST 10H D7
RST 10H: step Register Pair HL to the next character that is not a space and load it into Register A; the CARRY FLAG is set for a digit.
510E
If the CARRY FLAG is set (Register A is a digit: a number), JUMP to 5116H.
5110
CP 2CH FE 2C
Compare Register A (the character) against 2CH, a comma: this parameter is left out and keeps its default.
5112
If the Z FLAG is set (a comma), JUMP to 5126H to pass it and go on with the next parameter.
5114
Anything else: JUMP to 5139H to look for the options U and X.
5116
GOSUB to ROM 1E5AH (LINGET), which reads the decimal number at Register Pair HL into Register Pair DE and returns Register Pair HL after it.
5119
LD A,E 7B
Load Register A with Register E, the low byte of the number read.
511A
LD (BC),A 02
Store Register A (the number's low byte) at Register Pair BC, the parameter's low byte.
511B
INC BC 03
Increment Register Pair BC to the parameter's high byte.
511C
LD A,D 7A
Load Register A with Register D, the high byte of the number read.
511D
LD (BC),A 02
Store Register A (the number's high byte) at Register Pair BC, the parameter's high byte.
511E
DEC BC 0B
Decrement Register Pair BC back to the parameter's low byte.
511F
OR E B3
OR Register A (the number's high byte) with Register E (its low byte): the Z FLAG is set if the number is 0.
5120
If the Z FLAG is set (a 0 was given), JUMP to 5130H for SYNTAX ERROR.
5122
DEC HL 2B
Decrement Register Pair HL, the text pointer, so that the RST 10H that follows reads the character after the number again.
5123
RST 10H D7
RST 10H: step Register Pair HL to that character and load it into Register A; the Z FLAG is set at the end of the statement.
5124
If the Z FLAG is set (nothing follows the number), JUMP to 5148H to check the parameters.
5126
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: the character at Register Pair HL must be a comma, else the ROM gives SYNTAX ERROR; RST 08H then steps Register Pair HL to the next character, in Register A.
5128
INC BC 03
Increment Register Pair BC, 1 of 2, towards the next parameter.
5129
INC BC 03
Increment Register Pair BC, 2 of 2: Register Pair BC = the next parameter's address.
512A
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the count of parameters left.
512B
DEC A 3D
Decrement Register A, the count of parameters that may still be given.
512C
If the NZ FLAG is set (Register A is not 0: another number may follow), LOOP back to 510BH.
512E
After four parameters: JUMP to 5139H to look for the options.
5130
JUMP to ROM 1997H (SNERR, error code 02H) for SYNTAX ERROR.
5133
LD (DE),A 12
Store Register A (the option letter, 55H U or 58H X) at Register Pair DE, 4D0AH or 4D0BH: the option is on.
5134
RST 10H D7
RST 10H: step Register Pair HL past the letter and load the next character into Register A; the Z FLAG is set at the end of the statement.
5135
If the Z FLAG is set (the end), JUMP to 5148H to check the parameters.
5137
RST 08H => 2CH CF 2C
RST 08H with the byte 2CH: a comma must follow the option, else SYNTAX ERROR; Register Pair HL is stepped to the next character.
5139
LD DE,4D0AH 11 0A 4D
Load Register Pair DE with 4D0AH, the byte of option U.
513C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the character at the text pointer.
513D
CP 55H FE 55
Compare Register A (the character) against 55H, the letter U.
513F
If the Z FLAG is set (U), JUMP to 5133H to store it at 4D0AH (Register Pair DE).
5141
LD DE,4D0BH 11 0B 4D
Load Register Pair DE with 4D0BH, the byte of option X.
5144
CP 58H FE 58
Compare Register A (the character) against 58H, the letter X.
5146
If the Z FLAG is set (X), JUMP to 5133H to store it at 4D0BH (Register Pair DE).
5148
OR A B7
OR Register A (the character at the text pointer) with itself to set the flags: the Z FLAG is set for 00H, the end of the line.
5149
If the NZ FLAG is set (something else follows), JUMP to 5130H for SYNTAX ERROR.
514B
LD DE,(4D04H) ED 5B 04 4D
Load Register Pair DE with the 16-bit value at 4D04H, the first old line number of the range.
514F
LD HL,(4D06H) 2A 06 4D
Load Register Pair HL with the 16-bit value at 4D06H, the last old line number of the range.
5152
RST 18H DF
RST 18H: compare Register Pair HL (the range's last line) with Register Pair DE (its first line). The CARRY FLAG is set if the last is below the first.
5153
If the CARRY FLAG is set (the range is upside down), JUMP to 5130H for SYNTAX ERROR.
5155
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the range's last line.
5156
LD HL,FFF9H 21 F9 FF
Load Register Pair HL with FFF9H (65529), the highest line number allowed.
5159
RST 18H DF
RST 18H: compare Register Pair HL (65529) with Register Pair DE (the range's last line). The CARRY FLAG is set if the last line is above 65529.
515A
If the CARRY FLAG is set, JUMP to 5130H for SYNTAX ERROR.
515C
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the count of program lines.
515F
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the 16-bit value at 40A4H, the ROM's pointer to the first program line.
LINE LOOP
Register Pair HL = the line, Register Pair BC = the lines counted; the new number goes into the line's link field.
5162
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the line's link field (the address of the next line).
5163
INC HL 23
Increment Register Pair HL to the high byte of the line's link field.
5164
LD D,(HL) 56
Load Register D with the byte at Register Pair HL. Register Pair DE = the next line's address.
5165
LD A,D 7A
Load Register A with Register D, the high byte of the link.
5166
OR E B3
OR Register A with Register E, the low byte: the Z FLAG is set for 0000H, the end marker.
5167
If the Z FLAG is set (every line is done), JUMP to 51B5H with Register A = 00H.
5169
PUSH DE D5
Save Register Pair DE (the next line's address from the link) on the stack.
516A
INC BC 03
Increment Register Pair BC, the count of program lines.
516B
LD A,(4D0AH) 3A 0A 4D
Load Register A with the byte at 4D0AH, option U.
516E
OR A B7
OR Register A (option U) with itself to set the flags: the NZ FLAG is set if U was given.
516F
If the NZ FLAG is set (U: the program is only checked, the links stay), JUMP to 51A9H.
5171
PUSH HL E5
Save Register Pair HL (the address of the link field's high byte) on the stack.
5172
INC HL 23
Increment Register Pair HL to the low byte of the line's number.
5173
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the line's number.
5174
INC HL 23
Increment Register Pair HL to the high byte of the line's number.
5175
LD D,(HL) 56
Load Register D with the byte at Register Pair HL. Register Pair DE = the line's old number.
5176
LD A,D 7A
Load Register A with Register D, the high byte of the old number.
5177
OR E B3
OR Register A with Register E, the low byte: the Z FLAG is set for line 0.
5178
LD A,96H 3E 96
Load Register A with 96H, BASIC's error code for Can't Process Line 0. LD does not change the flags.
517A
If the Z FLAG is set (a line 0), JUMP to BASIC 5DE2H, which rebuilds the links (ROM 1AF8H), clears the variables (ROM 1B59H) and gives the error in Register A.
517D
LD HL,(4D04H) 2A 04 4D
Load Register Pair HL with the 16-bit value at 4D04H, the first old line number of the range.
5180
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the line's old number, Register Pair DE = the range's first line.
5181
RST 18H DF
RST 18H: compare Register Pair HL (the old number) with Register Pair DE (the range's first line). The CARRY FLAG is set if the line lies below the range.
5182
EX DE,HL EB
Exchange Register Pairs DE and HL back: Register Pair DE = the line's old number (EX does not change the flags).
5183
If the CARRY FLAG is set (below the range), JUMP to 51A4H: the line keeps its number, Register Pair DE.
5185
LD HL,(4D06H) 2A 06 4D
Load Register Pair HL with the 16-bit value at 4D06H, the last old line number of the range.
5188
RST 18H DF
RST 18H: compare Register Pair HL (the range's last line) with Register Pair DE (the old number). The CARRY FLAG is set if the line lies above the range.
5189
If the CARRY FLAG is set (above the range), JUMP to 51A4H: the line keeps its number.
518B
LD HL,(4D00H) 2A 00 4D
Load Register Pair HL with the 16-bit value at 4D00H, the next new line number.
518E
LD (4D08H),HL 22 08 4D
Store Register Pair HL (the new number) at 4D08H, the new number of the last line of the range so far, for SYS11/SYS.
5191
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the line's new number.
5192
LD HL,FFF9H 21 F9 FF
Load Register Pair HL with FFF9H (65529), the highest line number allowed.
5195
RST 18H DF
RST 18H: compare Register Pair HL (65529) with Register Pair DE (the new number). The CARRY FLAG is set if the new number is above 65529.
5196
LD A,8CH 3E 8C
Load Register A with 8CH, BASIC's error code for Seq # Overflow (51A2H enters here). LD does not change the flags.
5198
If the CARRY FLAG is set (the new number is too high), JUMP to BASIC 5DE2H to rebuild the links and give the error in Register A.
519B
LD HL,(4D02H) 2A 02 4D
Load Register Pair HL with the 16-bit value at 4D02H, the increment.
519E
ADD HL,DE 19
Add Register Pair DE (the new number) to Register Pair HL (the increment): the number for the next line in the range.
519F
LD (4D00H),HL 22 00 4D
Store Register Pair HL at 4D00H, the next new line number.
51A2
If the CARRY FLAG is set (the addition passed 65535), JUMP to 5196H for Seq # Overflow.
51A4
POP HL E1
Restore Register Pair HL from the stack: the address of the link field's high byte, saved at 5171H.
51A5
LD (HL),D 72
Store Register D (the high byte of the line's new or kept number) at Register Pair HL, the link field's high byte.
51A6
DEC HL 2B
Decrement Register Pair HL to the link field's low byte.
51A7
LD (HL),E 73
Store Register E (the low byte of the number) at Register Pair HL: the link field now holds the line's number for SYS11/SYS.
51A8
INC HL 23
Increment Register Pair HL back to the link field's high byte.
51A9
GOSUB to BASIC 5CCCH with Register Pair HL at the link field's high byte: it steps past the line number and scans the text to the byte after its 00H end, returning Register Pair HL at the next line.
51AC
POP DE D1
Restore Register Pair DE from the stack: the next line's address from the old link, saved at 5169H.
51AD
RST 18H DF
RST 18H: compare Register Pair HL (where the line really ends) with Register Pair DE (where its link said). The Z FLAG is set if they agree.
51AE
If the Z FLAG is set, LOOP back to 5162H for the next line at Register Pair HL.
51B0
LD A,72H 3E 72
Load Register A with 72H, BASIC's error code for Dos Error: a link does not match its line.
51B2
JUMP to BASIC 5DE2H to rebuild the links and give the error in Register A.
51B5
LD H,B 60
Load Register H with Register B, the high byte of the count of program lines.
51B6
LD L,C 69
Load Register L with Register C, the low byte. Register Pair HL = the count of program lines.
51B7
LD C,A 4F
Load Register C with Register A (00H, from the OR at 5166H that found the end marker).
51B8
LD DE,0080H 11 80 00
Load Register Pair DE with 0080H (128), the number of entries in SYS11/SYS's line table.
LINES PER ENTRY
Register C counts how many times 128 goes into the number of lines, rounded up, at least 1.
51BB
INC C 0C
Increment Register C, one more line per table entry.
51BC
SBC HL,DE ED 52
Subtract Register Pair DE (128) and the CARRY FLAG (clear from the OR at 5166H, then from the previous subtraction) from Register Pair HL, the lines left.
51BE
If the Z FLAG is set (the lines are used up exactly), JUMP to 51C2H.
51C0
If the NO CARRY FLAG is set (lines are left), LOOP back to 51BBH. Register C = the lines per table entry.
51C2
LD DE,64A3H 11 A3 64
Load Register Pair DE with 64A3H, the address of SYS11/SYS's line table (BASIC/CMD's initialization code, used as the input buffer).
51C5
LD B,80H 06 80
Load Register B with 80H (128), the number of table entries.
51C7
LD HL,(40A4H) 2A A4 40
Load Register Pair HL with the 16-bit value at 40A4H, the ROM's pointer to the first program line.
51CA
LD A,2DH 3E 2D
Load Register A with 2DH, the RST 28H code of SYS11/SYS (slot 0DH), function 1.
51CC
RST 28H EF
RST 28H with Register A = 2DH: SYS11/SYS is loaded at 4D0CH-51F3H over this code and goes on with RENUM; it does not come back here.