From e5cbbea435524ecd77f4ebabaab873720c64464f Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 26 Nov 2018 00:26:20 -0800 Subject: 4780 --- subx/050_write.subx | 1 - subx/051test.subx | 1 - subx/052kernel_string_equal.subx | 1 - subx/053new_segment.subx | 2 +- subx/054string_equal.subx | 1 - subx/055trace.subx | 1 - subx/056write.subx | 1 - subx/057stop.subx | 1 - subx/058read.subx | 1 - subx/059read-byte.subx | 1 - subx/060write-stream.subx | 1 - subx/examples/ex1.subx | 1 + subx/examples/ex11.subx | 2 +- subx/examples/ex12.subx | 1 + subx/examples/ex2.subx | 1 + subx/examples/ex3.subx | 1 + subx/examples/ex4.subx | 2 ++ subx/examples/ex6.subx | 1 + subx/examples/ex7.subx | 1 + subx/examples/ex8.subx | 1 + subx/examples/ex9.subx | 1 + 21 files changed, 12 insertions(+), 12 deletions(-) diff --git a/subx/050_write.subx b/subx/050_write.subx index 78fdecdd..8a65fc05 100644 --- a/subx/050_write.subx +++ b/subx/050_write.subx @@ -1,7 +1,6 @@ # _write: write to a file descriptor == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/051test.subx b/subx/051test.subx index a9f854c0..ec80adee 100644 --- a/subx/051test.subx +++ b/subx/051test.subx @@ -1,7 +1,6 @@ # Rudimentary test harness == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/052kernel_string_equal.subx b/subx/052kernel_string_equal.subx index 6dabd032..341607b5 100644 --- a/subx/052kernel_string_equal.subx +++ b/subx/052kernel_string_equal.subx @@ -15,7 +15,6 @@ # would cause tests to not run, rather than to fail as we'd like.) == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/053new_segment.subx b/subx/053new_segment.subx index 70acb572..c9a710e3 100644 --- a/subx/053new_segment.subx +++ b/subx/053new_segment.subx @@ -1,7 +1,6 @@ # Create a new segment (for data) using mmap(). == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes @@ -44,6 +43,7 @@ new-segment: # len : int -> address c3/return == data + # various constants used here were found in the Linux sources (search for file mman-common.h) mmap-new-segment: # type mmap_arg_struct # addr diff --git a/subx/054string_equal.subx b/subx/054string_equal.subx index fae2514b..a397dd8e 100644 --- a/subx/054string_equal.subx +++ b/subx/054string_equal.subx @@ -1,7 +1,6 @@ # Comparing 'regular' length-prefixed strings. == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/055trace.subx b/subx/055trace.subx index 8b4c15f4..8bcc1797 100644 --- a/subx/055trace.subx +++ b/subx/055trace.subx @@ -38,7 +38,6 @@ _test-trace-stream: 00 00 00 00 00 00 00 00 # 8 bytes == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/056write.subx b/subx/056write.subx index 045a8187..f793babe 100644 --- a/subx/056write.subx +++ b/subx/056write.subx @@ -16,7 +16,6 @@ # data: (array byte) # prefixed by length as usual == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/057stop.subx b/subx/057stop.subx index 2ec40221..8de167f0 100644 --- a/subx/057stop.subx +++ b/subx/057stop.subx @@ -26,7 +26,6 @@ # returns. (This is a poor man's setjmp/longjmp, if you know what that is.) == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/058read.subx b/subx/058read.subx index 3d55e195..b6bfac64 100644 --- a/subx/058read.subx +++ b/subx/058read.subx @@ -41,7 +41,6 @@ # data: (array byte) # prefixed by length as usual == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/059read-byte.subx b/subx/059read-byte.subx index e2b53d59..80cf30fb 100644 --- a/subx/059read-byte.subx +++ b/subx/059read-byte.subx @@ -27,7 +27,6 @@ Stdin: # TODO: 8 bytes is too small. We'll need to grow the buffer for efficiency. == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/060write-stream.subx b/subx/060write-stream.subx index 6b2adb9a..8b99301a 100644 --- a/subx/060write-stream.subx +++ b/subx/060write-stream.subx @@ -1,7 +1,6 @@ # write-stream: like write, but write streams rather than strings == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes diff --git a/subx/examples/ex1.subx b/subx/examples/ex1.subx index 8839fb6b..f956f974 100644 --- a/subx/examples/ex1.subx +++ b/subx/examples/ex1.subx @@ -9,6 +9,7 @@ # 42 == code + bb/copy-to-EBX 2a/imm32 # exit(EBX) b8/copy-to-EAX 1/imm32 diff --git a/subx/examples/ex11.subx b/subx/examples/ex11.subx index dc804ebe..28eb2a8a 100644 --- a/subx/examples/ex11.subx +++ b/subx/examples/ex11.subx @@ -15,7 +15,6 @@ # would cause tests to not run, rather than to fail as we'd like.) == code - # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes @@ -335,6 +334,7 @@ write-stderr: # s : (address array byte) -> c3/return == data + Newline: # size 01 00 00 00 diff --git a/subx/examples/ex12.subx b/subx/examples/ex12.subx index da752988..83943e1d 100644 --- a/subx/examples/ex12.subx +++ b/subx/examples/ex12.subx @@ -25,6 +25,7 @@ cd/syscall 0x80/imm8 == data + # various constants used here were found in the Linux sources (search for file mman-common.h) Mmap-new-segment: # type mmap_arg_struct # addr diff --git a/subx/examples/ex2.subx b/subx/examples/ex2.subx index e44d5ea8..09fe4414 100644 --- a/subx/examples/ex2.subx +++ b/subx/examples/ex2.subx @@ -8,6 +8,7 @@ # 2 == code + bb/copy-to-EBX 1/imm32 43/inc-EBX # exit(EBX) diff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx index 8496b9c2..e5dad9e4 100644 --- a/subx/examples/ex3.subx +++ b/subx/examples/ex3.subx @@ -11,6 +11,7 @@ # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes + # result: EBX = 0 bb/copy-to-EBX 0/imm32 # counter: ECX = 1 diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx index f053d3fe..17dae120 100644 --- a/subx/examples/ex4.subx +++ b/subx/examples/ex4.subx @@ -5,6 +5,7 @@ # $ subx run examples/ex4 == code + # syscall(read, stdin, X, 1) # fd = 0 (stdin) bb/copy-to-EBX 0/imm32 @@ -32,6 +33,7 @@ b8/copy-to-EAX 1/imm32/exit cd/syscall 0x80/imm8 == data + X: 00 00 00 00 # space for read() to write to diff --git a/subx/examples/ex6.subx b/subx/examples/ex6.subx index b96ee77f..dfec4bf9 100644 --- a/subx/examples/ex6.subx +++ b/subx/examples/ex6.subx @@ -26,6 +26,7 @@ cd/syscall 0x80/imm8 == data + Size: # size of string 0e 00 00 00 # 14 X: # string to print diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx index d678bb0b..fc04ce2d 100644 --- a/subx/examples/ex7.subx +++ b/subx/examples/ex7.subx @@ -91,6 +91,7 @@ cd/syscall 0x80/imm8 == data + Stream: 00 00 00 00 A: diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx index 4dc0054f..3f5ebce5 100644 --- a/subx/examples/ex8.subx +++ b/subx/examples/ex8.subx @@ -18,6 +18,7 @@ # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes + # prolog 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # call ascii-length(argv[1]) diff --git a/subx/examples/ex9.subx b/subx/examples/ex9.subx index fa2877df..6c6fc04b 100644 --- a/subx/examples/ex9.subx +++ b/subx/examples/ex9.subx @@ -20,6 +20,7 @@ # instruction effective address operand displacement immediate # op subop mod rm32 base index scale r32 # 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes + # prolog 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP # call ascii-difference(argv[1], argv[2]) -- cgit 1.4.1-2-gfad0