Call — Call Procedure - Samsung S3F84B8 User Manual

8-bit cmos
Hide thumbs Also See for S3F84B8:
Table of Contents

Advertisement

S3F84B8_UM_REV 1.00
6.3.13 CALL — CALL PROCEDURE
dst
CALL
SP
Operation:
@SP
SP
@SP
PC
The current contents of program counter are pushed onto the top of stack. Here, the program
counter value used specifies the address of first instruction following the CALL instruction. The
specified destination address is then loaded into the program counter and it points to the first
instruction of a procedure. At the end of the procedure, the return instruction (RET) can be used
to return to the original program flow. RET pops the top of stack back into the program counter.
No flags are affected.
Flags:
Format:
opc
opc
opc
Given R0 = 35H, R1 = 21H, PC = 1A47H, and SP = 0002H:
Examples:
CALL
CALL
CALL
In the first example, if the program counter (PC) value is 1A47H and the stack pointer contains
the value 0002H, the statement "CALL 3521H" pushes the current PC value onto the top of
stack. The stack pointer now points to memory location 0000H. PC is then loaded with the value
3521H, the address of first instruction in the program sequence to be executed.
If the contents of program counter and stack pointer are the same (as specified in the first
example), the statement "CALL @RR0" produces the same result, except that 49H is stored in
stack location 0001H (because the two-byte instruction format was used). PC is then loaded with
the value 3521H, the address of first instruction in the program sequence to be executed.
Assuming the contents of program counter and stack pointer are the same (as specified in the
first example), if program address 0040H contains 35H and program address 0041H contains
21H, the statement "CALL #40H" produces the same result (as specified in the second example).
SP – 1
PCL
SP –1
PCH
dst
dst
dst
dst
3521H 
SP = 0000H
(Memory locations 0000H = 1AH, 0001H = 4AH, where
4AH is the address that follows the instruction.)
@RR0 
SP = 0000H (0000H = 1AH, 0001H = 49H)
#40H
SP = 0000H (0000H = 1AH, 0001H = 49H)
Bytes
Cycles
3
2
2
6-25
6 INSTRUCTION SET
Opcode
(Hex)
14
F6
12
F4
14
D4
Addr Mode
dst
DA
IRR
IA

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents