Re: LZ: RST
[Prev][Next][Index][Thread]
The RST instruction specifies to the processor to jump to an address in memory
page 0. The only difference between a call is that a call is 3 bytes, and an
RST is 1 byte. This has some advantages...
A. When an interrupt occurs, the processor looks on the data bus for code to
execute, it executes whatever operand is there. Since you cannot place 3 bytes
on 8 data lines (the max is 1 byte, duh.) you need a 1-byte instruction. WHen
the processor executes the RST <blah> it jumps to that location, the location
is only 8 bytes long before the next rst instruction, so the rst instruction
usually calls another subroutine.
B. If youre not using interrupts, or have some unused rst's, you can use them
to optimize the size of your code, instead of making a 3-byte call, a 1-byte
rst can then call, making the code for that call 2 bytes smaller.
Heres the list of rst instructions. (these are the only ones that work, you
cant just rst to any address, because that would require 2 extra bytes for the
addr, hence a normal call statement.)
RST 00h
RST 08h
RST 10h
RST 18h
RST 20h
RST 28h
RST 30h
RST 38h
-Steve
s_wrobleski@foma.wsc.mass.edu
References: