ADDRESS SPACES

KS57C2308/P2308/C2316/P2316

 

 

POP OPERATIONS

For each push operation there is a corresponding pop operation to write data from the stack back to the source register or registers: for the PUSH instruction it is the POP instruction; for CALL, the instruction RET or SRET; for interrupts, the instruction IRET. When a pop operation occurs, the SP is incremented by a number determined by the type of operation and points to the next free stack location.

POP Instructions

A POP instruction references the SP to write data stored in two 4-bit stack locations back to the register pairs and SB register. The value of the lower 4-bit register is popped first, followed by the value of the upper 4-bit register. After the POP has executed, the SP is incremented by two and points to the next free stack location.

RET and SRET Instructions

The end of a subroutine call is signaled by the return instruction, RET or SRET. The RET or SRET uses the SP to reference the six 4-bit stack locations used for the CALL and to write this data back to the PC, the EMB, and the ERB. After the RET or SRET has executed, the SP is incremented by six and points to the next free stack location.

IRET Instructions

The end of an interrupt sequence is signaled by the instruction IRET. IRET references the SP to locate the six 4-bit stack addresses used for the interrupt and to write this data back to the PC and the PSW. After the IRET has executed, the SP is incremented by six and points to the next free stack location.

SP

SP + 1

SP + 2

POP

SP SP + 2)

LOWER

UPPER

SP

SP + 1

SP + 2

SP + 3

SP + 4

SP + 5

SP + 6

RET OR SRET

SP SP + 6)

PC11 – PC8

0

0

PC13

PC12

 

 

 

 

PC3 – PC0

PC7 – PC4

00 EMB ERB PSW

0

0

0

0

 

 

 

 

 

 

 

 

 

 

 

 

IRET

 

 

SP

 

 

 

SP

 

 

 

 

SP + 6)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PC11 – PC8

 

 

 

 

 

 

 

 

SP

 

+ 1

 

 

 

 

 

 

 

 

 

 

 

0

 

0

 

 

PC13

PC12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SP + 2

 

 

PC3 – PC0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SP + 3

 

 

PC7 – PC4

 

 

SP

 

+ 4

 

 

 

 

 

 

 

 

 

 

 

IS1

 

IS0

 

EMB

 

ERB

SP

 

+ 5

 

 

 

 

PSW

 

 

 

 

 

 

 

 

 

 

 

 

 

 

C

 

SC2

 

SC1

 

SC0

 

SP + 6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NOTE: PC13 is used for KS57C2316/P2316 microcontroller

Figure 2-8. Pop-Type Stack Operations

2-14

Page 22
Image 22
Samsung KS57C2308 manual POP Operations, POP Instructions, RET and Sret Instructions, Iret Instructions, RET or Sret