-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2.asm
100 lines (80 loc) · 1.6 KB
/
lab2.asm
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
section .data
input db 'Nhap vao chieu dai va chieu rong:', 0xa, 0xd
leninput equ $-input
outputchuvi db 'Chu vi cua hinh chu nhat: '
lenoutputchuvi equ $-outputchuvi
outputdientich db 'Dien tich cua hinh chu nhat: '
lenoutputdientich equ $-outputdientich
newline db 0xa, 0xd
lennewline equ $-newline
section .bss
chieudai resb 10
chieurong resb 10
chuvi resb 10
dientich resb 10
section .text
global _start
_start:
mov eax, 4
mov ebx, 1
mov ecx, input
mov edx, leninput
int 0x80
mov eax, 3
mov ebx, 0
mov ecx, chieudai
mov edx, 10
int 0x80
mov edx, chieudai
sub eax, 0x1
mov byte[edx+eax], 0x0
mov eax, 3
mov ebx, 0
mov ecx, chieurong
mov edx, 10
int 0x80
mov edx, chieurong
sub eax, 0x1
mov byte[edx+eax], 0x0
mov eax, [chieudai]
sub eax, '0'
mov ebx, [chieurong]
sub ebx, '0'
add eax, ebx
shl eax, 1
add eax, '0'
mov [chuvi], eax
mov eax, [chieudai]
sub eax, '0'
mov ebx, [chieurong]
sub ebx, '0'
mul ebx
add eax, '0'
mov [dientich], eax
mov eax, 4
mov ebx, 1
mov ecx, outputchuvi
mov edx, lenoutputchuvi
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, chuvi
mov edx, 10
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, lennewline
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, outputdientich
mov edx, lenoutputdientich
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, dientich
mov edx, 10
int 0x80
mov eax, 1
int 0x80