Machine Language help
Posted: Thu Oct 31, 2019 2:08 am
I'm writing a program and the first step is determining where REMS are in the program so for the first step I wrote
In the NOREM section I add the line length (BC) to the Pointer (HL) I then check to see if the Pointer is equal to or passes the D_FILE address with SBC HL,DE but It is incorrect since it only looks at the first line in the program. What is the best way to check to see if HL is equal to or greater than the D_FILE address?READPRG:
LD HL, STARTPROG
REMLOOP:
INC HL // Bypass line number
INC HL
LD A,(HL) // Get length of line
LD C,A
INC HL
LD A,(HL)
LD B, A
DEC BC // Adjust for HL to read first token
INC HL
LD A,(HL)
CP $EA // check for REM
JR NZ,NOREM
LD DE,(rems) // Increment number of rems found
INC DE
LD (rems),DE
NOREM:
ADC HL,BC // Point to next line
PUSH HL
LD DE,(D_FILE)
SBC HL,DE
JR C,EXIT
POP HL
JP REMLOOP
EXIT:
POP HL
LD BC,(rems) // Return with number of rems
RET