From d0d0fdb37bab5010c055fae5471f5de0ea195fb6 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 31 Mar 2019 07:28:28 -0700 Subject: 5042 --- subx/apps/pack | Bin 30368 -> 30372 bytes subx/apps/pack.subx | 68 +++++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 33 deletions(-) (limited to 'subx/apps') diff --git a/subx/apps/pack b/subx/apps/pack index 082d5856..022753ff 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ diff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index 0242b872..b87e24ba 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -1947,7 +1947,7 @@ $emit-opcodes:op2: 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EAX 0f 84/jump-if-equal $emit-opcodes:end/disp32 $emit-opcodes:op3: - # next-word(line, op3) # reuse EDX + # next-word(line, op3) # reuse op2/EDX # . . push args 52/push-EDX ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) @@ -2002,6 +2002,8 @@ $emit-opcodes:op3: # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP $emit-opcodes:end: + # . restore locals + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP # . restore registers 5b/pop-to-EBX 5a/pop-to-EDX @@ -2088,8 +2090,8 @@ $emit-sib:end: emit-disp: # line : (address stream byte), out : (address buffered-file) -> # pseudocode: # rewind-stream(line) - # var disp = 0 # var slice = {0, 0} + # var disp = 0 # while true # slice = next-word(line) # if (slice-empty?(slice)) break @@ -2119,9 +2121,7 @@ emit-disp: # line : (address stream byte), out : (address buffered-file) -> start, slice->end, '/')) + # disp = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) # . slice = next-token-from-slice(slice->start, slice->end, '/') # . . push args 51/push-ECX @@ -2244,9 +2244,9 @@ $emit-disp:disp32: e8/call parse-hex-int/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . imm = EAX + # . disp = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 4) + # emit-hex(out, disp, 4) # . . push args 68/push 4/imm32 53/push-EBX @@ -2255,10 +2255,10 @@ $emit-disp:disp32: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break e9/jump $emit-disp:break/disp32 $emit-disp:check-for-disp16: - # if (has-metadata?(slice, "disp16")) emit-hex(out, imm, 2) and break + # else if (has-metadata?(slice, "disp16")) # . EAX = has-metadata?(ECX, "disp16") # . . push args 68/push "disp16"/imm32 @@ -2271,7 +2271,7 @@ $emit-disp:check-for-disp16: 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EAX 74/jump-if-equal $emit-disp:check-for-disp8/disp8 $emit-disp:disp16: - # slice = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) + # disp = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) # . slice = next-token-from-slice(slice->start, slice->end, '/') # . . push args 51/push-ECX @@ -2289,9 +2289,9 @@ $emit-disp:disp16: e8/call parse-hex-int/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . imm = EAX + # . disp = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 2) + # emit-hex(out, disp, 2) # . . push args 68/push 2/imm32 53/push-EBX @@ -2300,10 +2300,10 @@ $emit-disp:disp16: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break e9/jump $emit-disp:break/disp32 $emit-disp:check-for-disp8: - # if (has-metadata?(slice, "disp8")) emit-hex(out, imm, 2) and break + # if (has-metadata?(slice, "disp8")) # . EAX = has-metadata?(ECX, "disp8") # . . push args 68/push "disp8"/imm32 @@ -2334,9 +2334,9 @@ $emit-disp:disp8: e8/call parse-hex-int/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . imm = EAX + # . disp = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 1) + # emit-hex(out, imm, 1) # . . push args 68/push 1/imm32 53/push-EBX @@ -2345,8 +2345,10 @@ $emit-disp:disp8: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break $emit-disp:break: + # . restore locals + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . restore registers 5b/pop-to-EBX 5a/pop-to-EDX @@ -2360,8 +2362,8 @@ $emit-disp:break: emit-imm: # line : (address stream byte), out : (address buffered-file) -> # pseudocode: # rewind-stream(line) - # var imm = 0 # var slice = {0, 0} + # var imm = 0 # while true # slice = next-word(line) # if (slice-empty?(slice)) break @@ -2392,8 +2394,6 @@ emit-imm: # line : (address stream byte), out : (address buffered-file) -> start, slice->end, '/')) + # imm = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) # . slice = next-token-from-slice(slice->start, slice->end, '/') # . . push args 51/push-ECX @@ -2518,7 +2518,7 @@ $emit-imm:imm32: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # . imm = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 4) + # emit-hex(out, imm, 4) # . . push args 68/push 4/imm32 53/push-EBX @@ -2527,10 +2527,10 @@ $emit-imm:imm32: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break e9/jump $emit-imm:break/disp32 $emit-imm:check-for-imm16: - # if (has-metadata?(slice, "imm16")) emit-hex(out, imm, 2) and break + # if (has-metadata?(slice, "imm16")) # . EAX = has-metadata?(ECX, "imm16") # . . push args 68/push "imm16"/imm32 @@ -2543,7 +2543,7 @@ $emit-imm:check-for-imm16: 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EAX 74/jump-if-equal $emit-imm:check-for-imm8/disp8 $emit-imm:imm16: - # slice = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) + # imm = parse-hex-int(next-token-from-slice(slice->start, slice->end, '/')) # . slice = next-token-from-slice(slice->start, slice->end, '/') # . . push args 51/push-ECX @@ -2563,7 +2563,7 @@ $emit-imm:imm16: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # . imm = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 2) + # emit-hex(out, imm, 2) # . . push args 68/push 2/imm32 53/push-EBX @@ -2572,10 +2572,10 @@ $emit-imm:imm16: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break e9/jump $emit-imm:break/disp32 $emit-imm:check-for-imm8: - # if (has-metadata?(slice, "imm8")) emit-hex(out, imm, 2) and break + # if (has-metadata?(slice, "imm8")) # . EAX = has-metadata?(ECX, "imm8") # . . push args 68/push "imm8"/imm32 @@ -2608,7 +2608,7 @@ $emit-imm:imm8: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # . imm = EAX 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX - # . emit-hex(out, imm, 1) + # emit-hex(out, imm, 1) # . . push args 68/push 1/imm32 53/push-EBX @@ -2617,8 +2617,10 @@ $emit-imm:imm8: e8/call emit-hex/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - # . break + # break $emit-imm:break: + # . restore locals + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # . restore registers 5b/pop-to-EBX 5a/pop-to-EDX -- cgit 1.4.1-2-gfad0 nti/profani-tty/blame/src/xmpp/capabilities.h?id=ccf71715ef92d94757c7dcefff705e9fe335fec3'>^
1
2
3
4
5