Mian Qi - 2024-03-13
demo for stack - push/pop
;The storing of a CPU register in the stack is called a PUSH.
;The loading of the contents of the stack back into a CPU register is called a POP.

    org 00h

Main:

;set SP at the default location  - 07h - 0000 0111B
Default:
    mov R2, #12h
    mov R3, #22h
    mov R4, #32h
    mov R5, #42h
    mov R6, #52h
    mov R7, #62h

    push    2
    push    3
    push    4
    push    5
    push    6
    push    7

Second:
    mov SP, #28h    ;set RAM location 28h as the first stack location

    push    2
    push    3
    push    4
    push    5
    push    6
    push    7

Third:
    setb    PSW.3
    setb    PSW.4

    mov R2, #13h
    mov R3, #23h
    mov R4, #33h
    mov R5, #43h
    mov R6, #53h
    mov R7, #63h

Fourth:
    push    2
    push    3
    push    4
    push    5
    push    6
    push    7

    pop 2
    pop 3
    pop 4
    pop 5
    pop 6
    pop 7

Fifth:
    pop 2
    pop 3
    pop 4
    pop 5
    pop 6
    pop 7

    pop 2
    pop 3
    pop 4
    pop 5
    pop 6
    pop 7


    end

when I tested this code, the simulator didn't pop the second push value.