diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-05-18 00:00:18 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-05-18 00:45:12 -0700 |
commit | 83c67014034bbf9072d7e4555b0e51e815a95756 (patch) | |
tree | cf52127783efc20bbe8d903d96e73bc51a1f752d /subx/examples | |
parent | 4b506b630ce28b3574a9f903904588f92dd3a1c1 (diff) | |
download | mu-83c67014034bbf9072d7e4555b0e51e815a95756.tar.gz |
switch to new syntax for segment headers in C++
Diffstat (limited to 'subx/examples')
-rw-r--r-- | subx/examples/ex1.subx | 2 | ||||
-rw-r--r-- | subx/examples/ex10.subx | 2 | ||||
-rw-r--r-- | subx/examples/ex11.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex12.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex2.subx | 2 | ||||
-rw-r--r-- | subx/examples/ex3.subx | 2 | ||||
-rwxr-xr-x | subx/examples/ex4 | bin | 171 -> 171 bytes | |||
-rw-r--r-- | subx/examples/ex4.subx | 13 | ||||
-rw-r--r-- | subx/examples/ex5.subx | 2 | ||||
-rw-r--r-- | subx/examples/ex6.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex7.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex8.subx | 2 | ||||
-rw-r--r-- | subx/examples/ex9.subx | 2 |
13 files changed, 22 insertions, 21 deletions
diff --git a/subx/examples/ex1.subx b/subx/examples/ex1.subx index 2c3f64eb..4b9f208e 100644 --- a/subx/examples/ex1.subx +++ b/subx/examples/ex1.subx @@ -8,7 +8,7 @@ # $ echo $? # 42 -== code +== code 0x09000000 # syscall(exit, 42) bb/copy-to-EBX 2a/imm32 # 42 in hex diff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx index 53148464..fd2ccc08 100644 --- a/subx/examples/ex10.subx +++ b/subx/examples/ex10.subx @@ -7,7 +7,7 @@ # $ echo $? # 0 # false -== code +== code 0x09000000 # instruction effective address register 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/ex11.subx b/subx/examples/ex11.subx index 78bcf5c9..ba75c1d3 100644 --- a/subx/examples/ex11.subx +++ b/subx/examples/ex11.subx @@ -14,7 +14,7 @@ # because checking for it would require the function being tested! Breakage # would cause tests to not run, rather than to fail as we'd like.) -== code +== code 0x09000000 # instruction effective address register 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 @@ -339,7 +339,7 @@ write-stderr: # s : (address array byte) -> <void> 5d/pop-to-EBP c3/return -== data +== data 0x0a000000 Newline: # size diff --git a/subx/examples/ex12.subx b/subx/examples/ex12.subx index 4518aecc..4d43b033 100644 --- a/subx/examples/ex12.subx +++ b/subx/examples/ex12.subx @@ -6,7 +6,7 @@ # $ ./subx run examples/ex12 # You shouldn't get a segmentation fault. -== code +== code 0x09000000 # instruction effective address register 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 @@ -24,7 +24,7 @@ b8/copy-to-EAX 1/imm32/exit cd/syscall 0x80/imm8 -== data +== data 0x0a000000 # various constants used here were found in the Linux sources (search for file mman-common.h) Mmap-new-segment: # type mmap_arg_struct diff --git a/subx/examples/ex2.subx b/subx/examples/ex2.subx index 757c5220..3605fcc8 100644 --- a/subx/examples/ex2.subx +++ b/subx/examples/ex2.subx @@ -7,7 +7,7 @@ # $ echo $? # 2 -== code +== code 0x09000000 # EBX = 1 bb/copy-to-EBX 1/imm32 diff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx index f7352b2f..c9ad3e38 100644 --- a/subx/examples/ex3.subx +++ b/subx/examples/ex3.subx @@ -7,7 +7,7 @@ # $ echo $? # 55 -== code +== code 0x09000000 # instruction effective address register 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/ex4 b/subx/examples/ex4 index 477dab46..66fb61e6 100755 --- a/subx/examples/ex4 +++ b/subx/examples/ex4 Binary files differdiff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx index b18a5da0..a1f042ed 100644 --- a/subx/examples/ex4.subx +++ b/subx/examples/ex4.subx @@ -4,7 +4,13 @@ # $ ./subx translate examples/ex4.subx -o examples/ex4 # $ ./subx run examples/ex4 -== code +== data 0x0a000000 + +# the global variable we save to +X: + 0/imm32 # space for read() to write to + +== code 0x09000000 # syscall(read, stdin, X, 1) # . fd = 0 (stdin) @@ -32,9 +38,4 @@ cd/syscall 0x80/imm8 b8/copy-to-EAX 1/imm32/exit cd/syscall 0x80/imm8 -== data - -X: - 0/imm32 # space for read() to write to - # . . vim:nowrap:textwidth=0 diff --git a/subx/examples/ex5.subx b/subx/examples/ex5.subx index f9ad9ea8..f051a91f 100644 --- a/subx/examples/ex5.subx +++ b/subx/examples/ex5.subx @@ -4,7 +4,7 @@ # $ ./subx translate examples/ex5.subx -o examples/ex5 # $ ./subx run examples/ex5 -== code +== code 0x09000000 # instruction effective address register 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/ex6.subx b/subx/examples/ex6.subx index 3375fb43..c5999033 100644 --- a/subx/examples/ex6.subx +++ b/subx/examples/ex6.subx @@ -5,7 +5,7 @@ # $ ./subx run examples/ex6 # Hello, world! -== code +== code 0x09000000 # instruction effective address register 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 @@ -25,7 +25,7 @@ b8/copy-to-EAX 1/imm32/exit cd/syscall 0x80/imm8 -== data +== data 0x0a000000 Size: # size of string 0x0e/imm32 # 14 diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx index c6dd3423..ee043c86 100644 --- a/subx/examples/ex7.subx +++ b/subx/examples/ex7.subx @@ -11,7 +11,7 @@ # $ echo $? # 97 -== code +== code 0x09000000 # instruction effective address register 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 @@ -91,7 +91,7 @@ b8/copy-to-EAX 1/imm32/exit cd/syscall 0x80/imm8 -== data +== data 0x0a000000 Stream: 0/imm32 diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx index d31786da..85fe1568 100644 --- a/subx/examples/ex8.subx +++ b/subx/examples/ex8.subx @@ -14,7 +14,7 @@ # ... # Locals start from ESP-4 downwards. -== code +== code 0x09000000 # instruction effective address register 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/ex9.subx b/subx/examples/ex9.subx index 66fbf2ff..344c62ae 100644 --- a/subx/examples/ex9.subx +++ b/subx/examples/ex9.subx @@ -17,7 +17,7 @@ # ... # Locals start from ESP-4 downwards. -== code +== code 0x09000000 # instruction effective address register 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 |