History

Changed the order of offsets passed to double indirection operands to reflect the order used in the standard Dis assembler notation.

David Boddie committed 9 years ago

Commit 3740cbe1 parent a8c27d92 files · +27 −25Browse files

Unified · Split

2 files
  1. Tests/count.py +20 −20
  2. opcodes.py +7 −5
Tests/count.py+20−20
@@ -39,26 +39,26 @@ if __name__ == "__main__": · 38 unmodified lines
39 # }39 # }
40 40
41 d.code = [41 d.code = [
42 opcodes.load(LOmp(0), Imm(0), LOfp(44)), # "$Sys", ldt[0] -> module42 opcodes.load(LOmp(0), Imm(0), LOfp(44)), # "$Sys", ldt[0] -> module
43 43
44 opcodes.frame(Imm(1), LOfp(52)), # types[1] -> new_frame1 (ptr)44 opcodes.frame(Imm(1), LOfp(52)), # types[1] -> new_frame1 (ptr)
45 opcodes.movp(LOmp(8), SOSOfp(52, 32)), # "Counting..." ->45 opcodes.movp(LOmp(8), SOSOfp(32, 52)), # "Counting..." ->
46 opcodes.lea(LOfp(48), SOSOfp(52, 16)), # 46 opcodes.lea(LOfp(48), SOSOfp(16, 52)), #
47 opcodes.mcall(LOfp(52), Imm(0), LOfp(44)), # new_frame1, ldt[0], module47 opcodes.mcall(LOfp(52), Imm(0), LOfp(44)), # new_frame1, ldt[0], module
48 48
49 opcodes.movw(Imm(0), LOfp(40)), # 0 -> i (int)49 opcodes.movw(Imm(0), LOfp(40)), # 0 -> i (int)
50 opcodes.blew(Imm(0x14), SOfp(40), Imm(0xe)),# 0x6: if 20 <= i branch to 0xe50 opcodes.blew(Imm(0x14), SOfp(40), Imm(0xe)),# 0x6: if 20 <= i branch to 0xe
51 51
52 opcodes.frame(Imm(1), LOfp(48)), # types[1] -> new_frame2 (ptr)52 opcodes.frame(Imm(1), LOfp(48)), # types[1] -> new_frame2 (ptr)
53 opcodes.movp(LOmp(4), SOSOfp(48, 32)), # "%d\n" -> 53 opcodes.movp(LOmp(4), SOSOfp(32, 48)), # "%d\n" ->
54 opcodes.movw(LOfp(40), SOSOfp(48, 36)),54 opcodes.movw(LOfp(40), SOSOfp(36, 48)),
55 opcodes.lea(LOfp(52), SOSOfp(48, 16)), # new_frame1 ->55 opcodes.lea(LOfp(52), SOSOfp(16, 48)), # new_frame1 ->
56 opcodes.mcall(LOfp(48), Imm(0), LOfp(44)), # new_frame2, ldt[0]56 opcodes.mcall(LOfp(48), Imm(0), LOfp(44)), # new_frame2, ldt[0]
57 57
58 opcodes.addw(Imm(1), NoOp(), LOfp(40)), # 1 + [i] -> i58 opcodes.addw(Imm(1), NoOp(), LOfp(40)), # 1 + [i] -> i
59 opcodes.jmp(Imm(6)), # jump to 0x659 opcodes.jmp(Imm(6)), # jump to 0x6
60 opcodes.ret() # 0xe: return60 opcodes.ret() # 0xe: return
61 ]61 ]
62 62
63 d.types = [63 d.types = [
64 dis.Type(0, 16, 1, "\xf0"),64 dis.Type(0, 16, 1, "\xf0"),
opcodes.py+7−5
@@ -82,9 +82,11 @@ class Instruction: · 81 unmodified lines
82 # No operand for 0x03.82 # No operand for 0x03.
83 83
84 elif operand == 0x04:84 elif operand == 0x04:
85 operand = DoubleShortOffsetMP(read_OP(f), read_OP(f), "SO(SO(MP))")85 inner, outer = read_OP(f), read_OP(f)
86 operand = DoubleShortOffsetMP(outer, inner, "SO(SO(MP))")
86 elif operand == 0x05:87 elif operand == 0x05:
87 operand = DoubleShortOffsetFP(read_OP(f), read_OP(f), "SO(SO(FP))")88 inner, outer = read_OP(f), read_OP(f)
89 operand = DoubleShortOffsetFP(outer, inner, "SO(SO(FP))")
88 else:90 else:
89 operand = NoOperand()91 operand = NoOperand()
90 92
@@ -186,10 +188,10 @@ class ShortOffsetFP(ShortOffset): · 95 unmodified lines
186 188
187class DoubleShortOffset(Operand):189class DoubleShortOffset(Operand):
188 190
189 def __init__(self, offset0, offset1, annotation = None):191 def __init__(self, outer, inner, annotation = None):
190 192
191 self.offset0 = offset0193 self.offset0 = inner
192 self.offset1 = offset1194 self.offset1 = outer
193 self.annotation = annotation195 self.annotation = annotation
194 196
195 def __str__(self):197 def __str__(self):