The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL

ACCESSING MEMORYStack and Direct Addressing Mode


‰Only direct addressing mode is allowed for pushing or popping the stack


¾PUSH A


is invalid


¾Pushing the accumulator onto the stack must be coded as


PUSH 0E0H


Example 5-2Show the code to push R5 and A onto the stack and then pop them back them into R2 and B, where B = A and R2 = R5Solution:PUSH 05 ;push R5 onto stackPUSH 0E0H ;push register A onto stackPOP 0F0H ;pop top of stack into B

;now register B = register A

POP 02 ;pop top of stack into R2

;now R2=R6
Free download pdf