TI 83 Plus Assembly/Input
There are three ways to receive input from an assembly program on your TI-83+. The first two are ROM calls, and the last one is directly interfacing with the calculator's keypad.
The ROM calls
These are two routines called with the b_call() macro. They are both good ways to receive input.
This routine will wait for the user to press a key, and only when the user does, will it return to the main program. What is nice about this routine is that it processes [2nd] and [Alpha] key presses for you. Parameters: None Returns:Key value in the accumulator To see a list of the codes, click here
.include "ti83plus.inc" . . . waitForUser: bCall(_GetKey) ; [x]Or: rst $28 \ .dw $4972 ; [x]Or: bCall($4972) cp kEnter jr nz,waitForUser jr continue continue: . . .
So, the example is a simple program that pauses execution until the user presses the [Enter] key.
This routine is like the GetKey routine, except for two things. The first is that, unlike the GetKey routine, it will not wait for the user to press a key. The second is that it uses a different set of key codes, which you can find here. Also, it does not process key combinations, but you can make your own parser for them.
Parameters: None Returns:Key Code in accumulator if key was pressed, else 0 (In the accumulator). Example:
.include "ti83plus.inc" . . . waitForUserCSC: bCall(_GetCSC) cp 0 jr z,waitForUserCSC jr nz,continue continue: . . .
This example waits until ANY key is pressed.
Note:This is a more advanced method, because it deals directly with the keyboard driver. The keypad of the TI 83+ calculator is divided into Seven sections. These are:
- The arrow keys
- [ENTER], going vertically to [CLEAR]
- [(-)], going vertically to [VARS]
- [.], going vertically to [DEL]
- , going vertically to [MODE]
- [STO->], going vertically to [2ND]
- [Y=], going horizontally to [GRAPH]
To read a value from the keys of a group, you must first turn the group on. This is done by writing to port 1 (01 hex.).
Bit 0 - Group 1
Bit 1 - Group 2
Bit 2 - Group 3
And so on. To turn a group on, you set its designated bit to 0 (zero).
. . . waitForUserInputDirect: ; You cannot write an actual value to one of the ports. You must forward it through the (a) register. ; Use group '1' ld a,%11111101 out ($01),a ; Read in a value in a,($01) ; Test bit 0 (Enter) bit 0,a ; If true, goto continue jr z,continue ; Else jr waitForUserInputDirect continue: . . .
It does the same thing as the previous two examples. Note that this method does not require any ROM calls, and is less readable. For a list of keycodes, go here.