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
Calls and Jumps

In assembly code there are labels, just as in BASIC. These labels are not tabbed like the rest of the program but are left aligned. These labels can either be labels to code or data.

An assembly program can have calls to certain routines. An example is below:

Header removed

StartProg:
      call ClearScreen
      ret
ClearScreen:
      B_CALL(_ClrLCDFull)
      ret

end

The beginning of a routine is shown by a label and the end is shown by a "ret". Note that if a routine was called, ret will return to the code below the call, while if no routine was called ret will be used to exit the program. This means that you cannot do this:

Header removed

StartProg:
      B_CALL(_ClrLCDFull)
      call ExitProg
ExitProg:
      ret

end

Because the "ret" in ExitProg would only return to the call, not exit the program.

There is a second type of call that you've already been introduced to. This is the B_CALL. This is a routine that Ti created. We use it to call premade instructions (which make this assembly programming a lot easier!). For TASM, the syntax is as follows:

B_CALL(_InstructionName)

In assembly there are also jumps. Jumps can be compared to Gotos in BASIC programming (but these actually work!). There are two types of jumps, relative and absolute.

These two types of jumps do the same thing. The relative jump jumps to a point in the code relative to where it is (+FFh or -FFh bytes maximum), while the absolute jump jumps to a specific memory address. Now we can do the exit routine we tried before using jumps:

Header removed

StartProg:
      B_CALL(_ClrLCDFull)
      jr ExitProg
ExitProg:
      ret

end

This WOULD work. The jump you see here is a relative jump.

Header removed

StartProg:
      B_CALL(_ClrLCDFull)
      jp ExitProg
ExitProg:
      ret

end

This would also work. This is an absolute jump.

Now of course in this case both of these jumps are completely unnecessary because the code would run to ExitProg anyway, but this is just to give you an idea. A relative jump only works for 255 bytes up or down your program, but it is 1 byte less.

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.