Esempio n. 1
0
def execute_cmp(s, inst):
    if condition_passed(s, inst.cond):
        a, (b, _) = s.rf[inst.rn], shifter_operand(s, inst)
        result = intmask(a - b)

        s.N = (result >> 31) & 1
        s.Z = trim_32(result) == 0
        s.C = not_borrow_from(result)
        s.V = overflow_from_sub(a, b, result)

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
Esempio n. 2
0
def execute_sbc(s, inst):
    if condition_passed(s, inst.cond):
        a, (b, _) = s.rf[inst.rn], shifter_operand(s, inst)
        result = intmask(a - b - (not s.C))
        s.rf[inst.rd] = trim_32(result)

        if inst.S:
            if inst.rd == 15: raise FatalError('Writing SPSR not implemented!')
            s.N = (result >> 31) & 1
            s.Z = trim_32(result) == 0
            s.C = not_borrow_from(result)
            s.V = overflow_from_sub(a, b, result)

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4