Skip to content

asm-4: add missing instructions#81

Merged
0xAX merged 1 commit intomasterfrom
asm-4/add-instructions
Mar 14, 2026
Merged

asm-4: add missing instructions#81
0xAX merged 1 commit intomasterfrom
asm-4/add-instructions

Conversation

@0xAX
Copy link
Owner

@0xAX 0xAX commented Mar 14, 2026

Description

This commit adds the missing instructions and better description for the mul, imul, div, and idiv` instructions.

Thank you to @sevilla-larry for report.

Related issues

#80

content/asm_4.md Outdated
- `div` and `idiv` - Unsigned and signed division. Both instructions take a single operand. The value of this operand is divided by the value of the `rax` register. The place where the result is stored depends on the size of the operands. In the case of 8-bit operands, the result is stored in the `al:ah` pair. In the case of 16-bit operands, the result is stored in the `dx:ax` pair. For 32-bit operands, the result is stored in the `edx:eax`, and in the case of 64-bit operands, the result is stored in the `rdx:rax` pair.
- `add` - Addition. It adds the value of the second operand to the first and stores the result in the first operand.
- `sub` - Subtraction. It subtracts the value of the second operand from the first and stores the result in the first operand.
- `mul` and `imul` - Unsigned and signed multiplication. Both instructions take a single operand. It multiples the value of the single operand by the value stored in the `rax` register or it its part. The part where the result is stored depends on the size of the operands.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `mul` and `imul` - Unsigned and signed multiplication. Both instructions take a single operand. It multiples the value of the single operand by the value stored in the `rax` register or it its part. The part where the result is stored depends on the size of the operands.
- `mul` and `imul` - Unsigned and signed multiplication. Both instructions take a single operand. It multiplies the value of the single operand by the value stored in the `rax` register or its part. The part where the result is stored depends on the size of the operands.

content/asm_4.md Outdated
Comment on lines +69 to +72
- For 8-bit operands, the value from the `al` register is multiplied by the operand and the result is stored in the `ax` register.
- For 16-bit operands, the value of the `ax` register is multiplied and the result is stored in the `dx:ax` register pair.
- For 32-bit operands, the value of the `eax` register is multiplied and the result is stored in the `edx:eax` register pair.
- For 64-bit operands, the value of the `rax` is multiplied and the result is stored in the `rdx:rax` register pair.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- For 8-bit operands, the value from the `al` register is multiplied by the operand and the result is stored in the `ax` register.
- For 16-bit operands, the value of the `ax` register is multiplied and the result is stored in the `dx:ax` register pair.
- For 32-bit operands, the value of the `eax` register is multiplied and the result is stored in the `edx:eax` register pair.
- For 64-bit operands, the value of the `rax` is multiplied and the result is stored in the `rdx:rax` register pair.
- For 8-bit operands, the value from the `al` register is multiplied by the operand, and the result is stored in the `ax` register.
- For 16-bit operands, the value of the `ax` register is multiplied, and the result is stored in the `dx:ax` register pair.
- For 32-bit operands, the value of the `eax` register is multiplied, and the result is stored in the `edx:eax` register pair.
- For 64-bit operands, the value of the `rax` register is multiplied, and the result is stored in the `rdx:rax` register pair.

content/asm_4.md Outdated
Comment on lines +74 to +77
- For 8-bit operands, the value of the `ax` register is divided by the operand, the quotient is stored in the `al` register, and the remainder in the `ah` register.
- For 16-bit operands, the register pair `dx:ax` is divided, the quotient is stored in the `ax` register, and the remainder in the `dx` register.
- For 32-bit operands, the register pair `edx:eax` is divided, the quotient is stored in the `eax` register, and the remainder in the `edx` register.
- For 64-bit operands, the register pair `rdx:rax` is divided, the quotient is stored in the `rax` regiter, and the remainder in the `rdx` register.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- For 8-bit operands, the value of the `ax` register is divided by the operand, the quotient is stored in the `al` register, and the remainder in the `ah` register.
- For 16-bit operands, the register pair `dx:ax` is divided, the quotient is stored in the `ax` register, and the remainder in the `dx` register.
- For 32-bit operands, the register pair `edx:eax` is divided, the quotient is stored in the `eax` register, and the remainder in the `edx` register.
- For 64-bit operands, the register pair `rdx:rax` is divided, the quotient is stored in the `rax` regiter, and the remainder in the `rdx` register.
- For 8-bit operands, the value of the `ax` register is divided by the operand, the quotient is stored in the `al` register, and the remainder is stored in the `ah` register.
- For 16-bit operands, the register pair `dx:ax` is divided, the quotient is stored in the `ax` register, and the remainder is stored in the `dx` register.
- For 32-bit operands, the register pair `edx:eax` is divided, the quotient is stored in the `eax` register, and the remainder is stored in the `edx` register.
- For 64-bit operands, the register pair `rdx:rax` is divided, the quotient is stored in the `rax` register, and the remainder is stored in the `rdx` register.

This commit adds the missing instructions and better description for
the `mul`, `imul, `div`, and `idiv` instructions.

Thank you to @sevilla-larry for report.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
@0xAX 0xAX force-pushed the asm-4/add-instructions branch from 103b9a1 to 18bcfc8 Compare March 14, 2026 09:08
@0xAX 0xAX merged commit 378b9b1 into master Mar 14, 2026
1 check passed
@0xAX 0xAX deleted the asm-4/add-instructions branch March 14, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants