From dd9ba09a7c74455f17afb515c377a217fa8be8bc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 29 Dec 2018 13:36:06 -0800 Subject: 4888 We only can't use rm32=5 when mod=0. Totally fine when it's mod=1. --- subx/examples/ex10 | Bin 165 -> 163 bytes subx/examples/ex10.subx | 4 ++-- subx/examples/ex11 | Bin 1125 -> 1117 bytes subx/examples/ex11.subx | 16 ++++++++-------- subx/examples/ex8 | Bin 139 -> 138 bytes subx/examples/ex8.subx | 2 +- subx/examples/ex9 | Bin 129 -> 127 bytes subx/examples/ex9.subx | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) (limited to 'subx/examples') diff --git a/subx/examples/ex10 b/subx/examples/ex10 index e6d8b3c4..9cdfb983 100755 Binary files a/subx/examples/ex10 and b/subx/examples/ex10 differ diff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx index 9ac6d6cb..0b937fa5 100644 --- a/subx/examples/ex10.subx +++ b/subx/examples/ex10.subx @@ -22,9 +22,9 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # argv-equal(argv[1], argv[2]) # . . push argv[2] - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . push argv[1] - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call argv-equal/disp32 # syscall(exit, EAX) diff --git a/subx/examples/ex11 b/subx/examples/ex11 index f4329e00..cdabbf0a 100755 Binary files a/subx/examples/ex11 and b/subx/examples/ex11 differ diff --git a/subx/examples/ex11.subx b/subx/examples/ex11.subx index 5acd5bf0..84ef43d9 100644 --- a/subx/examples/ex11.subx +++ b/subx/examples/ex11.subx @@ -53,12 +53,12 @@ kernel-string-equal: # s : null-terminated ascii string, benchmark : length-pre # return false # return *s1 == 0 # initialize s into EDI - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI # initialize benchmark length n into EDX - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 2/r32/EDX 0xc/disp8 . # copy *(EBP+12) to EDX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 2/r32/EDX 0xc/disp8 . # copy *(EBP+12) to EDX 8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . . # copy *EDX to EDX # initialize benchmark data into ESI - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI 81 0/subop/add 3/mod/direct 6/rm32/ESI . . . . . 4/imm32 # add to ESI # initialize loop counter i into ECX b9/copy-to-ECX 0/imm32/exit @@ -261,8 +261,8 @@ check-ints-equal: # (a : int, b : int, msg : (address array byte)) -> boolean 51/push-ECX 53/push-EBX # load args into EAX, EBX and ECX - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 3/r32/EBX 0xc/disp8 . # copy *(EBP+12) to EBX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 3/r32/EBX 0xc/disp8 . # copy *(EBP+12) to EBX # if EAX == b/EBX print('.') and return 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . . # compare EAX and EBX 75/jump-if-unequal $check-ints-equal:else/disp8 @@ -278,7 +278,7 @@ check-ints-equal: # (a : int, b : int, msg : (address array byte)) -> boolean # otherwise print(msg) $check-ints-equal:else: # copy msg into ECX - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 0x10/disp8 . # copy *(EBP+16) to ECX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 0x10/disp8 . # copy *(EBP+16) to ECX # print(ECX) # . . push args 51/push-ECX @@ -315,10 +315,10 @@ write-stderr: # s : (address array byte) -> # . . fd = 2 (stderr) bb/copy-to-EBX 2/imm32 # . . x = s+4 - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX 81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 4/imm32 # add to ECX # . . size = *s - 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 2/r32/EDX 8/disp8 . # copy *(EBP+8) to EDX + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 2/r32/EDX 8/disp8 . # copy *(EBP+8) to EDX 8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . . # copy *EDX to EDX # . . syscall b8/copy-to-EAX 4/imm32/write diff --git a/subx/examples/ex8 b/subx/examples/ex8 index dda61510..9a92bc7d 100755 Binary files a/subx/examples/ex8 and b/subx/examples/ex8 differ diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx index 75a77a50..d9234123 100644 --- a/subx/examples/ex8.subx +++ b/subx/examples/ex8.subx @@ -23,7 +23,7 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # EAX = ascii-length(argv[1]) # . . push args - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call ascii-length/disp32 # . . discard args diff --git a/subx/examples/ex9 b/subx/examples/ex9 index dc9c0e3c..ffbea21b 100755 Binary files a/subx/examples/ex9 and b/subx/examples/ex9 differ diff --git a/subx/examples/ex9.subx b/subx/examples/ex9.subx index bc842e4b..b3a125ea 100644 --- a/subx/examples/ex9.subx +++ b/subx/examples/ex9.subx @@ -26,9 +26,9 @@ 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # ascii-difference(argv[1], argv[2]) # . . push argv[2] - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) # . . push argv[1] - ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) # . . call e8/call ascii-difference/disp32 # . . discard args -- cgit 1.4.1-2-gfad0