# x86 (32-bit) vs x64 (64-bit)

{% embed url="<https://guyinatuxedo.github.io/01-intro_assembly/assembly/index.html>" %}

### General comparisons

|                                                                       | x86                 | x64                  |
| --------------------------------------------------------------------- | ------------------- | -------------------- |
| How are arguments passed to functions in an ELF (Linux) architecture? | Passed on the stack | Passed via registers |
| Which register is used to return a value from a C function?           | `eax` register      | `rax` register       |
| Maximum register size                                                 | 4 byte (32 bit)     | 8 byte (64 bit)      |
| ...                                                                   |                     |                      |

### Registers

As mentioned before, the `x64` architecture has the 8 byte registers, while `x86` can only access up to the 4 byte registers. There also exists 2 byte and a single byte register, as defined in the table below:

> Taken directly from [source](https://guyinatuxedo.github.io/01-intro_assembly/assembly/index.html)&#x20;

<div data-with-frame="true"><figure><img src="https://667177664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMsAGomcNx5xaB1xFygc9%2Fuploads%2FtlDJzcWeEbw2dcP7XSPe%2Fimage.png?alt=media&#x26;token=cfa21345-53f7-44ca-b13d-d2b59abcbf08" alt=""><figcaption></figcaption></figure></div>

Taking the 8 byte register `rax` as an example, we can see that the lower 4, 2 and single byte(s) register will be the `eax`, `ax` and `al` respectively.

* `eax`: Lower 4 bytes of the `rax` register
* `ax`: Lower 2 bytes of the `rax` register
* `al`: Last byte of the `rax` register
