E-mail Address
Password

Register
arasian > support > education > tutorial

Ti-83 and Ti-84 Assembly Programming
Getting Started
     1.1: About This Tutorial
     1.2: About TI-ASM
     1.3: Writing Your First Program
     1.4: Compiling
     1.5: Debugging
ASM Basics
     2.1: Calls and Jumps
     2.2: Registers
     2.3: Displaying Text
System Controls and Calls
     3.1: Data
     3.2: Register Stack
     3.3: If Statements (Comparing)
     3.4: GetKey and GetCSC
     3.5: System Flags
     3.6: Menus
     3.7: Displaying Pictures
     3.8: For Loops (djnz)
     3.9: White Loops
     3.10: OP Registers
Applications
     4.1: Apps vs ASM
     4.5: KeyHooks
System Flags

System flags are bits used to store options. The bit is either set to on (1) or off (0) to store an option. Setting and resetting system flags are easy.

SetTI:
      set textInverse,(IY+textFlags)

"set" turns a bit on. "res" turns a bit off. "bit" tests a bit, and returns 0 if it is set, and nz if the flag is not set (I think, it might be reversed). So let's make a program that switches textInverse on and off when you press Enter.

.NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#include "ti83plus.inc"
.LIST

     .org 9D93h
     .db $BB,$6D

StartProg:
     res textInverse,(IY+textFlags)
ProgLoop:
     ld a,0
     ld (CURROW),a
     ld a,0
     ld (CURCOL),a
     bit textInverse,(IY+textFlags)
     jp z,IsSet
     jp IsNotSet
IsSet:
     ld hl,txtIsSet
     B_CALL(_PutS)
     jp GetKeyLoop
IsNotSet:
     ld hl,txtIsNotSet
     B_CALL(_PutS)
     jp GetKeyLoop
GetKeyLoop:
     B_CALL(_GetKey)
     cp kEnter
     jp z,ToggleTxtI
     cp kClear
     jp z,ExitProg
     cp kQuit
     jp z,ExitProg
     jp GetKeyLoop
ToggleTxtI:
     bit textInverse,(IY+textFlags)
     jp z,ResTI
     jp SetTI
ResTI:
     res textInverse,(IY+textFlags)
     jp ProgLoop
SetTI:
     set textInverse,(IY+textFlags)
     jp ProgLoop
ExitProg:
     B_CALL(_ClrLCDFull)
     B_CALL(_ClrTxtShd)
     ret

txtIsSet:
     .db "Is Set ",0
txtIsNotSet:
     .db "Not Set",0

.end

This may look complicated, but all of it you know how to do. It's only some jumps, getkey, testing flags, and putting text on the screen. If you think that this is too much code for just doing this, you shouldn't be programming in assembly. If BASIC could even do the same thing, and even though this is much more code, this would be at least 10 times faster than fewer lines that do the same thing in BASIC.

With your new knowledge, we can create a menu.

Creative Commons License
The text in this tutorial is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Privacy Policy | Contact Us
(c) 1999-2010 Arasian. All rights reserved.