[TI ASM] labeljumper code

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

[TI ASM] labeljumper code

Post by King Harold »

Code: Select all

.define BasicPC $965D
.define BasicStart $965B
.define BasicEnd $965F
	Main
		bcall(_AnsName)
		bcall(_CkOP1Real)
		cp StrngObj
		jr nz,Search
		bcall(_RclVarSym)
		
		ex de,hl
		ld e,(hl)	;ans is a string so try to jump
		inc hl
		ld d,0
		inc hl
		ex de,hl
		ld a,e
		ld hl,savesscreen
jumploop:
		cp (hl)
		jr z,foundmsb
		inc hl
		inc hl
		inc hl
		inc hl
		jr jumploop
foundmsb:
		ld a,d
		inc hl
		cp (hl)
		jr z,foundlbl
		inc hl
		inc hl
		inc hl
		ld a,e
		jr jumploop
foundlbl:
		inc hl
		ld d,(hl)
		inc hl
		ld e,(hl)
		ld (BasicPC),de
		ret
		
Search:
		ld ix,BasicEnd	;BASIC end
		ld l,(ix)
		inc ix		;}load hl with basic-end
		ld h,(ix)
		ld ix,BasicStart	;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
you guessed it: it doesnt work
i dont see what's wrong with it (well, i do, but those arent things that would stop it from working..)
could someone check it please?
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

So you save the label's "name" and then search through the program untill you encounter that particular name? If this is correct, I see a number of issues. First of all, the name doesn't mean anything without a label token in front of it. Second of all, how do you handle labels that have only one character? Your routine appears to be reading two tokens regardless, which means that it will only find a single character label if the token after it is the same as the token after the one in the goto command. Not good.
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

so you mean i save t?, tEnter and you input t?,tGoto and that doesnt match..
dont forget i only just started this little project..

oh and i dont have to store the lable token since its allways the same, namely tLabel, so why store it?

is the way in loading the saved number into BasicPC even allowed though? (if so, would it switch my MSB and LSB?)
User avatar
Saibot84
New Member
Posts: 38
Joined: Fri 17 Feb, 2006 9:14 pm
Location: Jersey City, NJ

Post by Saibot84 »

in your scanning routine, instead of reading the 2 bytes after the label token (and saving this to the table), you should at least make sure that the second byte is not $3F (IIRC, this is the NewLine token). ATM, I don't remember what happens when you put Lbl ABC or LblAPause, but you should check that in TIOS first so that your routine will correctly handle these.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

well.. neither labels with more then 2 tokens nor labels with tokens other then A-Z + 0-9 + theta.
ofcourse it doesnt handle them in any way yet, and it probebly keeps looking for a label untill the end of the memory if it isnt in the program..
but you know, i first need a simple, bug-infested routine that works, and then i'll get the bugs out of it, it was to work first though
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

@thegamefreak0134: oh no i save to savesscreen along with the pointer, then search savesscreen for the label and directly load the pointer into the basic-pc
because what i NOT wanted to do was search the whole program, the whole point is NOT searching the whole program

has anyone noticed that ld reg8,(hl) is the same as ld reg8,imm8?
(the first one looks like it would load the next byte in the program to reg8)
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

<hit's head> Duh. OK, I feel really stupid now for not seeing that. I thought that code was what searched the program to save the labels to savescreen in the first place.

I'm stumped. I could help out, but I find it difficult to follow the flow of the program cause I'm not the one who wrote it...

-gamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

thanx for trying anyway
Post Reply