Assembly supports basic arithmetic operations such as addition, subtraction, multiplication, and division.
add: Adds the source to the destination.sub: Subtracts the source from the destination.mul: Multiplies the accumulator by the source.div: Divides the accumulator by the source.
section .text
global _start
_start:
mov rax, 10 ; Load 10 into rax
add rax, 5 ; Add 5 to rax (rax = 15)
sub rax, 3 ; Subtract 3 from rax (rax = 12)
section .text
global _start
_start:
mov rax, 6 ; Load 6 into rax
mov rbx, 2 ; Load 2 into rbx
mul rbx ; Multiply rax by rbx (rax = 12)
mov rcx, 3 ; Load 3 into rcx
div rcx ; Divide rax by rcx (rax = 4)
Note: Multiplication and division affect specific registers (e.g., rax for results).