回覆列表
  • 1 # 我是阿嘛

    atmel公司的晶片手冊關於RETI是這麼說的

    Description: RETI pops the high- and low-order bytes of the PC successively from the stack and restores the interrupt logic to accept additional interrupts at the same priority level as the one just processed. The Stack Pointer is left decremented by two. No other registers are effected; the PSW is not automatically restored to its pre-interrupt status. Program execution continues at the resulting address, which is generally the instruction immediately afte the point at which the interrupt request was detected. If a lower- or same-level interrupt was pending when the RETI instruction is executed, that one instruction is executed before the pending interrupt is processed.

    而RET是這麼說的

    Description: RET pops the high- and low-order bytes of the PC successively from the stack, decrementing the Stack Pointer by two. Program execution continues at the resulting address, generally the instruction immediately following an ACALL or LCALL. No flags are affected.

    舉例說明:

    假設SP為60H

    MOV A,#12H

    PUSH ACC ;SP=61H, 61H地址的內容為0x12

    MOV A,#13H

    PUSH ACC ;SP=62H, 62H地址中的內容為0x13

    RET ;SP=60H, PC=0x1312;

    完整的程式:可以在KEIL裡面軟體模擬看看結果

    ORG 0000H

    LJMP MAIN

    ORG 0100H

    MAIN:

    MOV SP, #60H

    MOV A, #12H

    PUSH ACC

    MOV A, #13H

    PUSH ACC

    RET

    ORG 1312H

    SJMP $ //原地跳轉

    END

  • 中秋節和大豐收的關聯?
  • 重返狼群讓我們懂得什麼了?