"basic label" jumper (in asm ofcourse)
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Whenever you execute the 'jp' or 'jr' instruction in assembly, you modify a register called the program counter. If you draw parallels, BASIC too must have some form of a program start, program end, and program counter.
http://wikiti.denglend.net/index.php?ti ... s:RAM:965F
http://wikiti.denglend.net/index.php?ti ... s:RAM:965D
http://wikiti.denglend.net/index.php?ti ... s:RAM:965B
http://wikiti.denglend.net/index.php?ti ... s:RAM:9652
How can you use these variables to search a BASIC program for all the label tokens and generate a table of labels? And once that's done, how can you intercept a Goto so that it will jump using this table instead of its default "searching the program from the top untill it finds the right label?"
Just some thoughts to get you thinking.
http://wikiti.denglend.net/index.php?ti ... s:RAM:965F
http://wikiti.denglend.net/index.php?ti ... s:RAM:965D
http://wikiti.denglend.net/index.php?ti ... s:RAM:965B
http://wikiti.denglend.net/index.php?ti ... s:RAM:9652
How can you use these variables to search a BASIC program for all the label tokens and generate a table of labels? And once that's done, how can you intercept a Goto so that it will jump using this table instead of its default "searching the program from the top untill it finds the right label?"
Just some thoughts to get you thinking.

"If SOURCE is outlawed, only outlaws will have SOURCE."
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
the code that should search the calling basic program for any labels and store them all in savesscreen (first token, second token, h, l) hl being the location of the label with the name token1+token2.
but would it? (my code so ineffecient, i know, and probebly loads of mistakes)
but would it? (my code so ineffecient, i know, and probebly loads of mistakes)
Code: Select all
Search:
ld ix,$965F ;BASIC end
ld l,(ix)
inc ix ;}load hl with basic-end
ld h,(ix)
ld ix,$965B ;BASIC start
ld c,(ix)
inc ix ;}load bc with basic-start
ld b,(ix)
push bc
SCF
CCF
sbc hl,bc ;hl is now the length (end - start)
push hl
pop bc ;length of basic prog in bc
pop hl ;begin of basic prog in hl
ld a,tLbl ;compare with tLbl
ld de,savesscreen ;destination
searchloop:
cpir ;search untill end-of-prog or Lbl encountered
ret nz ;end reached
ldi
ldi ;save 2 tokens: label name1+name2
push de
pop ix
ld (ix),h
inc ix ;token 1, token 2, h, l, next label
ld (ix),l
inc de
inc de
jr searchloop
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
I made an app with parserhook that intercepts Lbl and Goto but doesnt actually do anything with them yet, working on it..
Edit: it now works, great fun. But it only stores 16 labels* because otherwise the appvar would get huge.
*: or the same label up to 16 times, which happens when you repeat over a label.. I'll work on rejecting a label that allready exists.
note: I used my own parser equates which can be found here and it still works (for once I didn't completely mess everything up)
Edit: it now works, great fun. But it only stores 16 labels* because otherwise the appvar would get huge.
*: or the same label up to 16 times, which happens when you repeat over a label.. I'll work on rejecting a label that allready exists.
note: I used my own parser equates which can be found here and it still works (for once I didn't completely mess everything up)
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
I clocked it, and.. its crap. So just use the old Lbl I guess they weren't that bad, and they support forward refference, my code just hand controll back to the TI OS when it can't find a label, so if a Goto is a forward refference, you'd end up doing the same but with a huge overhead included, otherwise it was only a little bit faster (although it probebly makes a difference in huge programs, but just use Repeat, While and For, they're just as fast and don't need an appvar for storage)