Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Hot_Dog on November 17, 2010, 01:57:02 am
-
This is for Correlation, for those of you who were going to ask 8)
Let's say HL points to the token currently being read by the Parser. So if the Token is Output(, I increase HL to evaluate what the Row for the text will be. Assuming the expression isn't just a number (it could be something like A + 1), how do I easily evaluate the expression?
-
Are you using the parser hook? (I forget)
-
Are you using the parser hook? (I forget)
Yes, I'm using the parser hook
-
well then all you need to do is use pop real, I believe.
Or something to do with the FPS
-
Does HL point to the numerical data itself or the token data?
-
Does HL point to the numerical data itself or the token data?
It could be anything. HL points to the beginning of the expression for the Row of where to place the text. The expression could be 3 + 6, it could be A, it could be sin(60), or it could be 5.
For example:
Output(A + 5, 3, "TEXT")
-
Sorry, it might take a while for me to get alll the info. I had a folder named Parser Notes, but it didn't have my actual notes in it. Right now I am figuring everything out all over again... And I have to convert all the hex *groan* :D
Here is the start of the hook I have. All it does is change int( into a getKey-ish thing:
;this first section is only if you are going to run it as a program. It stores the hook in
;AppBackUpScreen and sets it up as well.
ld de,9972h ;117299 this is a appbackupscreen+256
ld a,(de) ;1A This will store the byte into a
cp 83h ;FE83 if a=83h, the hook might be active, so disable it...
jr nz,3 ;2003 ...and quit
xor a ;AF this sets a to 0
ld (de),a ;12 this disables the hook by overwriting the 83
ret ;C9
ld hl,9DB0h ;21B09D This is the location of the hook data
ld bc,512 ;010002 number of bytes left in appbackupscreen
push DE ;D5
ldir ;EDB0 this copies the hook data to 9972
pop HL ;E1 this points to the start of the hook in appbackupscreen
in a,(6) ;DB06 this checks the current page..
B_Call(5026h) ;EF2650 sets up the hook using HL=pointer to hook and a=page in memory
ret ;C9
HOOK:
add a,e ;83 necessary to start a hook
or a ;B7 like cp 0. if A=0, z flag is set
ret z ;C8
push hl ;E5 will need this later, but also need hl
ld hl,B1B1h ;21B1B1 B1 is the int( token
sbc hl,bc ;ED42 BC= the token, so if it is int(, HL-BC=0 and sets the Z flag
pop hl ;E1
jr z,2 ;2802 so if it is the right token, skip 2 bytes
xor a ;AF this is to set the z flag I think
ret ; C9
;And this is where the code gets creative. HL is the number of arguments passed and OP1 has the last argument. the arguments are stored reverse in the FPS, so it can be confusing. To pass a value, just store it to OP1 and do FE01C9... So here goes...
ld a,(843Fh) ;3A3F84 this is the key press... it is used in my quickkeys program
B_Call(478Ch) ;EF8C47 this is SetXXOP1
cp 1 ;FE01 does something flag-wise to let it exit the hook with modified Ans
ret ;C9
-
Sorry, it might take a while for me to get alll the info. I had a folder named Parser Notes, but it didn't have my actual notes in it. Right now I am figuring everything out all over again... And I have to convert all the hex *groan* :D
Here is the start of the hook I have. All it does is change int( into a getKey-ish thing:
;this first section is only if you are going to run it as a program. It stores the hook in
;AppBackUpScreen and sets it up as well.
ld de,9972h ;117299 this is a appbackupscreen+256
ld a,(de) ;1A This will store the byte into a
cp 83h ;FE83 if a=83h, the hook might be active, so disable it...
jr nz,3 ;2003 ...and quit
xor a ;AF this sets a to 0
ld (de),a ;12 this disables the hook by overwriting the 83
ret ;C9
ld hl,9DB0h ;21B09D This is the location of the hook data
ld bc,512 ;010002 number of bytes left in appbackupscreen
push DE ;D5
ldir ;EDB0 this copies the hook data to 9972
pop HL ;E1 this points to the start of the hook in appbackupscreen
in a,(6) ;DB06 this checks the current page..
B_Call(5026h) ;EF2650 sets up the hook using HL=pointer to hook and a=page in memory
ret ;C9
HOOK:
add a,e ;83 necessary to start a hook
or a ;B7 like cp 0. if A=0, z flag is set
ret z ;C8
push hl ;E5 will need this later, but also need hl
ld hl,B1B1h ;21B1B1 B1 is the int( token
sbc hl,bc ;ED42 BC= the token, so if it is int(, HL-BC=0 and sets the Z flag
pop hl ;E1
jr z,2 ;2802 so if it is the right token, skip 2 bytes
xor a ;AF this is to set the z flag I think
ret ; C9
;And this is where the code gets creative. HL is the number of arguments passed and OP1 has the last argument. the arguments are stored reverse in the FPS, so it can be confusing. To pass a value, just store it to OP1 and do FE01C9... So here goes...
ld a,(843Fh) ;3A3F84 this is the key press... it is used in my quickkeys program
B_Call(478Ch) ;EF8C47 this is SetXXOP1
cp 1 ;FE01 does something flag-wise to let it exit the hook with modified Ans
ret ;C9
Awesome, although I managed to do just that successfully. What I'm trying to do is take care of arguments. Here's my code, as well as where I'm stuck:
ParserHook:
relocate(appbackupscreen)
.db 83h ; Required for all hooks
;Check to see if the command is one of the following:
;Output to display the normal 6x8 routine. This is
;for compatability in case a user wants to update
;his program to do a different font
;
or a ;Which condition?
;If an instruction is being
;read, we don't
;waste time seeing what
;instruction it is
ret z
;For Text(), Output(), the value of register A will
;be equal to 2. We can then check the value of the
;token being used.
cp 1
jr z, _
cp 2
jr nz, Not_2
_
ld hl, ($965D) ;HL now points
;to the instruction
;being read.
;Decrease hl to check for two byte token. HL
;usually points to the second byte of a two byte token,
;if it is a two byte one
dec hl
ld a, (hl)
inc hl
cp $BB
jr z, Check_Instruction_Two_Byte_Token
;Is this the Output() statement?
cp $E0
jr z, CorrelationOutput
So, CorrelationOutput is run. How do I solve something like A + 1 in Output(A+1, 2, "A")?
-
Okay, from there you will want to check the floating point stack, but I am not sure exactly where that is (there are a few bytes in RAM that point to various points). If you used Output(Y,X,<<String>> it will put a pointer to the temporary string in OP1, X at the top of the FPS, and then Y. I am not sure if PopReal or PopRealO1 might be useful B_Calls for you??? I am not sure if they work in hooks, though.
-
Okay, from there you will want to check the floating point stack, but I am not sure exactly where that is (there are a few bytes in RAM that point to various points). If you used Output(Y,X,<<String>> it will put a pointer to the temporary string in OP1, X at the top of the FPS, and then Y. I am not sure if PopReal or PopRealO1 might be useful B_Calls for you??? I am not sure if they work in hooks, though.
I tried all this, to no avail. I think it's because Output() is a class 2 function. For example, I did Output(1,1, "AAAAAAAA"), and I could not find "AAAAAAAA" in OP1.
-
What do you mean by class 2? Sorry, I have only ever used the int( command in my parser hooks.
-
What do you mean by class 2? Sorry, I have only ever used the int( command in my parser hooks.
http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BAC. Int( is, I'm pretty sure, a class 1 function.
-
Oh, no. Now I know what you mean. Class 2 are functions like If, Repeat, While and things like that. If a function has a "(" then it is class 1. Output( is class 1, just like int(. Output isn't part of that "most programming commands" thing.
EDIT: Unless it is Class 3...