EasyManua.ls Logo

Intel 8080 - RET, RIM

Intel 8080
224 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter
3.
Instruction
Set
RET
RETURN
FROM
SUBROUTINE
The RET
in~truction
pops two bytes
of
data
off
the stack and places them
in
the program
counter
register.
Program
execution
resumes dt the new address
in
the program counter.
Typically, RET instructions are used
in
conjunction with CALL instructions. (The same
is
true
of
the variants
of
these instructions.)
In
thi'; case, it
is
assumed
that
the data the RET instruction pops
off
the stack
is
a
return address placed there
by
a previous CALL. This has the effect
of
returning control to the next instruction
after the
CALL. The user must
be
certain
that
the RET instruction finds the address
of
executable code on the
stack.
If
the instruction finds the
addre~,
of
data, the proce';sor
attempts
to execute the data as though
it
were
code.
Opcode Operand
RET
Operands are not permitted with the RET instruction.
Example:
o 0
o
(~
L-
__________________
_
Cycles:
States:
Ad
dressi
ng:
Flags:
3
10
register indirect
none
As
mentioned previously,
~ubroutines
un
be
nested. That
is,
a
~ubroutine
can
cdll
a subroutine that calls
another
subroutine. The only practical limit on the number
of
ne')ted cdlb
is
the
amount
of
memory available
for stacking return
addresse". A nested subroutine can even call the subroutine
that
called it,
as
shown
in
the
following example. (Notice
that
the program must contdin logic th.!t eventually returns control
to
the main
program.
Otherwise, the two subroutines will
cdll
edch othel indefinitely.)
MAIN
PROGRAM
1 SUBA
t~~~~~~
~~S~BB
1
~
7-
~~CALLSUBA
CALL SUBA CNZ
SUBI3
.,
~
T
T
~
T~~
___________
., ., ., ., .,
RET
RET
.,
RIM
(8085 PROCESSOR
ONLY)
READ
INTERRUPT
MASK
348
The
RIM
instruction loads eight bits
of
data
into
the accumulator. The resulting bit pattern indicates the current
setting
of
the
interrupt
mask, the setting
of
the interrupt flag, pending interrupts, and
onl:'
bit
of
serial input data,
if
any.

Table of Contents

Related product manuals