diff options
-rw-r--r-- | 00/README.md | 15 | ||||
-rwxr-xr-x | 00/hexcompile | bin | 632 -> 632 bytes | |||
-rw-r--r-- | 01/in00 | 390 | ||||
-rw-r--r-- | 01/in01 | 13 | ||||
-rw-r--r-- | 01/instructions.txt | 63 | ||||
-rw-r--r-- | instructions.txt | 12 |
6 files changed, 283 insertions, 210 deletions
diff --git a/00/README.md b/00/README.md index 3be7e5c..25dc1ae 100644 --- a/00/README.md +++ b/00/README.md @@ -25,7 +25,7 @@ it even smaller if you wanted to. Let's take a look at what's inside (`od -t x1 00 10 00 00 00 00 00 00 48 b8 6d 02 40 00 00 00 00 00 48 89 c7 31 c0 48 89 c6 48 b8 02 00 00 00 00 00 00 00 0f 05 48 b8 72 02 40 00 00 00 00 00 -48 89 c7 48 b8 41 00 00 00 00 00 00 00 48 89 c6 +48 89 c7 48 b8 41 02 00 00 00 00 00 00 48 89 c6 48 b8 ed 01 00 00 00 00 00 00 48 89 c2 48 b8 02 00 00 00 00 00 00 00 0f 05 48 b8 03 00 00 00 00 00 00 00 48 89 c7 48 89 c2 48 b8 6a 02 40 00 00 @@ -179,18 +179,19 @@ Now we open our output file: - `48 b8 72 02 40 00 00 00 00 00` `mov rax, 0x400272` - `48 89 c7` `mov rdi, rax` -- `48 b8 41 00 00 00 00 00 00 00` `mov rax, 0x41` +- `48 b8 41 02 00 00 00 00 00 00` `mov rax, 0x41` - `48 89 c6` `mov rsi, rax` - `48 b8 ed 01 00 00 00 00 00 00` `mov rax, 0o755` - `48 89 c2` `mov rdx, rax` - `48 b8 02 00 00 00 00 00 00 00` `mov rax, 2` - `0f 05` `syscall` -In C, this is `open("out00", O_WRONLY|O_CREAT, 0755)`. This is quite similar -to our first call, with two important differences: first, we specify `0x41` as -the second argument. This tells Linux that we are writing to the file -(`O_WRONLY = 0x01`), and that we want to create it if it doesn't exist -(`O_CREAT = 0x40`). Secondly, we are setting the third argument this time. It +In C, this is `open("out00", O_WRONLY|O_CREAT|O_TRUNC, 0755)`. This is quite +similar to our first call, with two important differences: first, we specify +`0x241` as the second argument. This tells Linux that we are writing to the +file (`O_WRONLY = 0x01`), that we want to create it if it doesn't exist +(`O_CREAT = 0x40`), and that we want to delete any previous contents it had +(`O_TRUNC = 0x200`). Secondly, we are setting the third argument this time. It specifies the permissions our file is created with (`0o755` means user read/write/execute, group/other read/execute). This is not very important to the actual execution of the program, so don't worry if you don't know what it diff --git a/00/hexcompile b/00/hexcompile Binary files differindex 6aeed48..f4c575e 100755 --- a/00/hexcompile +++ b/00/hexcompile @@ -36,7 +36,7 @@ a8 00 40 00 00 00 00 00 0f 05 48 b8 7d 00 40 00 00 00 00 00 48 89 c7 -48 b8 41 00 00 00 00 00 00 00 +48 b8 41 02 00 00 00 00 00 00 48 89 c6 48 b8 ed 01 00 00 00 00 00 00 48 89 c2 @@ -4558,6 +4558,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -5198,6 +5199,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 21 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -5291,6 +5293,101 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01 20 00 00 00 00 00 00 +01 21 00 00 00 00 00 00 +01 22 00 00 00 00 00 00 +01 23 00 00 00 00 00 00 +01 24 00 00 00 00 00 00 +01 25 00 00 00 00 00 00 +01 26 00 00 00 00 00 00 +01 27 00 00 00 00 00 00 +01 28 00 00 00 00 00 00 +01 29 00 00 00 00 00 00 +01 2a 00 00 00 00 00 00 +01 2b 00 00 00 00 00 00 +01 2c 00 00 00 00 00 00 +01 2d 00 00 00 00 00 00 +01 2e 00 00 00 00 00 00 +01 2f 00 00 00 00 00 00 +01 30 00 00 00 00 00 00 +01 31 00 00 00 00 00 00 +01 32 00 00 00 00 00 00 +01 33 00 00 00 00 00 00 +01 34 00 00 00 00 00 00 +01 35 00 00 00 00 00 00 +01 36 00 00 00 00 00 00 +01 37 00 00 00 00 00 00 +01 38 00 00 00 00 00 00 +01 39 00 00 00 00 00 00 +01 3a 00 00 00 00 00 00 +01 3b 00 00 00 00 00 00 +01 3c 00 00 00 00 00 00 +01 3d 00 00 00 00 00 00 +01 3e 00 00 00 00 00 00 +01 3f 00 00 00 00 00 00 +01 40 00 00 00 00 00 00 +01 41 00 00 00 00 00 00 +01 42 00 00 00 00 00 00 +01 43 00 00 00 00 00 00 +01 44 00 00 00 00 00 00 +01 45 00 00 00 00 00 00 +01 46 00 00 00 00 00 00 +01 47 00 00 00 00 00 00 +01 48 00 00 00 00 00 00 +01 49 00 00 00 00 00 00 +01 4a 00 00 00 00 00 00 +01 4b 00 00 00 00 00 00 +01 4c 00 00 00 00 00 00 +01 4d 00 00 00 00 00 00 +01 4e 00 00 00 00 00 00 +01 4f 00 00 00 00 00 00 +01 50 00 00 00 00 00 00 +01 51 00 00 00 00 00 00 +01 52 00 00 00 00 00 00 +01 53 00 00 00 00 00 00 +01 54 00 00 00 00 00 00 +01 55 00 00 00 00 00 00 +01 56 00 00 00 00 00 00 +01 57 00 00 00 00 00 00 +01 58 00 00 00 00 00 00 +01 59 00 00 00 00 00 00 +01 5a 00 00 00 00 00 00 +01 5b 00 00 00 00 00 00 +01 5c 00 00 00 00 00 00 +01 5d 00 00 00 00 00 00 +01 5e 00 00 00 00 00 00 +01 5f 00 00 00 00 00 00 +01 60 00 00 00 00 00 00 +01 61 00 00 00 00 00 00 +01 62 00 00 00 00 00 00 +01 63 00 00 00 00 00 00 +01 64 00 00 00 00 00 00 +01 65 00 00 00 00 00 00 +01 66 00 00 00 00 00 00 +01 67 00 00 00 00 00 00 +01 68 00 00 00 00 00 00 +01 69 00 00 00 00 00 00 +01 6a 00 00 00 00 00 00 +01 6b 00 00 00 00 00 00 +01 6c 00 00 00 00 00 00 +01 6d 00 00 00 00 00 00 +01 6e 00 00 00 00 00 00 +01 6f 00 00 00 00 00 00 +01 70 00 00 00 00 00 00 +01 71 00 00 00 00 00 00 +01 72 00 00 00 00 00 00 +01 73 00 00 00 00 00 00 +01 74 00 00 00 00 00 00 +01 75 00 00 00 00 00 00 +01 76 00 00 00 00 00 00 +01 77 00 00 00 00 00 00 +01 78 00 00 00 00 00 00 +01 79 00 00 00 00 00 00 +01 7a 00 00 00 00 00 00 +01 7b 00 00 00 00 00 00 +01 7c 00 00 00 00 00 00 +01 7d 00 00 00 00 00 00 +01 7e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -5718,10 +5815,12 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -5740,6 +5839,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 01 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -5971,10 +6071,12 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 eb 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 fb 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -6010,109 +6112,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +03 48 81 ec 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8016,11 +8016,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 d3 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 c1 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8270,11 +8272,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 d3 e8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 c1 e8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8651,10 +8655,15 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 d8 00 00 00 00 +03 48 89 c8 00 00 00 00 +03 48 89 d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f0 00 00 00 00 +03 48 89 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8662,6 +8671,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 e8 00 00 00 00 +03 48 89 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8771,11 +8782,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c3 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 cb 00 00 00 00 +03 48 89 d3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f3 00 00 00 00 +03 48 89 fb 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8783,6 +8799,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 eb 00 00 00 00 +03 48 89 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8892,11 +8910,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c1 00 00 00 00 +03 48 89 d9 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 d1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f1 00 00 00 00 +03 48 89 f9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -8904,6 +8927,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 e9 00 00 00 00 +03 48 89 e1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9013,11 +9038,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c2 00 00 00 00 +03 48 89 da 00 00 00 00 +03 48 89 ca 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f2 00 00 00 00 +03 48 89 fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9025,6 +9055,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 ea 00 00 00 00 +03 48 89 e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9646,11 +9678,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c6 00 00 00 00 +03 48 89 de 00 00 00 00 +03 48 89 ce 00 00 00 00 +03 48 89 d6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9658,45 +9695,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +03 48 89 ee 00 00 00 00 +03 48 89 e6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9807,10 +9807,14 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 48 89 c7 00 00 00 00 +03 48 89 df 00 00 00 00 +03 48 89 cf 00 00 00 00 +03 48 89 d7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -9819,6 +9823,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 ef 00 00 00 00 +03 48 89 e7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10104,6 +10110,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04 48 8b 04 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10823,10 +10830,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c5 00 00 00 00 +03 48 89 dd 00 00 00 00 +03 48 89 cd 00 00 00 00 +03 48 89 d5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f5 00 00 00 00 +03 48 89 fd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10835,6 +10848,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 e5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10944,10 +10958,16 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 c4 00 00 00 00 +03 48 89 dc 00 00 00 00 +03 48 89 cc 00 00 00 00 +03 48 89 d4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 f4 00 00 00 00 +03 48 89 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10955,6 +10975,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 ec 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -10985,6 +11006,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +04 48 89 04 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -11576,6 +11598,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 49 89 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -11703,6 +11726,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 49 89 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -11830,6 +11854,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 49 89 c2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -12130,11 +12155,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -12213,11 +12240,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 f8 d3 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 c1 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -12338,36 +12367,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +03 48 31 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -13049,8 +13049,8 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +02 ff d0 00 00 00 00 00 +03 48 39 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -13934,13 +13934,20 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 0f 87 00 00 00 00 00 +02 0f 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 0f 84 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 0f 8f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 0f 8c 00 00 00 00 00 +01 e9 00 00 00 00 00 00 +02 0f 85 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -14184,7 +14191,9 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 8a 03 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 8b 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -14197,11 +14206,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 8b 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 66 8b 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -14403,6 +14414,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 f7 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -14950,6 +14962,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +01 c3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -15074,7 +15087,9 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 88 03 00 00 00 00 00 00 00 00 00 00 00 00 00 +02 89 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -15087,28 +15102,13 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 89 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +03 66 89 03 00 00 00 00 00 00 00 00 00 00 00 00 02 0f 05 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -15218,6 +15218,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +03 48 85 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -15727,8 +15728,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +02 48 93 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -16207,7 +16207,7 @@ cc cc cc cc cc cc cc cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 +03 48 09 d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -1,6 +1,15 @@ || -;im;2a;00;00;00;00;00;00;00 +;im;01;00;00;00;00;00;00;00 file descriptor for stdout ;JA -;im;3c;00;00;00;00;00;00;00 +;im;bc;00;40;00;00;00;00;00 address of string "Hello, world!\n" +;IA +;im;0e;00;00;00;00;00;00;00 number of bytes to output +;DA +;im;01;00;00;00;00;00;00;00 syscall #1 (write) ;sy +;zA +;DA exit code 0 +;im;3c;00;00;00;00;00;00;00 syscall #60 (exit) +;sy +;'H;'e;'l;'l;'o;',;' ;'w;'o;'r;'l;'d;'!;\n the string we're printing ; diff --git a/01/instructions.txt b/01/instructions.txt new file mode 100644 index 0000000..890e878 --- /dev/null +++ b/01/instructions.txt @@ -0,0 +1,63 @@ +00 - Byte 00 +.. +ff - Byte ff + +'a - Character a (byte 0x61) +'! - Character ! (byte 0x21) +etc. + +zA - Zero rax +im - Set rax to an immediate value, e.g. + im;05;00;00;00;00;00;00;00; + will set rax to 5. + +ax bx cx dx sp bp si di +A B C D S R I J +The instruction for moving one register to another is [dest][src], e.g. CS is +mov rcx, rsp. + +XA - mov r8, rax +YA - mov r9, rax +ZA - mov r10, rax + +xc - xchg rax, rbx + +sq - mov qword [rbx], rax +lq - mov rax, qword [rbx] +sd - mov dword [rbx], eax +ld - mov eax, dword [rbx] +sw - mov word [rbx], ax +lw - mov ax, word [rbx] +sb - mov byte [rbx], al +lb - mov al, byte [rbx] +Sq - mov qword [rsp], rax +Lq - mov rax, qword [rsp] + +nA - neg rax ++B - add rax, rbx +-* - imul rbx +-/ - idiv rbx ++* - mul rbx ++/ - div rbx +!A - not rax +&B - and rax, rbx +|B - or rax, rbx +^B - xor rax, rbx +<C - shl rax, cl +<I - shl rax, imm8 +>C - shr rax, cl +>I - shr rax, imm8 +]C - sar rax, cl +]I - sar rax, imm8 +-S - sub rsp, imm32 +cm - cmp rax, rbx +te - test rax, rax +jm - jmp rel32 +je - je rel32 +jn - jne rel32 +jl - jl rel32 +jb - jb rel32 +ja - ja rel32 +cl - call rax +re - ret +sy - syscall diff --git a/instructions.txt b/instructions.txt index ca2fc0e..cc997b6 100644 --- a/instructions.txt +++ b/instructions.txt @@ -21,10 +21,6 @@ mov r10, rax (for syscalls) >49 89 c2 xchg rax, rbx >48 93 -mov qword [rsp], rax ->48 89 04 24 -mov rax, qword [rsp] ->48 8b 04 24 mov qword [rbx], rax >48 89 03 mov rax, qword [rbx] @@ -41,6 +37,10 @@ mov byte [rbx], al >88 03 mov al, byte [rbx] >8a 03 +mov qword [rsp], rax +>48 89 04 24 +mov rax, qword [rsp] +>48 8b 04 24 neg rax >48 f7 d8 add rax, rbx @@ -89,10 +89,10 @@ jl rel32 >0f 8c REL32 jg rel32 >0f 8f REL32 -ja rel32 ->0f 87 REL32 jb rel32 >0f 82 REL32 +ja rel32 +>0f 87 REL32 call rax >ff d0 ret |