Let user input a number at a '?' prompt.
05F6
E5
Read
PUSH H
05FA
F6AF
ORI AF
05FB
AF
XRA A
Preserve data prog ptr on stack and restore prog ptr to HL. This should point to the name of the variable to read data into. Note we also LXI over the syntax check for a comma that's done on subsequent reads.
05FF
E3
XTHL
0600
01....
LXI B,....
0602
2C
','
Get variable value address in DE.
Preserve prog ptr and get data prog ptr into HL.
0606
E3
XTHL
Preserve variable value address on stack.
0607
D5
PUSH D
Get byte of data part of program. If this is a comma seperator then we've found our data item and can jump ahead to GotDataItem
0608
7E
MOV A,M
0609
FE2C
CPI ','
If the next byte of data is not a null byte terminating the line then syntax error out.
060E
B7
ORA A
If we're READ'ing data then jump ahead to find the next DATA statement.
0615
B7
ORA A
0616
23
INX H
We've been called by the INPUT handler, and we have more inputs to take - the interpreter allows 'INPUT A,B,C' -type statement. So here we get the next input, only Bill has made a mistake here - he prints an unnecessary '?' , so the user gets two question marks for all inputs after the first one.
061A
3E3F
MVI A,'?'
Restore variable address, advance the data ptr so it points to the start of the next data item, and assign the data item to the variable.
0620
D1
GotDataItem
POP D
0621
23
INX H
Get prog ptr off stack, and push data prog ptr, decrement prog ptr because AssignVar automatically advanced it, which we don't want.
0625
E3
XTHL
0626
2B
DCX H
Get next char of READ statement and jump back to ReadNext if the end of the line has not been reached.
End of READ statement reached.
062B
D1
POP D
062F
B7
ORA A
0630
C8
RZ
0631
EB
XCHG
0632
C26E04
JNZ 046E
Loop to find the next DATA line. Here we get the data prog ptr off the stack, and PushNextWord so the address of the next line is on the stack.
0635
E1
NextDataLine
POP H
PushNextWord has pushed the address of the next line on the stack, but it has also left this address in BC. Here we test to see if this address is null (ie the null line at the end of the program has been reached) and if so then 'Out of Data' (OD) error.
0637
79
MOV A,C
0638
B0
ORA B
0639
1E06
MVI E,06
Get the first character of the line. If it's not the DATA keyword ID then loop back to try the next line.
063E
23
INX H
0640
FE83
CPI KWID_DATA
Found a DATA line. We remove the prog ptr to the beginning of the line from the stack (we don't need it - we have the ptr in HL) and jump up to GotDataItem.
0645
C1
POP B
[Index] [Previous] [Next]