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
Machine Language help
Machine Language help
I'm writing a program and the first step is determining where REMS are in the program so for the first step I wrote
2X Timex Sinclair 1000, ZX81, ZX80Core, 5X 16K Ram Pack, ZXBlast, ZX P file to Ear Input Signal Converter, Elf II
Re: Machine Language help
Hi,
n=true if the result is a negative value
Tyr a 'JP n,EXIT' .PUSH HL
LD DE,(D_FILE)
SBC HL,DE
JR C,EXIT
POP HL
n=true if the result is a negative value
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Machine Language help
Using the ROMs find line address routine at 09D8 LINE-ADDR. may work better. or not, for your REM loop.
For a given BASIC line number this subroutine will return the starting address of the actual line or the starting address of the following line if it does not exist (C reset).
09D8 LINE-ADDR PUSH HL
LD HL,+PROGRAM
LD D,H
LD E,L
09DE NEXT-TEST POP BC
CALL 09EA,CP-LINES
RET NC
PUSH BC
CALL 09F2,NEXT-ONE
EX DE,HL
JR 09DE,NEXT-TEST
For a given BASIC line number this subroutine will return the starting address of the actual line or the starting address of the following line if it does not exist (C reset).
09D8 LINE-ADDR PUSH HL
LD HL,+PROGRAM
LD D,H
LD E,L
09DE NEXT-TEST POP BC
CALL 09EA,CP-LINES
RET NC
PUSH BC
CALL 09F2,NEXT-ONE
EX DE,HL
JR 09DE,NEXT-TEST
Re: Machine Language help
Hi,
Not cool !
Yes, this ROM sub-routine seem working in a pure ASM program, but it erase some Basic variables and the Basic monitor seem to hang if you try to back to the Basic program…Using the ROMs find line address routine at 09D8 LINE-ADDR
Not cool !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Machine Language help
Thanks all, I did change the JR To JP P. I forgot about the conditional JP
The Line-ADDR Routine does look helpful but I got my routine working with my code so I'll keep it as is.
My idea is to use REM lines for DATA. Each REM will have RTTTL data for use with the ZX-GAME in it. From that I will build a look up table with each entry containing 10 bytes for name, length of RTTTL and Start address of RTTTL. I will then use the LUT to construct a menu that you can select a song from to play.

My idea is to use REM lines for DATA. Each REM will have RTTTL data for use with the ZX-GAME in it. From that I will build a look up table with each entry containing 10 bytes for name, length of RTTTL and Start address of RTTTL. I will then use the LUT to construct a menu that you can select a song from to play.
2X Timex Sinclair 1000, ZX81, ZX80Core, 5X 16K Ram Pack, ZXBlast, ZX P file to Ear Input Signal Converter, Elf II