This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Stack of instructions application_part2

Hi Everyone
Maybe previous a question to application external memory has confused, let me repost sample question about stack of instructions.

The assembler code is push register R0,R1 onto stack and pop register R0,R1from stack. So how to write a C51 program like this function or have any instructions?

PUSH 0 ; register R0
PUSH 1 ; register R1
.
.
.
.
POP 1 ; register R0
POP 0 ; register R1

Parents
  • Hi Hsu,

    I assume you are using the assembler and it is an 'asm' file that you are creating, if so, then this is what your code should be modified to allow you to push/pop R0:-

    MOV R0,#00 ;1 line
    CALL aa
    ;-----------
    aa:
    PUSH AR0   ;*** MODIFIED ***
    Mov R0,#ff ;2 line
    .
    .
    POP AR0    ;*** MODIFIED ***
    RET
    ;-----------
    

    I have just prefixed the register R0 with 'A' so we get AR0 when wanting to push or pop the contents of this register.
    Please note that if you start adding bank switching to your code, I have no idea (because i have not tried it) if this method still works and needs to be replaced by the less obvious pushing and poping of the specific address.

    Hope this helps,
    Mark.

Reply
  • Hi Hsu,

    I assume you are using the assembler and it is an 'asm' file that you are creating, if so, then this is what your code should be modified to allow you to push/pop R0:-

    MOV R0,#00 ;1 line
    CALL aa
    ;-----------
    aa:
    PUSH AR0   ;*** MODIFIED ***
    Mov R0,#ff ;2 line
    .
    .
    POP AR0    ;*** MODIFIED ***
    RET
    ;-----------
    

    I have just prefixed the register R0 with 'A' so we get AR0 when wanting to push or pop the contents of this register.
    Please note that if you start adding bank switching to your code, I have no idea (because i have not tried it) if this method still works and needs to be replaced by the less obvious pushing and poping of the specific address.

    Hope this helps,
    Mark.

Children
No data