Machine Language help

General Chit Chat about Sinclair Computers and their Clones
Post Reply
User avatar
blittled
Posts: 229
Joined: Fri Dec 19, 2008 3:04 am
Location: Northwestern Pennsylvania, USA

Machine Language help

Post by blittled »

I'm writing a program and the first step is determining where REMS are in the program so for the first step I wrote
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
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?
2X Timex Sinclair 1000, ZX81, ZX80Core, 5X 16K Ram Pack, ZXBlast, ZX P file to Ear Input Signal Converter, Elf II
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Machine Language help

Post by XavSnap »

Hi,
PUSH HL
LD DE,(D_FILE)
SBC HL,DE
JR C,EXIT
POP HL
Tyr a 'JP n,EXIT' .
n=true if the result is a negative value
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
GCHarder
Posts: 427
Joined: Sat Dec 14, 2013 7:46 pm

Re: Machine Language help

Post by GCHarder »

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
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Machine Language help

Post by XavSnap »

Hi,
Using the ROMs find line address routine at 09D8 LINE-ADDR
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…
Not cool !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
blittled
Posts: 229
Joined: Fri Dec 19, 2008 3:04 am
Location: Northwestern Pennsylvania, USA

Re: Machine Language help

Post by blittled »

Thanks all, I did change the JR To JP P. I forgot about the conditional JP :oops: 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.
2X Timex Sinclair 1000, ZX81, ZX80Core, 5X 16K Ram Pack, ZXBlast, ZX P file to Ear Input Signal Converter, Elf II
Post Reply