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
3939 # }
4040
4141 d.code = [
42− opcodes.load(LOmp(0), Imm(0), LOfp(44)), # "$Sys", ldt[0] -> module
43−
44− opcodes.frame(Imm(1), LOfp(52)), # types[1] -> new_frame1 (ptr)
45− opcodes.movp(LOmp(8), SOSOfp(52, 32)), # "Counting..." ->
46− opcodes.lea(LOfp(48), SOSOfp(52, 16)), #
47− opcodes.mcall(LOfp(52), Imm(0), LOfp(44)), # new_frame1, ldt[0], module
48−
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 0xe
51−
52− opcodes.frame(Imm(1), LOfp(48)), # types[1] -> new_frame2 (ptr)
53− opcodes.movp(LOmp(4), SOSOfp(48, 32)), # "%d\n" ->
54− opcodes.movw(LOfp(40), SOSOfp(48, 36)),
55− opcodes.lea(LOfp(52), SOSOfp(48, 16)), # new_frame1 ->
56− opcodes.mcall(LOfp(48), Imm(0), LOfp(44)), # new_frame2, ldt[0]
57−
58− opcodes.addw(Imm(1), NoOp(), LOfp(40)), # 1 + [i] -> i
59− opcodes.jmp(Imm(6)), # jump to 0x6
60− opcodes.ret() # 0xe: return
61− ]
42+ opcodes.load(LOmp(0), Imm(0), LOfp(44)), # "$Sys", ldt[0] -> module
43+
44+ opcodes.frame(Imm(1), LOfp(52)), # types[1] -> new_frame1 (ptr)
45+ opcodes.movp(LOmp(8), SOSOfp(32, 52)), # "Counting..." ->
46+ opcodes.lea(LOfp(48), SOSOfp(16, 52)), #
47+ opcodes.mcall(LOfp(52), Imm(0), LOfp(44)), # new_frame1, ldt[0], module
48+
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 0xe
51+
52+ opcodes.frame(Imm(1), LOfp(48)), # types[1] -> new_frame2 (ptr)
53+ opcodes.movp(LOmp(4), SOSOfp(32, 48)), # "%d\n" ->
54+ opcodes.movw(LOfp(40), SOSOfp(36, 48)),
55+ opcodes.lea(LOfp(52), SOSOfp(16, 48)), # new_frame1 ->
56+ opcodes.mcall(LOfp(48), Imm(0), LOfp(44)), # new_frame2, ldt[0]
57+
58+ opcodes.addw(Imm(1), NoOp(), LOfp(40)), # 1 + [i] -> i
59+ opcodes.jmp(Imm(6)), # jump to 0x6
60+ opcodes.ret() # 0xe: return
61+ ]
6262
6363 d.types = [
6464 dis.Type(0, 16, 1, "\xf0"),
opcodes.py+7−5
@@ -82,9 +82,11 @@ class Instruction: · 81 unmodified lines
8282 # No operand for 0x03.
8383
8484 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))")
8687 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))")
8890 else:
8991 operand = NoOperand()
9092
@@ -186,10 +188,10 @@ class ShortOffsetFP(ShortOffset): · 95 unmodified lines
186188
187189 class DoubleShortOffset(Operand):
188190
189− def __init__(self, offset0, offset1, annotation = None):
191+ def __init__(self, outer, inner, annotation = None):
190192
191− self.offset0 = offset0
192− self.offset1 = offset1
193+ self.offset0 = inner
194+ self.offset1 = outer
193195 self.annotation = annotation
194196
195197 def __str__(self):