-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic.nasm
More file actions
70 lines (49 loc) · 810 Bytes
/
arithmetic.nasm
File metadata and controls
70 lines (49 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
global _start
section .text
_start:
; Register ased addition
mov eax, 0
add al, 0x22
add al, 0x11
mov ax, 0x1122
add ax, 0x3344
mov eax, 0xffffffff
add eax, 0x10
mov eax, 0
add byte [var1], 0x22
add byte [var1], 0x11
add word [var2], 0x1122
add word [var2], 0x3344
mov dword [var3], 0xffffffff
add dword [var3], 0x10
clc
stc
cmc
; add with carry
mov eax, 0
stc
adc al, 0x22
stc
adc al, 0x11
mov ax, 0x1122
stc
adc ax, 0x3344
mov eax, 0xffffffff
stc
adc eax, 0x10
; substract
mov eax, 10
sub eax, 5
stc
sbb eax, 4
; increment and decrement
inc eax
dec eax
; exit program
mov eax, 1
mov ebx, 10
int 0x80
section .data
var1 db 0x00
var2 dw 0x000
var3 dd 0x00000000