Texas Instruments TI89 Developer Guide - Page 71
Sample ASM Program, power mode until a key is pressed. The key code for the pressed key is stored
UPC - 033317198566
View all Texas Instruments TI89 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 71 highlights
Chapter 6: Assembly Language Programming Overview 29 6.6. Sample ASM Program ASM programs do not have to be written in assembly language. Here is a sample ASM written in C. ASM program waitkey accepts a keypress from the user. It turns on the PAUSE indicator in the status line and puts the calculator in low power mode until a key is pressed. The key code for the pressed key is stored in a variable of the programmer's choosing. /* ASM program to wait for a keypress. Go into idle mode until a key is pressed. */ #include "tiams.h" /* Entry point must be called main */ void main(void) { Access_AMS_Global_Variables; Event e; USHORT ch; EStackIndex varname; varname = top_estack; /* Argument must be string containing name of a variable */ if (ESTACK(varname) != STR_DATA_TAG) ER_throw(ER_ARG_MUST_BE_STRING); /* Get pointer to beginning of variable name */ varname = next_expression_index(varname-1) + 2; /* Make sure name is legal and not reserved for something else */ if (TokenizeSymName(varname, TSF_PASS_ERRORS) == NULL) ER_throw(ER_INDIR_STRING_NOT_VARNAME); varname = top_estack; /* Get a keypress */ while ((ch = EV_getc(ST_PAUSE, &e)) == 0) ; /* Push character number onto estack */ push_ushort_to_integer(ch); /* Pop character number into variable */ VarStore(varname, STOF_ESI, 0, top_estack); } To get a keypress code into, say, variable k, in your TI-BASIC program call waitkey("k"). TI-89 / TI-92 Plus Developer Guide Not for Distribution Beta Version January 26, 2001