Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Xeda112358 on February 19, 2011, 09:16:18 pm
-
Okay, so for some time I have noticed that whenever I create a variable, CheckFindSym and FindSym seem to have trouble returning the correct pointer to the variable until after the var has been used. For example, in the screenshot below, CopyProg is creating a program, then when it finds that program and copies it to Str2, it copies starting at an offset. The data copies to the program, though. After the program is executed, though, the pointer seems to be corrected.
-
Have you tried re-chkfindsym'ing the files between the copy? Creating variables changes pointers in RAM, so after creating anything, any previous pointer is invalidated. You need to check again. Just my thoughts.
-
Grr, I figured that was the problem... but what about this one? Command 41 returns some stats about the variable and I have made sure that all the other calls work properly. It uses a bcall that creates a temp list and a bcall to find the var, and that is all. You will notice that it doesn't seem to work on vars that existed before the RAM clear, but if I delete it and create a program with the same name, it works. Archiving/unarchiving does not change anything.
-
Certainly after creating a variable, ChkFindSym ought to be able to find it (although that isn't generally necessary, since the routines that create variables also return the VAT and data pointers.) Assuming, of course, that the variable name is valid and unique.
What's the exact code you're using?
-
For dim(41 command, the code is:
Call FindVarNameArc ;CDEF98 returns: HL=Data Start; A=Flash Page; BC=Size; DE=VatEntry location
push af ;F5
push de ;D5
push bc ;C5
ld de,3 ;110300
Call CreateTempList ;CD274B Creates a temp list of size DE. Returns BC=Size, DE=pointer to data
pop hl ;E1
Call SetXXXXDE ;CDEB4A Converts HL to an FP number at address pointed to by DE. DE is incremented by 9
pop hl ;E1
ld l,(hl) ;6E This is the var type
ld l,0 ;2600
Call SetXXXXDE ;CDEB4A Converts HL to an FP number at address pointed to by DE. DE is incremented by 9
pop af ;F1
ld hl,0 ;2600
ld l,a ;6F
jp SetXXXXDE ;CDEB4A Converts HL to an FP number at address pointed to by DE. DE is incremented by 9
*FindVarNameArc uses a parsed string to copy the name to OP1 and then it uses bcall(_CheckFindSym) to get the pointers. and then more code to get the size and pointer depending on archive status.
-
What about FindVarNameArc? How does that work exactly?
-
It uses a parsed string for the name of a var and pretty much returns pointers to the var.
Outputs:
A=Flash page
BC=Size
DE=Vat Entry
HL=Data start
Sorry it is taking so long to respond, I'm converting the code on the fly :D
Call LocateStr ;CDB74E Gets pointers to the next parsed string
inc de ;13 points to second byte of the string
ld a,(de) ;1A
cp $EB ;FEEB the little L token for lists
jr nz,3 ;2003
ld a,5Dh ;3E5D The byte starting lists
ld (de),a ;12
dec de ;1B
ex de,hl ;EB
ld b,c ;41
ld de,OP1 ;117884
Call TokenToASCII ;CDCF4B Used to convert tokens to ASCII (in case lowercase is involved)
xor a ;AF
ld (de),a ;12 this puts a 0 at the end of where the string was converted to (meaning OP1)
inc de ;13
ld (de),a ;12
push bc ;C5 This is the ASCII length of the var name
bcall(_CheckFindSym) ;EFF142
ld a,b ;78
pop bc ;C1
jp c,ERRBadName ;DC8D55 If the var doesn't exist, goes to error handler
ex de,hl ;EB
or a ;B7
jr nz,5 ;2005 It skips 5 bytes, not sure of the mnemonic syntax
ld c,(hl) ;4E
inc hl ;23
ld b,(hl) ;46
inc hl ;23
ret ;C9
add hl,bc ;09
ld bc,9 ;010900
add hl,bc ;09
ld b,a ;47
ld a,l ;7C
add a,a ;87
or a ;B7
jr nz,3 ;2003 Again, not sure of the syntax, sorry
inc b ;04
ld hl,40h ;2640
ld a,b ;78
out (6),a ;D306 Erm, writes a to port 6. I think that is out (*),a
ld c,(hl) ;4E
inc hl ;23
ld b,a ;47
ld a,l ;7C
add a,a ;87
or l ;B5
jr nz,6 ;2006
inc b ;04
ld hl,40h ;2640
ld a,b ;78
out (6),a ;D306
ld a,b ;78
ld b,(hl) ;46
inc hl ;23
push hl ;E5
add hl,bc ;09
ld hl,(998Dh) ;228D99 Some spot in AppBackUpScreen to save the end of the file. It isn't used yet.
pop hl ;E1
push bc ;C5 I know this can be optimised by using HL and popping later... I should do that
in a,(6) ;DB06
ld c,a ;4F
ld a,(9B71h) ;3A719B This has the return app page (set at the begginning of the hook)
out (6),a ;D306
ld a,c ;79
pop bc ;C1
ret ;C9
Also, thanks because I have been trying to get around to converting all of the code to mnemonics. This will give me a head start on that :D
-
I don't see anything obviously wrong with that code, though it's a little hard to follow. B7 is 'or a', by the way, not 'cp a'. :)
It would be simpler just to use system routines (e.g., LoadDEIndPaged) to read from the archive.
I can't seem to reproduce the problem you're seeing, though. Is that the same version of BatLib that you uploaded here (http://ourl.ca/798010)?
-
Yes, that is the same version and sorry bout the 'cp a' thing :D I'll go fix that. But yeah, the thing is that I am pretty sure it isn't the code that is wrong. I am pretty sure it is an OS problem. I am thinking that I should just open the debugger in Wabbitemu...