Beispiel #1
0
def sra(machine, r, adr, x):
    v = get_effective_address(machine, adr, x)
    p = l2a(machine.GR[r])
    prev_p = p
    sign = get_bit(machine.GR[r], 15)
    ans = (p >> v) & 0x7fff
    if sign == 0:
        ans = ans & 0x7fff
    else:
        ans = ans | 0x8000
    machine.GR[r] = ans
    if 0 < v:
        return flags(machine.GR[r], OF=get_bit(prev_p, v - 1))
    else:
        return flags(machine.GR[r])
Beispiel #2
0
 def print_status(self):
     try:
         code = self.dis.dis_inst(self.PR)
     except InvalidOperation:
         code = '%04x' % self.memory[self.PR]
     sys.stderr.write('PR  #%04x [ %-30s ]  STEP %d\n'
                      % (self.PR, code, self.step_count) )
     sys.stderr.write('SP  #%04x(%7d) FR(OF, SF, ZF)  %03s  (%7d)\n'
                      % (self.SP, self.SP,
                         i2bin(self.FR, 3), self.FR))
     sys.stderr.write('GR0 #%04x(%7d) GR1 #%04x(%7d) '
                      ' GR2 #%04x(%7d) GR3: #%04x(%7d)\n'
                      % (self.GR[0], l2a(self.GR[0]),
                         self.GR[1], l2a(self.GR[1]),
                         self.GR[2], l2a(self.GR[2]),
                         self.GR[3], l2a(self.GR[3])))
     sys.stderr.write('GR4 #%04x(%7d) GR5 #%04x(%7d) '
                      'GR6 #%04x(%7d) GR7: #%04x(%7d)\n'
                      % (self.GR[4], l2a(self.GR[4]),
                         self.GR[5], l2a(self.GR[5]),
                         self.GR[6], l2a(self.GR[6]),
                         self.GR[7], l2a(self.GR[7])))
Beispiel #3
0
def suba2(machine, r, adr, x):
    v = get_value_at_effective_address(machine, adr, x)
    result = l2a(machine.GR[r]) - l2a(v)
    machine.GR[r] = a2l(result)
    return flags(result)
Beispiel #4
0
def cpa1(machine, r1, r2):
    diff = l2a(machine.GR[r1]) - l2a(machine.GR[r2])
    return int(diff == 0), int(diff < 0), 0
Beispiel #5
0
def cpa2(machine, r, adr, x):
    v = get_value_at_effective_address(machine, adr, x)
    diff = l2a(machine.GR[r]) - l2a(v)
    return int(diff == 0), int(diff < 0), 0
Beispiel #6
0
def suba1(machine, r1, r2):
    result = l2a(machine.GR[r1]) - l2a(machine.GR[r2])
    machine.GR[r1] = a2l(result)
    return flags(result)
Beispiel #7
0
def adda1(machine, r1, r2):
    result = l2a(machine.GR[r1]) + l2a(machine.GR[r2])
    machine.GR[r1] = a2l(result)
    return flags(result)