Difference between revisions of "83Plus:Hooks:9BAC"
Line 1: | Line 1: | ||
− | ''' | + | == Synopsis == |
+ | '''Name:''' Parser Hook | ||
− | + | '''Hook Pointer Block Address:''' [[83Plus:RAM:9BAC|9BAC]] | |
− | + | '''Hook Enable BCALL:''' [[83Plus:BCALLs:5026|5026]] | |
− | + | '''Hook Disable BCALL:''' [[83Plus:BCALLs:5029|5029]] | |
− | ''' | + | |
− | '''Hook | + | '''Hook Call BCALL:''' ''(none known)'' |
− | '''Hook | + | '''Hook Active Flag:''' [[83Plus:Flags:36#Bit_1|1, (iy + 36h)]] |
− | + | This hook allows you to change the behavior of the TI-BASIC parser and functions. | |
− | + | == Using the Hook == | |
+ | These different values, passed in A, determine what the hook should do. | ||
+ | * 0: The calculator is about to parse a variable. | ||
+ | ** OP1 = name of variable to be parsed. | ||
+ | ** Return Z if the variable should be parsed normally. | ||
+ | * 1-3: A BASIC function has been encountered. The various types are described below. | ||
+ | ** BC identifies the particular function within the class. For many 1-byte tokens, B is the token itself; for many others, B is the OP-number given in ti83plus.inc (although some of these are incorrect.) | ||
+ | ** Return Z to run the standard function. | ||
− | + | === Class 1 Functions === | |
− | + | Class 1 tokens all take some positive number of arguments (zero arguments is a syntax error.) These are separated by commas, or in the case of binary operators, by the operator itself. All of the arguments are evaluated before the function is. | |
− | + | The arguments are placed on the FPS in "reverse" order. That is to say, the earliest argument read is deepest in the stack. The final argument is in OP1. The total number of arguments is passed in HL. | |
− | + | ||
− | + | Any of the following data types may be used (except where prohibited by syntax rules): Real, List, Matrix, Equation, String, Complex, Complex List. Real numbers are stored on the stack as floating-point. Complex numbers are stored as two consecutive stack entries or in OP1 and OP2 (see the SDK documentation for Push/Pop OP1/3/5.) Other data types are stored as variable names. | |
− | + | ||
− | * | + | A hook may do any of the following: |
− | * | + | * Leave all arguments as is, and return Z. |
− | * | + | * Modify arguments, or add or remove them while updating HL appropriately, and return Z. |
− | + | * Remove all arguments from the FPS, place the result of your computation in OP1, and return NZ. | |
− | + | * Remove all arguments from the FPS, reset [[83Plus:Flags:7#Bit0|numOP1,(iy+ParsFlag2)]], and return NZ. (This is generally preferable if you are not returning a useful value, as it will preserve Ans.) | |
+ | |||
+ | === Class 2 Functions === | ||
+ | |||
+ | These include most "programming" commands. No arguments are parsed. | ||
+ | |||
+ | You may, if you are prepared to face the consequences, attempt to read the arguments yourself. The undocumented B_CALL [[83Plus:BCALLs:4B73|IncFetch]] can be useful in doing so. | ||
+ | |||
+ | If you return Z, the parser will run the function normally. If you return NZ, the parser will continue execution from where you left off. | ||
+ | |||
+ | === Class 3 Functions === | ||
+ | |||
+ | If very little is known about class 2, less is known about class 3. Tenatively, it looks like the class 2 functions that you would expect to be class 1 have class 3 secondary callbacks. | ||
− | + | It looks like the parameters are stored in OP1 and the FPS as in class 1, but there is the rather significant problem that the number of arguments is not in HL. If it's stored somewhere else, I don't know about it, though I haven't looked very hard. | |
− | + | ||
== Credits and Contributions == | == Credits and Contributions == | ||
− | * ''' | + | * '''Brandon Sterner:''' Analysis, and the Symbolic source code. |
+ | * '''Michael Vincent:''' The Omnicalc source code. |
Revision as of 23:04, 27 March 2005
Contents
Synopsis
Name: Parser Hook
Hook Pointer Block Address: 9BAC
Hook Enable BCALL: 5026
Hook Disable BCALL: 5029
Hook Call BCALL: (none known)
Hook Active Flag: 1, (iy + 36h)
This hook allows you to change the behavior of the TI-BASIC parser and functions.
Using the Hook
These different values, passed in A, determine what the hook should do.
- 0: The calculator is about to parse a variable.
- OP1 = name of variable to be parsed.
- Return Z if the variable should be parsed normally.
- 1-3: A BASIC function has been encountered. The various types are described below.
- BC identifies the particular function within the class. For many 1-byte tokens, B is the token itself; for many others, B is the OP-number given in ti83plus.inc (although some of these are incorrect.)
- Return Z to run the standard function.
Class 1 Functions
Class 1 tokens all take some positive number of arguments (zero arguments is a syntax error.) These are separated by commas, or in the case of binary operators, by the operator itself. All of the arguments are evaluated before the function is.
The arguments are placed on the FPS in "reverse" order. That is to say, the earliest argument read is deepest in the stack. The final argument is in OP1. The total number of arguments is passed in HL.
Any of the following data types may be used (except where prohibited by syntax rules): Real, List, Matrix, Equation, String, Complex, Complex List. Real numbers are stored on the stack as floating-point. Complex numbers are stored as two consecutive stack entries or in OP1 and OP2 (see the SDK documentation for Push/Pop OP1/3/5.) Other data types are stored as variable names.
A hook may do any of the following:
- Leave all arguments as is, and return Z.
- Modify arguments, or add or remove them while updating HL appropriately, and return Z.
- Remove all arguments from the FPS, place the result of your computation in OP1, and return NZ.
- Remove all arguments from the FPS, reset numOP1,(iy+ParsFlag2), and return NZ. (This is generally preferable if you are not returning a useful value, as it will preserve Ans.)
Class 2 Functions
These include most "programming" commands. No arguments are parsed.
You may, if you are prepared to face the consequences, attempt to read the arguments yourself. The undocumented B_CALL IncFetch can be useful in doing so.
If you return Z, the parser will run the function normally. If you return NZ, the parser will continue execution from where you left off.
Class 3 Functions
If very little is known about class 2, less is known about class 3. Tenatively, it looks like the class 2 functions that you would expect to be class 1 have class 3 secondary callbacks.
It looks like the parameters are stored in OP1 and the FPS as in class 1, but there is the rather significant problem that the number of arguments is not in HL. If it's stored somewhere else, I don't know about it, though I haven't looked very hard.
Credits and Contributions
- Brandon Sterner: Analysis, and the Symbolic source code.
- Michael Vincent: The Omnicalc source code.