Page 3 of 3
Posted: Thu 31 Aug, 2006 6:32 pm
by DarkAuron
Well of course, but you should always push TI-BASIC to its limits. And using Return clears up any blocks its in, so it won't memory leak.
Posted: Thu 31 Aug, 2006 6:59 pm
by King Harold
but uhm, wouldnt it like return to shell/OS/calling program?
Posted: Thu 31 Aug, 2006 7:06 pm
by DarkAuron
Yes, it returns it to the calling program. But if that calling program calls itself, i.e. being recursive in a way, then you can build subroutines within a program.
Posted: Thu 31 Aug, 2006 7:18 pm
by King Harold
oh yea you did it that way..
but its still faster to do it in asm..
Posted: Thu 31 Aug, 2006 7:35 pm
by Gambit
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.
Posted: Fri 01 Sep, 2006 7:58 am
by King Harold
ok thanx mate
edit: maybe i could make a asm program to use instead of "Goto", maybe, but intercepting goto's is something for great programmers who make apps with parserhooks..
Posted: Sun 03 Sep, 2006 7:21 pm
by King Harold
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)
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
Posted: Sat 07 Oct, 2006 10:34 am
by King Harold
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)
Posted: Wed 18 Oct, 2006 7:55 am
by King Harold
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)