Restart Commands

z80 » Intermediate

Similiar to calls, the rst commands jump to an address and execute code until encountering a return command. They are exactly like calls but only take up 1 byte (instead of 3). They are only capable of going to a few preset addresses. Those addresses are: $0000, $0008, $0010, $0018, $0020, $0028, $0030, and $0038.

Command Equivalent Call Description
rst 00h none Hardware Restart. It's just like when you pull out the batteries; once the calculator has power, the Program Counter is reset to $0000 and the TI86 starts executing code at $0000. Only use this if you want to reset the calculator.
rst 08h _OP1toOP2 Copies 11 bytes from _OP1 to _OP2.
rst 10h _FindSym See the section on FindSym in the Variables Section.
rst 18h _push_FP ($4827) Pushes OP1 to the Floating Point Stack
rst 20h _MOV10toOP1 Copies 10 bytes starting at the address pointed to by HL to OP1.
rst 28h _FPMULT Multiplies OP1 and OP2 and stores the result in OP1.
rst 30h _FPADD Adds OP1 and OP2 and stores the result in OP1.
rst 38h none This is the interrupt handler. See the secion on Interrupts.

Here's an example from the _FindSym section using rst 20h (_MOV10toOP1) and rst 10h (_FindSym) to find a variable.

find_variable:
	ld hl,variable-1
			;address of one byte before
			; 'variable' label
	rst 20h		;same as 'call _Mov10toOP1'
	rst 10h		;same as 'call _FindSym'
	ret
variable: .db $06,"Stupid"
			;just need the length and string
			; now because we're using the byte
			; infront of this as our type


More from z80 » Intermediate
All the Flags // Debugging // Down-Left Bug // _GetKey Codes // Logical Operators // Memory, ROM, RAM, and Safe Areas // Miscellaneous Instructions // PC and SP // Random Numbers // TI's ROM Calls // Restart Commands // Simulated 16-bit Addition // The Stack // Tables and Arrays // Text Display // Variables