예제 #1
0
def _pop_2_mem(sgm, index):
    dec_sp()  # Mem[SP] = Mem[SP] - 1
    asm.set_areg_from_sgm()  # A=M
    asm.set_dreg_from_sgm()  # D=M
    asm.set_areg('%s' % asm.sgm_2_reg(sgm))  # @reg
    asm.inc_areg(index)  # Loop: A=A+1
    asm.set_sgm_from_dreg()  # M=D
예제 #2
0
def _push(sgm, index):
    asm.set_areg_from_reg('%s' % asm.sgm_2_reg(sgm))  # @REGISTER, A=M
    asm.inc_areg(index)  # Loop: A=A+1
    asm.set_dreg_from_sgm()  # D=M
    asm.set_areg_from_reg('SP')  # @SP, A=M
    asm.set_sgm_from_dreg()  # M=D
    inc_sp()  # Mem[SP] = Mem[SP] + 1