You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arch agnostic infrastructure getting started at: <<userland-assembly>>.
12356
12357
12358
+
=== x86 registers
12359
+
12360
+
link:userland/arch/x86_64/registers.S
12361
+
12362
+
....
12363
+
|-----------------------------------------------|
12364
+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
12365
+
|-----------------------------------------------|
12366
+
| | | AH | AL |
12367
+
|-----------------------------------------------|
12368
+
| | | AX |
12369
+
|-----------------------------------------------|
12370
+
| | EAX |
12371
+
|-----------------------------------------------|
12372
+
| RAX |
12373
+
|-----------------------------------------------|
12374
+
....
12375
+
12376
+
For the newer x86_64 registers, the naming convention is somewhat saner:
12377
+
12378
+
....
12379
+
|-----------------------------------------------|
12380
+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
12381
+
|-----------------------------------------------|
12382
+
| | |R12H |R12L |
12383
+
|-----------------------------------------------|
12384
+
| | | R12W |
12385
+
|-----------------------------------------------|
12386
+
| | R12D |
12387
+
|-----------------------------------------------|
12388
+
| R12 |
12389
+
|-----------------------------------------------|
12390
+
....
12391
+
12392
+
Most of the 8 older x86 general purpose registers are not "really" general purpose in the sense that a few instructions magically use them without an explicit encoding. This is reflected in their names:
12393
+
12394
+
* RAX: Accumulator. The general place where you add, subtract and otherwise manipulate results in-place. Magic for example for <<MUL,x86 binary arithmetic instructions>>
12395
+
* RCX, RSI, RDI: Counter, Source and Destination. Used in <<x86-string-instructions>>
@@ -12631,7 +12671,7 @@ These instructions do some operation on an array item, and automatically update
12631
12671
** link:userland/arch/x86_64/movs.S[]: MOVS: MOV String: move from one memory to another with addresses given by RSI and RDI. Could be used to implement `memmov`.
12632
12672
** link:userland/arch/x86_64/scas.S[]: SCAS: SCan String: compare memory to the value in a register. Could be used to implement `strchr`.
12633
12673
12634
-
The RSI and RDI registers are actually named after these intructions! S is the source of string instructions, D is the destination of string instructions.
12674
+
The RSI and RDI registers are actually named after these intructions! S is the source of string instructions, D is the destination of string instructions: https://stackoverflow.com/questions/1856320/purpose-of-esi-edi-registers
12635
12675
12636
12676
The direction of the index increment depends on the direction flag of the FLAGS register: 0 means forward and 1 means backward: https://stackoverflow.com/questions/9636691/what-are-cld-and-std-for-in-x86-assembly-language-what-does-df-do
12637
12677
@@ -15402,11 +15442,17 @@ which also downloads build dependencies.
0 commit comments