4D00H - Load Entry
BASIC loads SYS10 with LD A,2CH / RST 28H (BASIC 6131H). The SYS0 dispatcher (4BC2H) has already dropped the RST's own return address and calls 4D00H with the return to 4C20H on top of the stack. SYS10 discards that word, so the RET goes straight back to the caller of 6131H: BASIC then jumps to 4D03H (from 612EH), or simply carries on when 6131H only reloaded SYS10 after a DOS call. Because 4C20H is skipped, 4369H bit 6 stays set; BASIC clears it at the end of the statement (6461H).
4D00
INC SP 33
Increment the Stack Pointer SP past the low byte of the return address into SYS0 4C20H, discarding it.
4D01
INC SP 33
Increment the Stack Pointer SP past the high byte: the word at the top of the stack is now the return address into the caller of BASIC 6131H.
4D02
RET C9
RETURN to the caller of BASIC 6131H; the SYS10 code is now in memory at 4D00H-51E7H.
4D03H - GET and PUT
Entered by JP 4D03H at BASIC 612EH. BASIC's GET (6126H, vector 417FH) and PUT (6125H, vector 4182H) push Register Pair AF with the Z FLAG set for GET and clear for PUT, read the file number through 5F7AH, copy the file area's 2DH-byte header to 5700H-572CH (Index Register IX = 5700H; 570DH-572CH is the file's FCB) and clear the statement flags at 572DH (IX+2DH). Register Pair HL is the BASIC text pointer after the file number. The statement is GET f / PUT f, optionally followed by a position (a record number, or one of the characters * # $ % & !) and an item list (see 4F18H).
4D03
LD A,01H 3E 01
Load Register A with 01H, the value for BASIC's reload flag.
4D05
LD (624DH),A 32 4D 62
Self-Modifying Code
Store Register A (01H) at 624DH, the operand of BASIC's LD A,nn at 624CH: from now on BASIC reloads SYS10 (through 6131H) after every DOS call it makes, since a DOS call may bring another overlay into 4D00H.
4D08
POP AF F1
Restore Register Pair AF from the stack: the GET/PUT flag BASIC pushed, the Z FLAG set for GET and clear for PUT.
4D09
LD DE,(5700H) ED 5B 00 57
Load Register Pair DE with the 16-bit value at 5700H: E = the file's mode byte (5700H), D = the second mode byte (5701H).
4D0D
RES 4,E CB A3
Clear bit 4 of Register E, the mode byte's PUT bit (bit 4 = this statement is a PUT). RES does not change the flags.
4D0F
If the Z FLAG is set (a GET), JUMP to 4D13H with bit 4 of Register E clear.
4D11
SET 4,E CB E3
It is a PUT: set bit 4 of Register E, the mode byte.
4D13
LD (IX+00H),E DD 73 00
Store Register E (the mode byte with bit 4 = PUT) at Index Register IX+00H, the mode byte at 5700H.
4D16
CALL 638FH CD 8F 63
GOSUB to BASIC 638FH with Register Pair HL = the text pointer: the Z FLAG is set if the statement ends here; otherwise it requires a comma and returns the NZ FLAG with Register A = the character after it.
4D19
If the Z FLAG is set (the statement ends after the file number), JUMP to 4D1FH: no position given.
4D1B
CP 2CH FE 2C
Compare Register A (the character after the comma) against 2CH, a second comma: no position given, an item list follows.
4D1D
If the NZ FLAG is set (not a comma), JUMP to 4D5AH to read the position.
4D1F
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack.
4D20
CALL 61D3H CD D3 61
GOSUB to BASIC 61D3H, which returns Register C and Register Pair HL = the file's current position NEXT (FCB+5 at 5712H, FCB+10/11 at 5717H-5718H): C the low byte, L the middle, H the high byte.
4D23
BIT 6,D CB 72
Test bit 6 of Register D (the second mode byte, 5701H), set once a GET or PUT has stored a record start at 5707H-5709H.
4D25
If the Z FLAG is set (no record start yet), JUMP to 4D36H and use NEXT in Register C and Register Pair HL.
4D27
CALL 6149H CD 49 61
GOSUB to BASIC 6149H, which returns Register C and Register Pair HL = the position where the last GET or PUT ended (5704H-5706H).
4D2A
BIT 3,E CB 5B
Test bit 3 of Register E, the mode byte: set for item files of the second letter U or F, and for the plain random file.
4D2C
If the Z FLAG is set (second letter I), JUMP to 4D36H: continue where the last statement ended.
4D2E
BIT 2,E CB 53
Test bit 2 of Register E, the mode byte: set for fixed-length records (second letter F, and the plain random file).
4D30
If the Z FLAG is set (type MU), JUMP to 4E48H.
4D33
CALL 6065H CD 65 60
Fixed-length records: GOSUB to BASIC 6065H, which returns Register C and Register Pair HL = the last record start (5707H-5709H) plus the record length (5702H-5703H): the next record.
4D36
CALL 6173H CD 73 61
GOSUB to BASIC 6173H, which checks the mode byte in Register E allows the statement (bit 7 = random, then bit 5 for GET or bit 6 for PUT), else error 6CH BAD FILE MODE.
4D39
CALL 613EH CD 3E 61
GOSUB to BASIC 613EH, which stores Register C and Register Pair HL as the record start (5707H-5709H) and sets bit 6 of 5701H.
4D3C
BIT 4,E CB 63
Test bit 4 of Register E, the mode byte's PUT bit.
4D3E
CALL NZ,6185H C4 85 61
If the NZ FLAG is set (a PUT), GOSUB to BASIC 6185H: a position (Register C and Register Pair HL) at or past the end of file sets bit 4 of 572DH; past it, the file must have fixed-length records (else error A6H BAD FILE POSITIONING PARAM) and an item file is padded with records of 00H bytes up to the position.
4D41
LD A,(5700H) 3A 00 57
Load Register A with the byte at 5700H, the mode byte.
4D44
AND 0FH E6 0F
Mask Register A against 0FH (0000 1111) to keep the file type in bits 0-3.
4D46
CP 09H FE 09
Compare Register A (the file type) against 09H, type MU.
4D48
If the Z FLAG is set (type MU), JUMP to 4E9AH.
4D4B
LD (570BH),HL 22 0B 57
Store Register Pair HL (the position's middle and high bytes) at 570BH-570CH, where this statement started.
4D4E
LD (IX+0AH),C DD 71 0A
Store Register C (the position's low byte) at Index Register IX+0AH, 570AH.
4D51
GOSUB to BASIC 6137H, which stores Register C and Register Pair HL at 5704H-5706H as well, the position of the last GET or PUT.
4D54
GOSUB to BASIC 61CDH, which positions the file to Register C / L / H (SYS0 444EH through the FCB at 570DH).
4D57
JUMP to 4EBEH for the transfer, with the file positioned at Register C / L / H.
4D5AH - The Position Characters
Register A holds the first character of the position parameter and Register Pair HL points at it. * continues at the position where the last GET or PUT ended, # uses the last record start again, $ the position where the last statement started, % formats string variables to their item lengths without any file access, & writes the buffer (&& also the end of file), ! takes a byte position. Anything else is a record number (4E5FH).
4D5A
INC HL 23
Increment Register Pair HL, the text pointer, past the character.
4D5B
PUSH HL E5
Save Register Pair HL (the text pointer after the character) on the stack.
4D5C
CP CFH FE CF
Compare Register A (the character) against CFH, the * token.
4D5E
If the NZ FLAG is set (not *), JUMP to 4D75H.
4D60
BIT 3,E CB 5B
Test bit 3 of Register E, the mode byte (item files of the second letter U or F, and the plain random file).
4D62
If the Z FLAG is set, JUMP to 4D20H and treat the statement as having no position.
4D64
BIT 6,D CB 72
Test bit 6 of Register D (5701H): set if a record start is known.
4D66
If the Z FLAG is set (no record start), JUMP to 4D20H as well.
4D68
LD A,(5700H) 3A 00 57
Load Register A with the byte at 5700H, the mode byte.
4D6B
AND 03H E6 03
Mask Register A against 03H (0000 0011) to keep bits 0-1, the item file letters M and F.
4D6D
If the Z FLAG is set (not an item file), JUMP to 4E06H for error A6H BAD FILE POSITIONING PARAM.
4D70
CALL 6149H CD 49 61
GOSUB to BASIC 6149H, which returns Register C and Register Pair HL = the position where the last GET or PUT ended.
4D73
JUMP to 4D8EH to check the mode with that position.
4D75
CP 23H FE 23
Compare Register A (the character) against 23H, a #.
4D77
If the NZ FLAG is set (not #), JUMP to 4D81H.
4D79
CALL 6150H CD 50 61
GOSUB to BASIC 6150H, which returns Register C and Register Pair HL = the last record start; error 6CH BAD FILE MODE if bit 6 of 5701H is clear.
4D7C
CALL 6173H CD 73 61
GOSUB to BASIC 6173H to check the mode byte in Register E for GET or PUT.
4D7F
JUMP to 4D41H to go on with the position in Register C and Register Pair HL.
4D81
CP 24H FE 24
Compare Register A (the character) against 24H, a $.
4D83
If the NZ FLAG is set (not $), JUMP to 4D93H.
4D85
LD C,(IX+0AH) DD 4E 0A
Load Register C with the byte at Index Register IX+0AH (570AH), the low byte of the position where the last statement started.
4D88
LD HL,(570BH) 2A 0B 57
Load Register Pair HL with the 16-bit value at 570BH, the middle and high bytes of that position.
4D8B
GOSUB to BASIC 6156H: error 6CH BAD FILE MODE if bit 6 of 5701H is clear (no statement has run yet).
4D8E
CALL 6173H CD 73 61
GOSUB to BASIC 6173H to check the mode byte in Register E for GET or PUT.
4D91
JUMP to 4D4BH to store the position in Register C and Register Pair HL and position the file.
4D93
CP 25H FE 25
Compare Register A (the character) against 25H, a %.
4D95
If the NZ FLAG is set (not %), JUMP to 4DA1H.
4D97
LD (IX+00H),A2H DD 36 00 A2
Store A2H at Index Register IX+00H, the working copy's mode byte (5700H): random (bit 7), GET allowed (bit 5), type letter F (bit 1), not a PUT. The file area keeps its own mode byte because the copy is not written back (51C3H).
4D9B
SET 5,(IX+2DH) DD CB 2D EE
Set bit 5 of the byte at Index Register IX+2DH (572DH, the statement flags): the item list only formats string variables (501DH).
4D9F
JUMP to 4D57H, then 4EBEH, without positioning the file.
4DA1
POP HL E1
Restore Register Pair HL from the stack: the text pointer after the character.
4DA2
CP 26H FE 26
Compare Register A (the character) against 26H, an &.
4DA4
If the NZ FLAG is set (not &), JUMP to 4DBCH.
4DA6
BIT 4,(IX+0EH) DD CB 0E 66
Test bit 4 of the byte at Index Register IX+0EH (570EH, FCB+1): set when the sector buffer has been changed.
4DAA
CALL NZ,625EH C4 5E 62
If the NZ FLAG is set (changed), GOSUB to BASIC 625EH to write the buffer (SYS0 443CH, write with verify).
4DAD
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the next character of the statement.
4DAE
CP 26H FE 26
Compare Register A (the next character) against 26H, a second &.
4DB0
If the NZ FLAG is set (a single &), JUMP to 51BEH to end the statement.
4DB3
LD DE,4451H 11 51 44
Load Register Pair DE with 4451H, the SYS0 vector that writes the end of file into the directory.
4DB6
GOSUB to BASIC 6245H, which calls the vector in Register Pair DE with the FCB at 570DH (errors are handled through BASIC 5E16H).
4DB9
JUMP to 51BFH to end the statement with Register Pair HL = the text pointer.
4DBC
CP 21H FE 21
Compare Register A (the character) against 21H, a !.
4DBE
If the NZ FLAG is set (not !), JUMP to 4E5FH: a record number.
4DC1
LD B,00H 06 00
Load Register B with 00H, the kind: plain ! (GET or PUT at a byte position).
4DC3
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the character after the !.
4DC4
CP 25H FE 25
Compare Register A (the character after the !) against 25H, a %.
4DC6
If the Z FLAG is set (!%), JUMP to 4E37H: the position is the end of file.
4DC8
CP 24H FE 24
Compare Register A (the character after the !) against 24H, a $.
4DCA
If the NZ FLAG is set (not $), JUMP to 4DD5H.
4DCC
INC B 04
Increment Register B to 01H, the kind: !$ only positions the file.
4DCD
INC HL 23
Increment Register Pair HL, the text pointer, past the $.
4DCE
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the next character.
4DCF
CP 25H FE 25
Compare Register A (the character after the $) against 25H, a %.
4DD1
If the Z FLAG is set (!$%), JUMP to 4E37H to position at the end of file.
4DD3
JUMP to 4DE0H to read the position with Register B = 01H.
4DD5
CP 23H FE 23
Compare Register A (the character after the !) against 23H, a #.
4DD7
If the NZ FLAG is set (not #), JUMP to 4DE0H with Register B = 00H.
4DD9
BIT 6,E CB 73
Test bit 6 of Register E, the mode byte: set if the file may be written.
4DDB
If the Z FLAG is set (read only), JUMP to 4E06H for error A6H BAD FILE POSITIONING PARAM.
4DDD
INC HL 23
Increment Register Pair HL, the text pointer, past the #.
4DDE
INC B 04
Increment Register B (the kind) to 01H; 4DDFH makes it 02H.
4DDF
INC B 04
Increment Register B to 02H, the kind: !# sets the end of file.
4DE0
PUSH BC C5
Save Register Pair BC on the stack: Register B = the kind (00H !, 01H !$, 02H !#).
4DE1
JP 6648H C3 48 66
JUMP to BASIC 6648H, which evaluates the expression at Register Pair HL (61B7H), comes back to 4DE4H to convert the value and then jumps to 4E17H.
4DE4H - Convert the Position Value
Entered by JP 4DE4H at BASIC 6655H, after 61B7H has evaluated an expression (the Z FLAG set if it is a string) and left the text pointer on the stack. Returns the value as a 24-bit number in Register C (low), Register L and Register H (high), with any fraction dropped. A string, a negative value or a value of 224 or more gives error A6H BAD FILE POSITIONING PARAM.
4DE4
If the Z FLAG is set (the value is a string), JUMP to 4E06H for error A6H.
4DE6
LD BC,(4121H) ED 4B 21 41
Load Register Pair BC with the 16-bit value at 4121H, REG 1's low bytes: an integer (C low, B high), or the low (C) and middle (B) mantissa bytes.
4DEA
LD DE,(4123H) ED 5B 23 41
Load Register Pair DE with the 16-bit value at 4123H: E = the high mantissa byte (bit 7 the sign), D = the exponent (4124H).
4DEE
LD A,D 7A
Load Register A with Register D, the exponent.
4DEF
LD L,B 68
Load Register L with Register B, the middle byte (the high byte of an integer).
4DF0
LD H,00H 26 00
Load Register H with 00H, the high byte for an integer.
4DF2
If the SIGN FLAG is set (from the type test: an integer), JUMP to 4E12H with the value in Register C and Register Pair HL.
4DF5
OR A B7
OR Register A (the exponent) with itself to set the flags: the Z FLAG is set for an exponent of 0, the value 0.
4DF6
If the NZ FLAG is set (not zero), JUMP to 4DFCH.
4DF8
LD C,A 4F
The value is 0: load Register C with Register A (00H).
4DF9
LD L,A 6F
Load Register L with Register A (00H); Register H is already 00H.
4DFA
RET C9
RETURN with the value 0 in Register C and Register Pair HL.
4DFB
DEFB 00H 00
Unreferenced 00H byte between the RET at 4DFAH and the code at 4DFCH; nothing jumps to it.
4DFC
LD H,E 63
Load Register H with Register E, the high mantissa byte.
4DFD
LD B,E 43
Load Register B with Register E as well: its bit 7 is the sign, tested at 4E12H.
4DFE
SET 7,H CB FC
Set bit 7 of Register H to put back the mantissa's implied top bit (the sign bit's place).
4E00
SUB 98H D6 98
Subtract 98H from Register A (the exponent): 98H means the 24-bit mantissa in Register H / L / C is already an integer.
4E02
If the Z FLAG is set (exponent 98H), JUMP to 4E12H.
4E04
If the CARRY FLAG is set (exponent below 98H), JUMP to 4E09H to shift the fraction out.
4E06
JP 5E03H C3 03 5E
JUMP to BASIC 5E03H for error A6H BAD FILE POSITIONING PARAM (here: the value is 224 or more).
SHIFT OUT THE FRACTION
Register H / L / C = the mantissa, Register A counts up from (exponent - 98H) to 0.
4E09
SRL H CB 3C
Shift Register H (the high byte) right, bit 0 into the CARRY FLAG.
4E0B
RR L CB 1D
Rotate Register L (the middle byte) right through the CARRY FLAG.
4E0D
RR C CB 19
Rotate Register C (the low byte) right through the CARRY FLAG; the bit shifted out is dropped.
4E0F
INC A 3C
Increment Register A, the shift count, towards 0 (an exponent of 98H).
4E10
If the NZ FLAG is set (more shifts), LOOP back to 4E09H.
4E12
BIT 7,B CB 78
Test bit 7 of Register B, the sign (of the integer's high byte, or of the mantissa).
4E14
If the NZ FLAG is set (the value is negative), JUMP to 4E06H for error A6H.
4E16
RET C9
RETURN to BASIC 664CH with the value in Register C, Register L and Register H.
4E17H - Apply the ! Position
Entered by JP 4E17H at BASIC 664CH with the position in Register C, Register L and Register H (Register Pair HL also pushed). The stack holds, from the top, Register Pair HL, the text pointer and the kind pushed at 4DE0H (0 = !, 1 = !$, 2 = !#). 4E37H comes here too with the end of file as the position.
4E17
PUSH BC C5
Save Register Pair BC (Register C = the position's low byte) on the stack.
4E18
BIT 2,(IX+00H) DD CB 00 56
Test bit 2 of the byte at Index Register IX+00H (5700H, the mode byte): set for fixed-length records.
4E1C
If the Z FLAG is set (no fixed-length records), JUMP to 4E25H.
4E1E
CALL 5F08H CD 08 5F
GOSUB to BASIC 5F08H, which divides the position in Register C / L / H by the record length (5702H): the NZ FLAG is set if there is a remainder.
4E21
NOP 00
No operation: a spare byte between the CALL at 4E1EH and the JR at 4E23H.
4E22
NOP 00
No operation: a second spare byte; the flags from BASIC 5F08H pass through unchanged.
4E23
If the NZ FLAG is set (the position is not at a record boundary), JUMP to 4E06H for error A6H BAD FILE POSITIONING PARAM.
4E25
POP BC C1
Restore Register Pair BC from the stack: Register C = the position's low byte.
4E26
POP HL E1
Restore Register Pair HL from the stack: the position's middle and high bytes, pushed by BASIC 664CH.
4E27
POP DE D1
Restore Register Pair DE from the stack: the text pointer.
4E28
POP AF F1
Restore Register Pair AF from the stack: the kind, pushed as Register Pair BC at 4DE0H, so Register A = the old Register B.
4E29
PUSH DE D5
Save Register Pair DE (the text pointer) on the stack again.
4E2A
LD B,A 47
Load Register B with Register A, the kind (00H !, 01H !$, 02H !#).
4E2B
Decrement Register B; if the NZ FLAG is set (the kind is not 1), JUMP to 4E40H.
4E2D
!$: GOSUB to BASIC 61CDH, which positions the file to Register C / L / H.
4E30
RES 6,(IX+01H) DD CB 01 B6
Clear bit 6 of the byte at Index Register IX+01H (5701H): there is no record start now.
4E34
JUMP to 51BDH to end the statement; the text pointer is on the stack.
4E37
INC HL 23
!% or !$%: increment Register Pair HL, the text pointer, past the %.
4E38
PUSH BC C5
Save Register Pair BC (Register B = the kind) on the stack.
4E39
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack.
4E3A
CALL 61DAH CD DA 61
GOSUB to BASIC 61DAH, which returns Register A and Register Pair HL = the end of file (5715H, 5719H-571AH).
4E3D
LD C,A 4F
Load Register C with Register A, the end of file's low byte.
4E3E
JUMP to 4E27H with the position in Register C and Register Pair HL.
4E40
Decrement Register B (the kind minus 1); if the NZ FLAG is set (the kind was 0, plain !), JUMP to 4E97H: GET or PUT at that position.
4E42
LD A,C 79
!#: load Register A with Register C, the position's low byte.
4E43
CALL 6112H CD 12 61
GOSUB to BASIC 6112H, which stores Register A and Register Pair HL as the new end of file (FCB+8, FCB+12/13).
4E46
JUMP to 4E34H to end the statement; the text pointer is on the stack.
4E48H - Type MU: Skip to the Next Record
Reached from 4D30H for a type MU file (records of marked items, each starting with a 70H byte) when a record start is known and no position was given. Register C and Register Pair HL hold the position where the last statement ended. A PUT carries on from there; a GET skips the rest of the current record, up to the next 70H byte.
4E48
BIT 4,E CB 63
Test bit 4 of Register E, the mode byte's PUT bit.
4E4A
If the NZ FLAG is set (a PUT), JUMP to 4E97H and continue at Register C / L / H.
4E4C
CALL 6173H CD 73 61
GOSUB to BASIC 6173H to check the mode byte in Register E for GET.
4E4F
GOSUB to BASIC 61CDH, which positions the file to Register C / L / H.
FIND THE NEXT RECORD
Register C and Register Pair HL = the position of the marker about to be read.
4E52
CALL 61D3H CD D3 61
GOSUB to BASIC 61D3H, which returns Register C and Register Pair HL = the file's current position.
4E55
CALL 627FH CD 7F 62
GOSUB to BASIC 627FH, which reads one item marker and skips the item (see 4EA3H for the markers): the Z FLAG is set when the marker was 70H.
4E58
If the NZ FLAG is set (not 70H), LOOP back to 4E52H until the 70H byte of the next record is found.
4E5A
CALL 613EH CD 3E 61
GOSUB to BASIC 613EH, which stores Register C and Register Pair HL (the position of that 70H byte) as the record start.
4E5D
JUMP to 4EA9H for Register C and Register Pair HL = the position after the 70H byte.
4E5FH - A Record Number
The position parameter is an expression: a record number, 1 or more. The byte position is (number - 1) times the record length. Only files with fixed-length records (mode bit 2) accept it.
4E5F
DEC HL 2B
Decrement Register Pair HL, the text pointer, back to the first character of the expression.
4E60
CALL 664FH CD 4F 66
GOSUB to BASIC 664FH, which evaluates it and converts it through 4DE4H into Register C, Register L and Register H; the text pointer is left on the stack.
4E63
LD A,H 7C
Load Register A with Register H, the number's high byte.
4E64
CALL 6658H CD 58 66
GOSUB to BASIC 6658H: error 7EH BAD RECORD # if the number in Register C / L / H is 0; returns Register A = the low byte (Register C) and the Z FLAG set if it is 0.
4E67
If the NZ FLAG is set (the low byte is not 0), JUMP to 4E6AH: no borrow.
4E69
DEC HL 2B
Decrement Register Pair HL: borrow from the middle and high bytes for the decrement.
4E6A
DEC C 0D
Decrement Register C: Register C / L / H = the record number minus 1.
4E6B
BIT 2,(IX+00H) DD CB 00 56
Test bit 2 of the byte at Index Register IX+00H (5700H, the mode byte): fixed-length records.
4E6F
JP Z,5DD0H CA D0 5D
If the Z FLAG is set (no fixed-length records), JUMP to BASIC 5DD0H for error 6CH BAD FILE MODE.
4E72
EX DE,HL EB
Exchange Register Pairs DE and HL: D = the high byte and E = the middle byte of the number.
4E73
LD A,C 79
Load Register A with Register C, the low byte of the number.
4E74
LD BC,(5702H) ED 4B 02 57
Load Register Pair BC with the 16-bit value at 5702H, the record length.
4E78
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the high part of the product.
4E7B
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': the number's low byte goes to Register A'.
4E7C
LD A,19H 3E 19
Load Register A with 19H, a count of 25 shifts.
4E7E
EX AF,AF' 08
Bug in the file. The loop is meant as a shift-and-add multiply of A / D / E by Register Pair BC, with the count in the alternate A' and the product shifting right through H, L, D, E and A. As the bytes stand, 4E88H is 3FH (CCF), so the next three bytes read as LD BC,0809H: the record length in Register Pair BC is lost and never added, and this EX AF,AF' is the only swap in the loop, so Register A takes turns as the multiplier byte and the count. With 30H at 4E88H the bytes would read JR NC,4E8BH / ADD HL,BC / EX AF,AF', which gives the product. Here: exchange Register Pair AF with the alternate AF'.
MULTIPLY LOOP
Register Pair HL and Register D / E / A shift right together; Register Pair BC was meant to hold the record length.
4E7F
SRL H CB 3C
Shift Register H right, bit 0 into the CARRY FLAG.
4E81
RR L CB 1D
Rotate Register L right through the CARRY FLAG.
4E83
RR D CB 1A
Rotate Register D right through the CARRY FLAG.
4E85
RR E CB 1B
Rotate Register E right through the CARRY FLAG.
4E87
RRA 1F
Rotate Register A right through the CARRY FLAG: the bit shifted out is in the CARRY FLAG.
4E88
CCF 3F
Complement the CARRY FLAG (the byte meant to be 30H, JR NC).
4E89
LD BC,0809H 01 09 08
Load Register Pair BC with 0809H: the bytes 01H 09H 08H are meant as the JR's offset, ADD HL,BC and EX AF,AF' (see 4E7EH).
4E8C
DEC A 3D
Decrement Register A (meant to be the count; see 4E7EH).
4E8D
If the NZ FLAG is set (Register A is not 0), LOOP back to 4E7EH.
4E8F
LD A,H 7C
Load Register A with Register H, the product's top byte.
4E90
OR L B5
OR Register A with Register L: the NZ FLAG is set if Register Pair HL is not 0.
4E91
JP NZ,5DD9H C2 D9 5D
If the NZ FLAG is set (the product does not fit in 24 bits), JUMP to BASIC 5DD9H for error 7EH BAD RECORD #.
4E94
EX AF,AF' 08
Exchange Register Pair AF with the alternate AF': Register A = the product's low byte in the intended code.
4E95
EX DE,HL EB
Exchange Register Pairs DE and HL: HL = the product's middle and high bytes.
4E96
LD C,A 4F
Load Register C with Register A, the product's low byte.
4E97
JUMP to 4D36H to GET or PUT at Register C / L / H.
4E9AH - Type MU: the Record Marker
For type MU every record starts with a 70H byte. Register C and Register Pair HL hold the position.
4E9A
GOSUB to BASIC 61CDH, which positions the file to Register C / L / H.
4E9D
BIT 4,(IX+00H) DD CB 00 66
Test bit 4 of the byte at Index Register IX+00H (5700H, the mode byte): the PUT bit.
4EA1
If the NZ FLAG is set (a PUT), JUMP to 4EAFH.
4EA3
CALL 6293H CD 93 62
GOSUB to BASIC 6293H, which reads an item marker. It returns the Z FLAG and NO CARRY for 00H (a filler byte), the Z FLAG and CARRY for 70H (a record start), and the NZ FLAG with Register A = the type (2 integer 72H, 3 string 71H n or 80H + n, 4 single 73H, 8 double 74H) and Register B = the length for the others; any other byte is error 2AH BAD FILE DATA.
4EA6
JP NC,5DC4H D2 C4 5D
If the NO CARRY FLAG is set (not the 70H byte), JUMP to BASIC 5DC4H for error 2AH BAD FILE DATA.
4EA9
CALL 61D3H CD D3 61
GOSUB to BASIC 61D3H, which returns Register C and Register Pair HL = the position after the marker.
4EAC
JUMP to 4D4BH to store the positions and transfer.
4EAF
BIT 4,(IX+2DH) DD CB 2D 66
PUT: test bit 4 of the byte at Index Register IX+2DH (572DH): set if the position is at the end of file.
4EB3
If the Z FLAG is set (the record exists), JUMP to 4EA3H: it must start with 70H.
4EB5
LD A,70H 3E 70
Load Register A with 70H, the record start marker.
4EB7
LD B,00H 06 00
Load Register B with 00H: no data bytes follow the marker.
4EB9
CALL 6206H CD 06 62
GOSUB to BASIC 6206H to write the 70H byte in Register A.
4EBC
JUMP to 4EA9H for Register C and Register Pair HL = the position after it.
4EBEH - Transfer a Plain Record
The file is positioned. Item files (types with the letter M or F) go to the item list at 4F18H. A plain random file moves one record between the file and its record buffer (the FIELD buffer, see 4F0EH): a whole sector for a record length of 256, or the record in record mode (FCB+1 bit 7, LRL = the length) otherwise.
4EBE
LD A,(5700H) 3A 00 57
Load Register A with the byte at 5700H, the mode byte.
4EC1
AND 03H E6 03
Mask Register A against 03H (0000 0011) to keep bits 0-1, the item file letters M and F.
4EC3
If the NZ FLAG is set (an item file), JUMP to 4F18H.
4EC5
CALL 6058H CD 58 60
GOSUB to BASIC 6058H, which returns Register C and Register Pair HL = NEXT, with the CARRY FLAG set if NEXT is below the end of file.
4EC8
If the CARRY FLAG is set (the record exists), JUMP to 4EF0H.
4ECA
BIT 4,(IX+00H) DD CB 00 66
Test bit 4 of the byte at Index Register IX+00H (5700H, the mode byte): the PUT bit.
4ECE
If the NZ FLAG is set (a PUT), JUMP to 4EE9H.
4ED0
LD A,(5702H) 3A 02 57
GET past the end of file: load Register A with the byte at 5702H, the low byte of the record length.
4ED3
ADD A,C 81
Add Register C (the position's low byte) to Register A.
4ED4
LD C,A 4F
Load Register C with Register A, the new low byte of the position.
4ED5
LD A,(5703H) 3A 03 57
Load Register A with the byte at 5703H, the high byte of the record length.
4ED8
ADC A,L 8D
Add Register L (the position's middle byte) and the CARRY FLAG to Register A.
4ED9
LD L,A 6F
Load Register L with Register A, the new middle byte.
4EDA
If the NO CARRY FLAG is set, JUMP to 4EDDH: nothing to carry into Register H.
4EDC
INC H 24
Increment Register H, the high byte: the carry from the middle byte.
4EDD
GOSUB to BASIC 61CDH, which positions the file to Register C / L / H, after the missing record.
4EE0
GOSUB to 4F0EH, which returns Register Pair HL = the record buffer and Register A = the low byte of the record length.
4EE3
LD B,A 47
Load Register B with Register A, the byte count (0 = 256).
4EE4
GOSUB to BASIC 6389H to clear Register B bytes of the record buffer at Register Pair HL: the record reads as zeros.
4EE7
JUMP to 4F0BH to finish the statement at 51B1H.
4EE9
BIT 7,(IX+01H) DD CB 01 7E
PUT past the end of file: test bit 7 of the byte at Index Register IX+01H (5701H), set by the OPEN modes O, E and R.
4EED
JP Z,5DE8H CA E8 5D
If the Z FLAG is set (the file may not be extended), JUMP to BASIC 5DE8H for error 90H ILLEGAL TO EXTEND FILE.
4EF0
GOSUB to 4F0EH, which returns Register Pair HL = the record buffer and Register A = the low byte of the record length, with the Z FLAG set for 256.
4EF3
If the Z FLAG is set (the record length is 256), JUMP to 4F01H.
4EF5
BIT 4,(IX+00H) DD CB 00 66
Test bit 4 of the byte at Index Register IX+00H (5700H, the mode byte): the PUT bit.
4EF9
CALL Z,623BH CC 3B 62
If the Z FLAG is set (a GET), GOSUB to BASIC 623BH to read the record into the buffer at Register Pair HL in record mode (SYS0 4436H).
4EFC
If the NZ FLAG is set (a PUT), GOSUB to BASIC 6236H to write the record from Register Pair HL in record mode (SYS0 443CH, write with verify).
4EFF
JUMP to 4F0BH to finish the statement at 51B1H.
4F01
BIT 4,(IX+00H) DD CB 00 66
A 256-byte record: test bit 4 of the byte at Index Register IX+00H (5700H, the mode byte), the PUT bit.
4F05
CALL Z,6259H CC 59 62
If the Z FLAG is set (a GET), GOSUB to BASIC 6259H to read the sector (SYS0 4436H).
4F08
CALL NZ,625EH C4 5E 62
If the NZ FLAG is set (a PUT), GOSUB to BASIC 625EH to write the sector (SYS0 443CH).
4F0B
JUMP to 51B1H to finish the statement; the text pointer is on the stack.
4F0EH - The Record Buffer
Returns Register Pair HL = the record buffer of the file. The FCB's buffer address (5710H-5711H) is the sector buffer; a file with a record length that is not a multiple of 256 has its record buffer in the 256 bytes before it. Register A = the low byte of the record length, with the Z FLAG set if it is 0.
4F0E
LD HL,(5710H) 2A 10 57
Load Register Pair HL with the 16-bit value at 5710H, the FCB's buffer address (FCB+3/4): the sector buffer.
4F11
LD A,(5702H) 3A 02 57
Load Register A with the byte at 5702H, the low byte of the record length.
4F14
OR A B7
OR Register A with itself to set the flags: the Z FLAG is set for a record length of 256.
4F15
RET Z C8
If the Z FLAG is set (length 256), RETURN with Register Pair HL = the sector buffer.
4F16
DEC H 25
Decrement Register H: Register Pair HL = the record buffer, 256 bytes below the sector buffer.
4F17
RET C9
RETURN with Register Pair HL = the record buffer and Register A = the record length's low byte.
4F18H - The Item List (IGEL)
Item files (types MI, MU, MF, FI, FF from OPEN's fourth parameter) move the values of a list of variables or expressions. The list follows a comma after the position: either the number of the program line that holds it, or a second comma and the list in the statement itself. Items are separated by commas and the list ends with a semicolon; a list may run on over several program lines, and ' comments are skipped. Type F files hold the values as bare bytes (a string takes the length given by a (n) prefix); type M files put a marker before each value (72H integer, 73H single, 74H double, 80H + n or 71H n for a string, 00H filler, 70H end of record). The available room in the record is counted in BASIC's 61F1H; a PUT to types MU, MF, FI and FF first runs the whole list without writing (572DH bit 2) to count it.
4F18
CALL 6358H CD 58 63
GOSUB to BASIC 6358H, which returns Register Pair HL = the room left in the record (the record length minus the bytes from the record start to here); error 8EH RECORD OVERFLOW if there is none.
4F1B
LD (4F8CH),HL 22 8C 4F
Self-Modifying Code
Store Register Pair HL (the room) at 4F8CH, the operand of 4F8BH.
4F1E
POP HL E1
Restore Register Pair HL from the stack: the text pointer.
4F1F
CALL 638FH CD 8F 63
GOSUB to BASIC 638FH with Register Pair HL = the text pointer: the Z FLAG is set at the end of the statement, else it takes a comma.
4F22
If the Z FLAG is set (there is no item list), JUMP to 51B0H to finish.
4F25
DEC HL 2B
Decrement Register Pair HL, the text pointer, back one character for RST 10H.
4F26
RST 10H D7
RST 10H: step Register Pair HL to the next character after the comma and load it into Register A; the Z FLAG is set at the end of the statement.
4F27
JP Z,5DF4H CA F4 5D
If the Z FLAG is set (the statement ends there), JUMP to BASIC 5DF4H for error 9AH IGEL SYNTAX ERROR.
4F2A
CP 2CH FE 2C
Compare Register A against 2CH, another comma: the list follows in this statement.
4F2C
If the Z FLAG is set (a comma), JUMP to 4F3DH with Register Pair HL at the comma.
4F2E
SET 1,(IX+2DH) DD CB 2D CE
Otherwise it is a line number: set bit 1 of the byte at Index Register IX+2DH (572DH, the statement flags): the list is in another line.
4F32
GOSUB to ROM 1E5AH (LINGET), which converts the digits at Register Pair HL to the line number in Register Pair DE.
4F35
PUSH HL E5
Save Register Pair HL (the text pointer of the statement, after the line number) on the stack.
4F36
GOSUB to ROM 1EC5H, inside the GOTO routine, to find the line numbered Register Pair DE (error UNDEFINED LINE # if it does not exist); Register Pair HL comes back pointing at that line.
4F39
LD BC,0004H 01 04 00
Load Register Pair BC with 0004H, the size of the line's link and line number.
4F3C
ADD HL,BC 09
Add Register Pair BC (4) to Register Pair HL: skip the link and the line number, ready for RST 10H.
4F3D
LD C,(IX+00H) DD 4E 00
Load Register C with the byte at Index Register IX+00H (5700H, the mode byte).
4F40
BIT 4,C CB 61
Test bit 4 of Register C, the mode byte's PUT bit.
4F42
If the Z FLAG is set (a GET), JUMP to 4F87H: no counting run.
4F44
BIT 4,(IX+2DH) DD CB 2D 66
Test bit 4 of the byte at Index Register IX+2DH (572DH): set if the position is at the end of file.
4F48
If the NZ FLAG is set (at the end of file), JUMP to 4F87H: nothing to fit into.
4F4A
BIT 0,C CB 41
Test bit 0 of Register C, the mode byte: letter M.
4F4C
If the Z FLAG is set (a type F file), JUMP to 4F7BH.
4F4E
BIT 3,C CB 59
Test bit 3 of Register C, the mode byte: second letter U or F.
4F50
JP Z,5DD0H CA D0 5D
If the Z FLAG is set (type MI), JUMP to BASIC 5DD0H for error 6CH BAD FILE MODE: type MI is only written at the end of file.
4F53
BIT 2,C CB 51
Test bit 2 of Register C, the mode byte: second letter F.
4F55
If the NZ FLAG is set (type MF), JUMP to 4F7BH.
4F57
PUSH HL E5
Type MU: save Register Pair HL (the text pointer) on the stack.
MEASURE THE EXISTING RECORD
Register C and Register Pair HL = the file's position as each item of the old record is skipped.
4F58
CALL 6058H CD 58 60
GOSUB to BASIC 6058H, which returns Register C and Register Pair HL = NEXT, with the CARRY FLAG set if it is below the end of file.
4F5B
If the CARRY FLAG is set (more of the file), JUMP to 4F69H.
4F5D
SET 3,(IX+2DH) DD CB 2D DE
The record runs to the end of file: set bit 3 of the byte at Index Register IX+2DH (572DH).
4F61
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of the byte at Index Register IX+01H (5701H): set if the file may be extended.
4F65
If the NZ FLAG is set (it may), JUMP to 4F7AH: the room is not limited.
4F67
Otherwise JUMP to 4F6EH to take the record's length as the room.
4F69
CALL 627FH CD 7F 62
GOSUB to BASIC 627FH to skip one item of the existing record: the Z FLAG is set at the 70H byte of the next record.
4F6C
If the NZ FLAG is set (not yet), LOOP back to 4F58H until the end of the record.
4F6E
LD H,L 65
Load Register H with Register L, the position's middle byte.
4F6F
LD L,C 69
Load Register L with Register C, the low byte. Register Pair HL = the low 16 bits of the position.
4F70
LD DE,(5704H) ED 5B 04 57
Load Register Pair DE with the 16-bit value at 5704H, the low 16 bits of the record's start.
4F74
OR A B7
OR Register A with itself to clear the CARRY FLAG for the subtraction.
4F75
SBC HL,DE ED 52
Subtract Register Pair DE (the start) from Register Pair HL: HL = the length of the existing record.
4F77
LD (4F8CH),HL 22 8C 4F
Self-Modifying Code
Store Register Pair HL (the record's length) at 4F8CH, the operand of 4F8BH: the new record must fit into it.
4F7A
POP HL E1
Restore Register Pair HL from the stack: the text pointer.
4F7B
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack for after the counting run.
4F7C
SET 2,(IX+2DH) DD CB 2D D6
Set bit 2 of the byte at Index Register IX+2DH (572DH): count only, do not write.
4F80
GOSUB to 4F8BH to run the list once; the counting run returns from 51AAH.
4F83
CALL 61CAH CD CA 61
GOSUB to BASIC 61CAH to position the file back to the record's start (5704H-5706H).
4F86
POP HL E1
Restore Register Pair HL from the stack: the text pointer at the list.
4F87
RES 2,(IX+2DH) DD CB 2D 96
Clear bit 2 of the byte at Index Register IX+2DH (572DH): now transfer.
4F8B
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the room in the record, the operand 4F8CH (0000H in the file, stored at 4F1BH and 4F77H).
4F8E
LD (61F1H),DE ED 53 F1 61
Self-Modifying Code
Store Register Pair DE (the room) at 61F1H, BASIC's room counter (the operand of LD HL,nnnn at 61F0H).
4F92
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H, the number of the first item.
ITEM LOOP
Register Pair HL = the text pointer, Register Pair DE = the item number (kept at BASIC 5D5FH for error messages).
4F95
LD (5D5FH),DE ED 53 5F 5D
Self-Modifying Code
Store Register Pair DE (the item number) at 5D5FH, the operand of LD DE,nnnn at BASIC 5D5EH.
4F99
GOSUB to 4FC1H, which returns the next character of the list in Register A with Register Pair HL at it.
4F9C
CP 2CH FE 2C
Compare Register A against 2CH, a comma: an empty item.
4F9E
If the Z FLAG is set (an empty item), JUMP to 4FAAH to skip an item.
4FA0
CP 3BH FE 3B
Compare Register A (the list's character) against 3BH, a semicolon.
4FA2
If the NZ FLAG is set (not a semicolon), JUMP to 4FDFH: an item.
4FA4
DEC DE 1B
Decrement Register Pair DE, the item number, to test it for 1.
4FA5
LD A,D 7A
Load Register A with Register D, to test Register Pair DE for zero.
4FA6
OR E B3
OR Register A with Register E: the Z FLAG is set if the semicolon came first (item number 1).
4FA7
If the Z FLAG is set (the list is just ;), JUMP to 51A2H to end it.
4FAA
LD A,(IX+00H) DD 7E 00
Skip one item: load Register A with the byte at Index Register IX+00H (5700H, the mode byte).
4FAD
AND 12H E6 12
Mask Register A against 12H (0001 0010) to keep bit 4 (PUT) and bit 1 (letter F).
4FAF
JP NZ,5DF7H C2 F7 5D
If the NZ FLAG is set (a PUT, or a type F file), JUMP to BASIC 5DF7H for error 9CH IGEL ITEM SYNTAX ERROR: skipping needs a GET from a type M file.
4FB2
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack.
4FB3
CALL 6293H CD 93 62
GOSUB to BASIC 6293H to read the next item marker (see 4EA3H): Register A = the type, Register B = the length.
4FB6
JP C,5DE5H DA E5 5D
If the CARRY FLAG is set (the 70H byte, the end of the record), JUMP to BASIC 5DE5H for error 8EH RECORD OVERFLOW.
4FB9
If the Z FLAG is set (a 00H filler byte), LOOP back to 4FB3H.
4FBB
CALL 626CH CD 6C 62
GOSUB to BASIC 626CH to skip the item's Register B bytes in the file.
4FBE
JUMP to 518EH for the next item; the text pointer is on the stack.
4FC1H - Next Character of the List
RST 10H with two extensions: at the end of a program line the list continues with the next line, and a ' comment (a colon followed by the REM token 93H) skips the rest of the line. A list that runs off the end of the program is error 9AH IGEL SYNTAX ERROR.
4FC1
RST 10H D7
RST 10H: step Register Pair HL to the next character and load it into Register A; the Z FLAG is set for 00H or a colon.
4FC2
If the NZ FLAG is set (not the end of a statement), JUMP to 4FCDH.
4FC4
OR A B7
OR Register A with itself: the Z FLAG is set for 00H, the end of the line.
4FC5
If the Z FLAG is set (the end of the line), JUMP to 4FD4H.
4FC7
RST 10H D7
A colon: RST 10H steps Register Pair HL to the next character and loads it into Register A.
4FC8
CP 93H FE 93
Compare Register A against 93H, the REM token (a ' comment is stored as a colon and 93H).
4FCA
JP NZ,5DF4H C2 F4 5D
If the NZ FLAG is set (another statement), JUMP to BASIC 5DF4H for error 9AH IGEL SYNTAX ERROR.
4FCD
CP 93H FE 93
Compare Register A against 93H, the REM token.
4FCF
RET NZ C0
If the NZ FLAG is set (not a comment), RETURN with the character in Register A.
SKIP THE COMMENT
Register Pair HL steps to the line's 00H end.
4FD0
RST 10H D7
RST 10H: step Register Pair HL to the next character and load it into Register A.
4FD1
OR A B7
OR Register A with itself: the Z FLAG is set for 00H, the end of the line.
4FD2
If the NZ FLAG is set (not yet), LOOP back to 4FD0H.
4FD4
INC HL 23
Increment Register Pair HL to the next line's link field.
4FD5
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the link's low byte.
4FD6
INC HL 23
Increment Register Pair HL to the link's high byte.
4FD7
OR (HL) B6
OR Register A with the byte at Register Pair HL: the Z FLAG is set for a 0000H link, the end of the program.
4FD8
JP Z,5DF4H CA F4 5D
If the Z FLAG is set (the end of the program), JUMP to BASIC 5DF4H for error 9AH IGEL SYNTAX ERROR.
4FDB
INC HL 23
Increment Register Pair HL to the line number's low byte.
4FDC
INC HL 23
Increment Register Pair HL to the line number's high byte, just before the text.
4FDD
JUMP to 4FC1H to read the line's first character through RST 10H.
4FDFH - One Item: the (n) Prefix
Register Pair HL points at the item and Register A holds its first character. An item may start with a length in parentheses, (n) with n = 0 to 255, stored at 5094H (FFH when there is none). A parenthesised expression that is followed by a comma, a semicolon or the end is taken as the item itself.
4FDF
PUSH HL E5
Save Register Pair HL (the item's start) on the stack.
4FE0
RES 6,(IX+2DH) DD CB 2D B6
Clear bit 6 of the byte at Index Register IX+2DH (572DH): no prefix yet.
4FE4
CP 28H FE 28
Compare Register A (the item's first character) against 28H, an opening parenthesis.
4FE6
If the NZ FLAG is set (no parenthesis), JUMP to 500AH.
4FE8
CALL 61B7H CD B7 61
GOSUB to BASIC 61B7H, which evaluates the parenthesised expression at Register Pair HL (the Z FLAG set if it is a string) and leaves the text pointer after it on the stack.
4FEB
POP HL E1
Restore Register Pair HL from the stack: the text pointer after the expression.
4FEC
If the Z FLAG is set (a string), JUMP to 500AH: not a prefix.
4FEE
DEC HL 2B
Decrement Register Pair HL, the text pointer, back one character for RST 10H.
4FEF
RST 10H D7
RST 10H: step Register Pair HL to the next character and load it into Register A; the Z FLAG is set at the end of the statement.
4FF0
If the Z FLAG is set (the end), JUMP to 500AH: the parentheses were the item.
4FF2
CP 2CH FE 2C
Compare Register A (the character after the parentheses) against 2CH, a comma.
4FF4
If the Z FLAG is set (a comma), JUMP to 500AH: the parentheses were the item.
4FF6
CP 3BH FE 3B
Compare Register A (the character after the parentheses) against 3BH, a semicolon.
4FF8
If the Z FLAG is set (a semicolon), JUMP to 500AH: the parentheses were the item.
4FFA
SET 6,(IX+2DH) DD CB 2D F6
Something follows: it is a prefix. Set bit 6 of the byte at Index Register IX+2DH (572DH).
4FFE
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (at the Stack Pointer SP): the text pointer after the prefix replaces the item's start there, and HL = the item's start.
4FFF
GOSUB to ROM 0A7FH (FRCINT), which converts the value in REG 1 to an integer in Register Pair HL.
5002
LD A,H 7C
Load Register A with Register H, the integer's high byte.
5003
OR A B7
OR Register A with itself: the Z FLAG is set if the value is 255 or less.
5004
LD A,L 7D
Load Register A with Register L, the integer's low byte: the length n. LD does not change the flags.
5005
If the Z FLAG is set (n is 0-255), JUMP to 500CH.
5007
JP 5DFAH C3 FA 5D
JUMP to BASIC 5DFAH for error 9EH BAD/ILLEGAL/MISSING IGEL ITEM PREFIX.
500A
LD A,FFH 3E FF
No prefix: load Register A with FFH, the value for none.
500C
LD (5094H),A 32 94 50
Self-Modifying Code
Store Register A (the length prefix, FFH = none) at 5094H, the operand of 5093H (BASIC's 615DH and 6304H read it there too).
500F
BIT 4,(IX+00H) DD CB 00 66
Test bit 4 of the byte at Index Register IX+00H (5700H, the mode byte): the PUT bit.
5013
If the NZ FLAG is set (a PUT), JUMP to 50F6H.
5016
POP HL E1
GET: restore Register Pair HL from the stack: the text pointer at the item (after any prefix).
5017
CALL 62FFH CD FF 62
GOSUB to BASIC 62FFH. For a type M file it returns the Z FLAG. For a type F file it returns the NZ FLAG with Register C = the length prefix, and either Register A = # or $ (Register Pair DE = the text pointer after it) or Register A = 00H with Register Pair HL = the variable's address (found through PTRGET 260DH), Register Pair DE = the text pointer and Register B = its first byte; a string variable without a prefix is error 9EH.
501A
If the Z FLAG is set (a type M file), JUMP to 506AH.
501CH - GET from a Type F File
Each item is a variable (its bytes are read raw, a string takes exactly n bytes), or (n)# / (n)$ to skip n bytes. With the % position (572DH bit 5) no file is read: each string variable is cut or padded with spaces to its length prefix. Register Pair HL = the variable's address, Register C = the prefix, Register A = 00H or the # / $ character.
501C
PUSH DE D5
Save Register Pair DE (the text pointer after the item) on the stack.
501D
BIT 5,(IX+2DH) DD CB 2D 6E
Test bit 5 of the byte at Index Register IX+2DH (572DH): set for the % position.
5021
If the Z FLAG is set (not the % position), JUMP to 5056H.
5023
OR A B7
%: OR Register A with itself: the NZ FLAG is set if the item is # or $.
5024
If the NZ FLAG is set (# or $), JUMP to 5053H: nothing to do.
5026
RST 20H E7
RST 20H: test the variable's type (VALTYP, 40AFH); the Z FLAG is set for a string.
5027
If the NZ FLAG is set (not a string), JUMP to 5053H.
5029
GOSUB to BASIC 5CC3H, which returns Register A = the string's length and Register Pair DE = its address, from the descriptor at Register Pair HL.
502C
LD B,A 47
Load Register B with Register A, the string's length.
502D
LD A,C 79
Load Register A with Register C, the length prefix.
502E
SUB B 90
Subtract Register B (the length) from Register A (the prefix): the number of spaces to add.
502F
If the NO CARRY FLAG is set (the string is not longer than the prefix), JUMP to 5034H.
5031
XOR A AF
Longer: load Register A with 00H (XOR A with itself), no spaces to add.
5032
LD (HL),C 71
Store Register C (the prefix) at Register Pair HL, the descriptor's length byte: the string is cut.
5033
LD B,C 41
Load Register B with Register C, the new length.
5034
LD C,A 4F
Load Register C with Register A, the number of spaces to add.
5035
PUSH HL E5
Save Register Pair HL (the descriptor's address) on the stack.
5036
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the 16-bit value at 40D6H, FRETOP: the bottom of the string space in use.
5039
RST 18H DF
RST 18H: compare Register Pair HL (FRETOP) with Register Pair DE (the string's address). The CARRY FLAG is set if the string lies above FRETOP, in the string space.
503A
POP HL E1
Restore Register Pair HL from the stack: the descriptor's address.
503B
If the NO CARRY FLAG is set (the string is not in the string space: a literal in the program), JUMP to 5041H to copy it.
503D
LD A,C 79
Load Register A with Register C, the number of spaces.
503E
OR A B7
OR Register A with itself: the Z FLAG is set if there are none.
503F
If the Z FLAG is set (no spaces to add), JUMP to 5053H.
5041
PUSH BC C5
Save Register Pair BC (B = the kept length, C = the spaces) on the stack.
5042
PUSH DE D5
Save Register Pair DE (the old string's address) on the stack.
5043
LD A,B 78
Load Register A with Register B, the kept length.
5044
ADD A,C 81
Add Register C (the spaces) to Register A: the new length.
5045
GOSUB to BASIC 5CD3H, which allocates Register A bytes of string space (GETSPA 28BFH) and sets the descriptor at Register Pair HL; Register Pair DE = the new string's address.
5048
EX DE,HL EB
Exchange Register Pairs DE and HL: HL = the new string's address.
5049
POP DE D1
Restore Register Pair DE from the stack: the old string's address.
504A
POP BC C1
Restore Register Pair BC from the stack: B = the kept length, C = the spaces.
504B
LD A,B 78
Load Register A with Register B, the kept length.
504C
OR A B7
OR Register A with itself: the Z FLAG is set if nothing is kept.
504D
If the NZ FLAG is set, GOSUB to ROM 09D6H (VMOVEA), which copies Register A bytes from Register Pair DE (the old characters) to Register Pair HL (the new string).
5050
GOSUB to BASIC 5CE3H to store Register C spaces at Register Pair HL.
5053
JUMP to 518EH for the next item; the text pointer is on the stack.
5056
OR A B7
Normal GET: OR Register A with itself: the Z FLAG is set for a variable (00H), clear for # or $.
5057
If the Z FLAG is set (a variable), JUMP to 5062H.
5059
LD A,C 79
(n)# or (n)$: load Register A with Register C, the count n.
505A
GOSUB to BASIC 626DH to skip Register A (n) bytes of the file.
505D
CALL 636DH CD 6D 63
GOSUB to BASIC 636DH: error 8EH RECORD OVERFLOW if the record is now overrun.
5060
JUMP to 5053H, which goes on to 518EH for the next item.
5062
PUSH HL E5
Save Register Pair HL (the variable's address) on the stack.
5063
RST 20H E7
RST 20H: test the variable's type (VALTYP, 40AFH); the Z FLAG is set for a string.
5064
PUSH AF F5
Save Register Pair AF (the variable's type flags) on the stack.
5065
If the NZ FLAG is set (numeric), JUMP to 50BFH.
5067
LD A,C 79
A string: load Register A with Register C, the length prefix.
5068
JUMP to 5098H to read Register A bytes into it.
506AH - GET from a Type M File
Register Pair HL = the item. Each item is # (skip an item, needs a prefix), or a variable. The file's marker decides the value's type: a numeric value is stored through the ROM's LET code (so it is converted to the variable's type), a string needs a string variable and is cut to the length prefix if one is given.
506A
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the item's first character.
506B
CP 23H FE 23
Compare Register A (the item's first character) against 23H, a #.
506D
If the NZ FLAG is set (not #), JUMP to 5076H.
506F
INC HL 23
Increment Register Pair HL, the text pointer, past the #.
5070
GOSUB to BASIC 62F7H: error 9EH BAD/ILLEGAL/MISSING IGEL ITEM PREFIX unless a prefix was given.
5073
JUMP to 4FAAH to skip an item of the file; the text pointer in Register Pair HL is saved there.
5076
GOSUB to ROM 260DH (PTRGET), which finds the variable named at Register Pair HL: Register Pair DE = its address, HL = the text pointer after the name.
5079
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack.
507A
PUSH DE D5
Save Register Pair DE (the variable's address) on the stack.
507B
RST 20H E7
RST 20H: test the variable's type (VALTYP, 40AFH, set by PTRGET); the Z FLAG is set for a string.
507C
PUSH AF F5
Save Register Pair AF (the variable's type flags) on the stack.
READ THE MARKER
00H filler bytes are skipped; the 70H byte ends the record.
507D
CALL 6293H CD 93 62
GOSUB to BASIC 6293H to read the item marker (see 4EA3H): Register A = the type, Register B = the length.
5080
JP C,5DE5H DA E5 5D
If the CARRY FLAG is set (the 70H byte, the end of the record), JUMP to BASIC 5DE5H for error 8EH RECORD OVERFLOW.
5083
If the Z FLAG is set (a 00H filler byte), LOOP back to 507DH.
5085
LD C,B 48
Load Register C with Register B, the item's length in the file.
5086
LD (40AFH),A 32 AF 40
Store Register A (the item's type) at 40AFH, VALTYP: the item's type becomes the current value type.
5089
RST 20H E7
RST 20H: test the item's type (VALTYP); the Z FLAG is set for a string.
508A
If the NZ FLAG is set (a numeric item), JUMP to 50BFH.
508C
POP AF F1
A string item: restore Register Pair AF from the stack, the variable's type flags.
508D
POP HL E1
Restore Register Pair HL from the stack: the variable's address.
508E
PUSH HL E5
Save Register Pair HL (the variable's address) on the stack again.
508F
PUSH AF F5
Save Register Pair AF (the variable's type flags) on the stack again.
5090
If the NZ FLAG is set (the variable is not a string), JUMP to ROM 0AF6H (TMERR) for TYPE MISMATCH.
5093
LD A,00H 3E 00
Self-Modifying Code
Load Register A with the length prefix, the operand 5094H (00H in the file, stored at 500CH; FFH = none).
5095
CP B B8
Compare Register A (the prefix) against Register B (the item's length): the CARRY FLAG is set if the prefix is shorter.
5096
If the NO CARRY FLAG is set (the prefix is not shorter), JUMP to 5099H with Register B = the item's length.
5098
LD B,A 47
Load Register B with Register A: the number of bytes to read is the prefix (5068H also enters here with the type F prefix).
5099
PUSH BC C5
Save Register Pair BC (B = the bytes to read, C = the bytes in the file) on the stack.
509A
GOSUB to BASIC 5CC3H, which returns Register A = the variable's current length and Register Pair DE = its address, from the descriptor at Register Pair HL.
509D
LD B,D 42
Load Register B with Register D, the old string's address, high byte.
509E
LD C,E 4B
Load Register C with Register E. Register Pair BC = the old string's address.
509F
LD D,H 54
Load Register D with Register H, the descriptor's address, high byte.
50A0
LD E,L 5D
Load Register E with Register L. Register Pair DE = the descriptor's address.
50A1
XOR A AF
Load Register A with 00H (XOR A with itself).
50A2
CALL 29E3H CD E3 29
GOSUB to ROM 29E3H, inside FREFAC (29DAH-29F4H, which frees a string temporary through FRETMS 29F5H), entered with Register Pair DE = the descriptor's address; it returns Register Pair HL = the descriptor's address.
50A5
PUSH HL E5
Save Register Pair HL (the descriptor's address) on the stack.
50A6
LD HL,(40D6H) 2A D6 40
Load Register Pair HL with the 16-bit value at 40D6H, FRETOP: the bottom of the string space in use.
50A9
RST 18H DF
RST 18H: compare Register Pair HL (FRETOP) with Register Pair DE as the ROM routine left it, taken here as the old string's address. The CARRY FLAG is set if it lies above FRETOP, in the string space.
50AA
POP HL E1
Restore Register Pair HL from the stack: the descriptor's address.
50AB
If the CARRY FLAG is set (the old string is in the string space), JUMP to 50AFH.
50AD
LD (HL),00H 36 00
It is a literal in the program: store 00H at Register Pair HL, the descriptor's length, so new space is taken.
50AF
POP BC C1
Restore Register Pair BC from the stack: B = the bytes to read, C = the bytes in the file.
50B0
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the old length from the descriptor.
50B1
CP B B8
Compare Register A (the old length) against Register B (the new length): the CARRY FLAG is set if the new string is longer.
50B2
PUSH BC C5
Save Register Pair BC (the counts) on the stack again.
50B3
LD (HL),B 70
Store Register B (the new length) at Register Pair HL, the descriptor's length byte.
50B4
LD A,B 78
Load Register A with Register B, the new length. LD does not change the flags.
50B5
If the CARRY FLAG is set (the new string is longer), GOSUB to BASIC 5CD3H to allocate Register A bytes of string space for it and set the descriptor at Register Pair HL.
50B8
GOSUB to BASIC 5CC3H, which returns Register Pair DE = the string's address from the descriptor at Register Pair HL.
50BB
EX DE,HL EB
Exchange Register Pairs DE and HL: HL = the address to read into.
50BC
POP BC C1
Restore Register Pair BC from the stack: B = the bytes to read, C = the bytes in the file.
50BD
JUMP to 50DCH to read Register B bytes into Register Pair HL.
50BF
LD HL,4121H 21 21 41
Numeric: load Register Pair HL with 4121H, REG 1, where the value is read.
50C2
LD B,02H 06 02
Load Register B with 02H, the byte count of an integer.
50C4
If the SIGN FLAG is set (from the type test: an integer), JUMP to 50D0H.
50C7
LD B,04H 06 04
Load Register B with 04H, the byte count of a single precision value.
50C9
If the CARRY FLAG is set (from the type test: single precision), JUMP to 50D0H.
50CB
LD HL,411DH 21 1D 41
Double precision: load Register Pair HL with 411DH, the low end of the double precision REG 1.
50CE
LD B,08H 06 08
Load Register B with 08H, the byte count of a double precision value.
50D0
LD C,B 48
Load Register C with Register B: the item's length in the file is the same.
50D1
LD (40DFH),HL 22 DF 40
Store Register Pair HL (where the value is read) at 40DFH, the ROM's TEMP.
50D4
POP AF F1
Restore Register Pair AF from the stack: the variable's type flags.
50D5
If the Z FLAG is set (the variable is a string), JUMP to ROM 0AF6H (TMERR) for TYPE MISMATCH.
50D8
PUSH AF F5
Save Register Pair AF (the variable's type flags) on the stack again.
50D9
CALL 62EEH CD EE 62
GOSUB to BASIC 62EEH: a numeric item may not have a length prefix (error 9EH).
50DC
LD A,B 78
Load Register A with Register B, the number of bytes to read.
50DD
OR A B7
OR Register A with itself: the Z FLAG is set if there are none.
50DE
CALL NZ,623BH C4 3B 62
If the NZ FLAG is set, GOSUB to BASIC 623BH to read Register B bytes into Register Pair HL in record mode (SYS0 4436H with LRL = Register B).
50E1
LD A,C 79
Load Register A with Register C, the item's length in the file.
50E2
SUB B 90
Subtract Register B (the bytes read) from Register A: the bytes left over.
50E3
If the NZ FLAG is set (a string was cut), GOSUB to BASIC 626DH to skip the Register A bytes that are left.
50E6
CALL 636DH CD 6D 63
GOSUB to BASIC 636DH: error 8EH RECORD OVERFLOW if the record is overrun.
50E9
POP AF F1
Restore Register Pair AF from the stack: the variable's type flags.
50EA
POP HL E1
Restore Register Pair HL from the stack: the variable's address.
50EB
If the Z FLAG is set (a string variable), JUMP to 518EH: done.
50EE
LD DE,518EH 11 8E 51
A number: load Register Pair DE with 518EH, the way back after the store.
50F1
PUSH DE D5
Push Register Pair DE (518EH) on the stack as a return address.
50F2
PUSH DE D5
Push Register Pair DE (518EH) on the stack a second time, so two copies of the way back are stacked.
50F3
JUMP to ROM 1F33H, inside the LET routine (1F21H-1F6BH), to store the value in REG 1 into the variable at Register Pair HL, converting it to the variable's type.
50F6H - PUT an Item
For a type F file an item is a variable, (n)# (write n 00H bytes) or (n)$ (keep the n bytes in the file; at the end of file write n 00H bytes). Numbers go out as their raw bytes, a string as exactly n characters, padded with spaces. For a type M file see 5144H. Every write goes through BASIC 61EFH, which writes Register A and then Register B bytes from Register Pair HL, counting B + 1 against the room in the record (error 8EH RECORD OVERFLOW) and only counting while 572DH bit 2 is set.
50F6
POP HL E1
Restore Register Pair HL from the stack: the text pointer at the item (after any prefix).
50F7
CALL 62FFH CD FF 62
GOSUB to BASIC 62FFH (see 5017H): the Z FLAG for a type M file; for a type F file Register C = the prefix, Register A = 00H (Register Pair HL = the variable) or # / $, Register Pair DE = the text pointer after the item.
50FA
If the Z FLAG is set (a type M file), JUMP to 5144H.
50FC
PUSH DE D5
Save Register Pair DE (the text pointer after the item) on the stack.
50FD
OR A B7
OR Register A with itself: the Z FLAG is set if the item is a variable (00H).
50FE
If the Z FLAG is set (a variable), JUMP to 511EH.
5100
CP 23H FE 23
Compare Register A (the item's character) against 23H, a #.
5102
If the Z FLAG is set (#), JUMP to 5111H to write n 00H bytes.
5104
LD A,(IX+2DH) DD 7E 2D
$: load Register A with the byte at Index Register IX+2DH (572DH, the statement flags).
5107
BIT 2,A CB 57
Test bit 2 of Register A: set during the counting run.
5109
If the NZ FLAG is set (counting only), JUMP to 518EH: $ takes no room from the count.
510C
BIT 4,A CB 67
Test bit 4 of Register A: set if the position is at the end of file.
510E
If the Z FLAG is set (inside the file), JUMP to 5059H to skip Register C (n) bytes in the file.
5111
INC C 0C
Increment Register C (n) for the loop, which decrements before it tests (5158H also enters here).
5112
JUMP to 5119H to count first, so n = 0 writes nothing.
WRITE n ZERO BYTES
Register C counts the bytes left plus 1.
5114
XOR A AF
Load Register A with 00H (XOR A with itself), the byte to write.
5115
LD B,A 47
Load Register B with Register A (00H): no data bytes follow.
5116
CALL 61EFH CD EF 61
GOSUB to BASIC 61EFH to write the 00H byte in Register A.
5119
DEC C 0D
Decrement Register C, the count of bytes left plus 1.
511A
If the NZ FLAG is set (more), LOOP back to 5114H until n bytes are written.
511C
JUMP to 518EH for the next item; the text pointer is on the stack.
511E
RST 20H E7
A variable: RST 20H tests its type (VALTYP, 40AFH); the Z FLAG is set for a string.
511F
If the NZ FLAG is set (numeric), JUMP to 516CH with Register Pair HL = the variable's address.
5121
LD A,C 79
Load Register A with Register C, the length prefix n.
5122
GOSUB to BASIC 61C3H, which returns Register B = the string's length and Register Pair HL = its address.
5125
LD C,B 48
Load Register C with Register B, the string's length.
5126
LD B,A 47
Load Register B with Register A, the prefix n.
5127
LD A,C 79
Load Register A with Register C, the string's length.
5128
SUB B 90
Subtract Register B (n) from Register A: the string's length minus n.
5129
If the NO CARRY FLAG is set (the string is at least n long), JUMP to 517EH to write n characters from Register Pair HL.
512B
PUSH AF F5
Save Register Pair AF (Register A = the negative difference, minus the spaces to add) on the stack.
512C
LD A,C 79
Load Register A with Register C, the string's length.
512D
OR A B7
OR Register A with itself: the Z FLAG is set if the string is empty.
512E
If the Z FLAG is set (empty), JUMP to 5137H to write only spaces.
5130
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the string's first character.
5131
LD B,C 41
Load Register B with Register C, the string's length.
5132
INC HL 23
Increment Register Pair HL past the first character.
5133
DEC B 05
Decrement Register B: the characters after the first one.
5134
CALL 61EFH CD EF 61
GOSUB to BASIC 61EFH to write Register A and then Register B bytes from Register Pair HL: the whole string.
5137
POP HL E1
Restore Register Pair HL from the stack: Register H = the old Register A, minus the number of spaces to add.
5138
LD B,00H 06 00
Load Register B with 00H: no data bytes follow each space.
PAD WITH SPACES
Register H counts up from minus the spaces to 0.
513A
LD A,20H 3E 20
Load Register A with 20H, a space, the byte to write.
513C
CALL 61EFH CD EF 61
GOSUB to BASIC 61EFH to write the space in Register A.
513F
INC H 24
Increment Register H, the negative count, towards 0.
5140
If the NZ FLAG is set (more spaces), LOOP back to 513AH until the field is full.
5142
JUMP to 518EH for the next item; the text pointer is on the stack.
5144H - PUT to a Type M File
Register Pair HL = the item. Each item is an expression (evaluated through BASIC 61B7H), or (n)# for a string item of n 00H bytes. A number is written as its marker (72H, 73H or 74H) and its bytes; a string as 80H + length (or 71H and the length for 128 or more) and its characters, cut to the prefix n if one is given.
5144
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the item's first character.
5145
CP 23H FE 23
Compare Register A (the item's first character) against 23H, a #.
5147
If the NZ FLAG is set (not #), JUMP to 515AH: an expression.
5149
GOSUB to BASIC 62F5H, which steps past the # (error 9EH unless a prefix was given) and returns Register Pair DE = the text pointer after it.
514C
PUSH DE D5
Save Register Pair DE (the text pointer) on the stack.
514D
LD B,FFH 06 FF
Load Register B with FFH, the length to be cut to the prefix.
514F
CALL 615DH CD 5D 61
GOSUB to BASIC 615DH, which returns Register B = the prefix n and the string marker for that length: 80H + n in Register A, or 71H written and n in Register A.
5152
LD C,B 48
Load Register C with Register B, the count n.
5153
LD B,00H 06 00
Load Register B with 00H: no data bytes follow the marker.
5155
CALL 61EFH CD EF 61
GOSUB to BASIC 61EFH to write the marker in Register A.
5158
JUMP to 5111H to write Register C (n) 00H bytes.
515A
CALL 61B7H CD B7 61
GOSUB to BASIC 61B7H, which evaluates the expression at Register Pair HL and leaves the text pointer on the stack: the NZ FLAG for a number; for a string the Z FLAG, Register B = its length and Register Pair HL = its address.
515D
If the NZ FLAG is set (a number), JUMP to 5164H.
515F
CALL 615DH CD 5D 61
A string: GOSUB to BASIC 615DH for the length in Register B (the prefix, if shorter) and the marker in Register A.
5162
JUMP to 518BH to write the marker and Register B characters from Register Pair HL.
5164
LD HL,4121H 21 21 41
Load Register Pair HL with 4121H, REG 1, where the value is.
5167
If the CARRY FLAG is set (an integer or single precision value), JUMP to 516CH.
5169
LD HL,411DH 21 1D 41
Double precision: load Register Pair HL with 411DH, the low end of the double precision REG 1.
516C
LD A,72H 3E 72
Load Register A with 72H, the integer marker (511FH also enters here for a numeric type F variable, Register Pair HL = its address).
516E
LD B,02H 06 02
Load Register B with 02H, the byte count of an integer.
5170
If the SIGN FLAG is set (from the type test: an integer), JUMP to 517BH.
5173
INC A 3C
Increment Register A to 73H, the single precision marker (INC does not change the CARRY FLAG).
5174
LD B,04H 06 04
Load Register B with 04H, the byte count of a single precision value.
5176
If the CARRY FLAG is set (single precision), JUMP to 517BH.
5178
INC A 3C
Increment Register A to 74H, the double precision marker.
5179
LD B,08H 06 08
Load Register B with 08H, the byte count of a double precision value.
517B
CALL 62EEH CD EE 62
GOSUB to BASIC 62EEH: a numeric item may not have a length prefix (error 9EH).
517E
BIT 1,(IX+00H) DD CB 00 4E
Test bit 1 of the byte at Index Register IX+00H (5700H, the mode byte): letter F (5129H also enters here for a string).
5182
If the Z FLAG is set (a type M file), JUMP to 518BH to write the marker in Register A and the bytes.
5184
LD A,B 78
Type F: load Register A with Register B, the number of bytes.
5185
OR A B7
OR Register A with itself: the Z FLAG is set if there are none.
5186
If the Z FLAG is set (nothing to write), JUMP to 518EH.
5188
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the first byte, written in the marker's place.
5189
DEC B 05
Decrement Register B: one byte fewer follows.
518A
INC HL 23
Increment Register Pair HL past the first byte.
518B
CALL 61EFH CD EF 61
GOSUB to BASIC 61EFH to write Register A and then Register B bytes from Register Pair HL.
518EH - After an Item
The text pointer is on the stack. A comma takes the next item; a semicolon ends the list, and nothing may follow it.
518E
POP HL E1
Restore Register Pair HL from the stack: the text pointer after the item.
518F
DEC HL 2B
Decrement Register Pair HL, the text pointer, back one character for RST 10H.
5190
GOSUB to 4FC1H, which returns the next character of the list in Register A.
5193
LD DE,(5D5FH) ED 5B 5F 5D
Load Register Pair DE with the 16-bit value at 5D5FH, the item number (the operand of LD DE,nnnn at BASIC 5D5EH).
5197
INC DE 13
Increment Register Pair DE, the item number, for the next item.
5198
CP 2CH FE 2C
Compare Register A (the list's character) against 2CH, a comma.
519A
If the Z FLAG is set (a comma), JUMP to 4F95H to store Register Pair DE and take the next item.
519D
CP 3BH FE 3B
Compare Register A (the list's character) against 3BH, a semicolon.
519F
If the NZ FLAG is set (neither), JUMP to 51CBH for error 9CH IGEL ITEM SYNTAX ERROR.
51A2
GOSUB to 51C9H: the statement must end after the semicolon.
51A5
LD A,(IX+2DH) DD 7E 2D
Load Register A with the byte at Index Register IX+2DH (572DH, the statement flags).
51A8
BIT 2,A CB 57
Test bit 2 of Register A: set during the counting run.
51AA
RET NZ C0
If the NZ FLAG is set (the counting run), RETURN to 4F83H, after the CALL 4F8BH at 4F80H.
51AB
BIT 1,A CB 4F
Test bit 1 of Register A: set if the list was in another line.
51AD
If the Z FLAG is set (the list was in the statement), JUMP to 51B0H.
51AF
POP HL E1
Restore Register Pair HL from the stack: the statement's own text pointer saved at 4F35H, in place of the pointer into the list's line.
51B0H - End the Statement
Register Pair HL = the text pointer. Store where the statement ended as the new position of the last GET or PUT, pad a written item record where needed, copy the work area back to the file area and return to BASIC.
51B0
PUSH HL E5
Save Register Pair HL (the text pointer) on the stack.
51B1
BIT 5,(IX+2DH) DD CB 2D 6E
Test bit 5 of the byte at Index Register IX+2DH (572DH): set for the % position (4F0BH enters here).
51B5
If the NZ FLAG is set (the % position), JUMP to 51C3H.
51B7
GOSUB to BASIC 6134H, which stores NEXT (Register C and Register Pair HL) at 5704H-5706H, where the last GET or PUT ended.
51BA
CALL 6326H CD 26 63
GOSUB to BASIC 6326H: after a PUT to an item file, fill the rest of the record with 00H bytes where the type needs it.
51BD
POP HL E1
Restore Register Pair HL from the stack: the text pointer (4E34H enters here).
51BE
DEC HL 2B
Decrement Register Pair HL, the text pointer, back one character for RST 10H (4DB0H enters here).
51BF
RST 10H D7
RST 10H: step Register Pair HL to the current character and load it into Register A, with the Z FLAG set at the end of the statement (4DB9H enters here).
51C0
JUMP to BASIC 6445H, which finishes the file statement (copies 5700H-572CH back to the file area, clears 624CH's reload flag and 4369H bit 6) and returns to BASIC.
51C3
%: GOSUB to BASIC 6381H to clear 5700H-572DH and release the file area without writing it back.
51C6
POP HL E1
Restore Register Pair HL from the stack: the text pointer.
51C7
RET C9
RETURN to BASIC with Register Pair HL = the text pointer (the end-of-statement code at 6445H is not run).
51C8
DEC HL 2B
Unreferenced: decrement Register Pair HL, the text pointer (nothing jumps to 51C8H; 51A2H calls 51C9H).
51C9
RST 10H D7
RST 10H: step Register Pair HL to the next character and load it into Register A; the Z FLAG is set at the end of the statement.
51CA
RET Z C8
If the Z FLAG is set (the statement ends here), RETURN.
51CB
JP 5DF7H C3 F7 5D
JUMP to BASIC 5DF7H for error 9CH IGEL ITEM SYNTAX ERROR.
51CEH - Unused Bytes
The rest of the file.
51CE-51E7
NOP x 26 00 x 26
26 zero bytes to the end of the file (51E7H). Nothing in SYS10 reads or writes them.