예제 #1
0
파일: isa.py 프로젝트: cfbolz/pydgin
def execute_cmp(s, inst):
    if condition_passed(s, inst.cond()):
        a, (b, _) = s.rf[inst.rn()], shifter_operand(s, inst)
        result = 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
예제 #2
0
파일: isa.py 프로젝트: cfbolz/pydgin
def execute_tst(s, inst):
    if condition_passed(s, inst.cond()):
        a, (b, cout) = s.rf[inst.rn()], shifter_operand(s, inst)
        result = trim_32(a & b)

        if inst.S():
            s.N = (result >> 31) & 1
            s.Z = result == 0
            s.C = cout

        if inst.rd() == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #3
0
파일: isa.py 프로젝트: cornell-brg/pydgin
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
예제 #4
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_cmn( s, inst ):
  if condition_passed( s, inst.cond ):
    a, (b, _) = s.rf[ inst.rn ], shifter_operand( s, inst )
    result = a + b

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

    if inst.rd == 15:
      return
  s.rf[PC] = s.fetch_pc() + 4
예제 #5
0
파일: isa.py 프로젝트: igrr/pydgin-min
def execute_cmn(s, inst):
    if condition_passed(s, inst.cond):
        a, (b, _) = s.rf[inst.rn], shifter_operand(s, inst)
        result = a + b

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

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #6
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_tst( s, inst ):
  if condition_passed( s, inst.cond ):
    a, (b, cout) = s.rf[ inst.rn ], shifter_operand( s, inst )
    result = trim_32( a & b )

    if inst.S:
      s.N = (result >> 31)&1
      s.Z = result == 0
      s.C = cout

    if inst.rd == 15:
      return
  s.rf[PC] = s.fetch_pc() + 4
예제 #7
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_bic( s, inst ):
  if condition_passed( s, inst.cond ):
    a, (b, cout) = s.rf[ inst.rn ], shifter_operand( s, inst )
    result       = a & trim_32(~b)
    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 = cout

    if inst.rd == 15:
      return
  s.rf[PC] = s.fetch_pc() + 4
예제 #8
0
파일: isa.py 프로젝트: igrr/pydgin-min
def execute_bic(s, inst):
    if condition_passed(s, inst.cond):
        a, (b, cout) = s.rf[inst.rn], shifter_operand(s, inst)
        result = a & trim_32(~b)
        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 = cout

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #9
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_mvn( s, inst ):
  if condition_passed( s, inst.cond ):
    a, cout = shifter_operand( s, inst )
    result  = trim_32( ~a )
    s.rf[ inst.rd ] = 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 = cout
      s.V = s.V

    if inst.rd == 15:
      return
  s.rf[PC] = s.fetch_pc() + 4
예제 #10
0
파일: isa.py 프로젝트: igrr/pydgin-min
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
예제 #11
0
파일: isa.py 프로젝트: igrr/pydgin-min
def execute_mvn(s, inst):
    if condition_passed(s, inst.cond):
        a, cout = shifter_operand(s, inst)
        result = trim_32(~a)
        s.rf[inst.rd] = 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 = cout
            s.V = s.V

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #12
0
파일: isa.py 프로젝트: cornell-brg/pydgin
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
예제 #13
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_adc( s, inst ):
  if condition_passed( s, inst.cond ):
    a, (b, _) = s.rf[ inst.rn ], shifter_operand( s, inst )
    result  = a + b + 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 = carry_from( result )
      s.V = overflow_from_add( a, b, result )

    if inst.rd == 15:
      return
  s.rf[PC] = s.fetch_pc() + 4
예제 #14
0
파일: isa.py 프로젝트: igrr/pydgin-min
def execute_adc(s, inst):
    if condition_passed(s, inst.cond):
        a, (b, _) = s.rf[inst.rn], shifter_operand(s, inst)
        result = a + b + 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 = carry_from(result)
            s.V = overflow_from_add(a, b, result)

        if inst.rd == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #15
0
파일: isa.py 프로젝트: cfbolz/pydgin
def execute_rsc(s, inst):
    if condition_passed(s, inst.cond()):
        a, (b, _) = s.rf[inst.rn()], shifter_operand(s, inst)
        result = b - a - (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(b, a, result)

        if inst.rd() == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #16
0
파일: isa.py 프로젝트: cfbolz/pydgin
def execute_orr(s, inst):
    if condition_passed(s, inst.cond()):
        a, (b, cout) = s.rf[inst.rn()], shifter_operand(s, inst)
        result = a | b
        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 = cout
            s.V = s.V

        if inst.rd() == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #17
0
파일: isa.py 프로젝트: cfbolz/pydgin
def execute_mov(s, inst):
    if condition_passed(s, inst.cond()):
        if inst.rd() == 15 and inst.S():
            # if not CurrentModeHasSPSR(): CPSR = SPSR
            # else:                        UNPREDICTABLE
            raise FatalError('UNPREDICTABLE in user and system mode!')

        result, cout = shifter_operand(s, inst)
        s.rf[inst.rd()] = trim_32(result)

        if inst.S():
            s.N = (result >> 31) & 1
            s.Z = trim_32(result) == 0
            s.C = cout
            s.V = s.V

        if inst.rd() == 15:
            return
    s.rf[PC] = s.fetch_pc() + 4
예제 #18
0
파일: isa.py 프로젝트: cornell-brg/pydgin
def execute_mov( s, inst ):
  if condition_passed( s, inst.cond ):
    if inst.rd == 15 and inst.S:
    # if not CurrentModeHasSPSR(): CPSR = SPSR
    # else:                        UNPREDICTABLE
      raise FatalError('UNPREDICTABLE in user and system mode!')

    result, cout = shifter_operand( s, inst )
    s.rf[ inst.rd ] = trim_32( result )

    if inst.S:
      s.N = (result >> 31)&1
      s.Z = trim_32( result ) == 0
      s.C = cout
      s.V = s.V

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