-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.asm
More file actions
86 lines (72 loc) · 1.44 KB
/
Copy pathcalculator.asm
File metadata and controls
86 lines (72 loc) · 1.44 KB
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
; Calculadora em assembly
; Aluno: Luís Henrique Gundes Valim
; Ciência da Computação
; Universidade Federal do Espírito Santo
; Características do trabalho:
; Arquitetura: x64
; Compilador: NASM
; _start
global _start
; secao .data - Constantes - Mensagens
section .data
msgInput1 db 'Insira primeiro numero: '
lenMsgInput1 equ $-msgInput1
msgInput2 db 'Insira segundo numero: '
lenMsgInput2 equ $-msgInput2
displayResult db 'Resultado: '
lenDisplayResult equ $-displayResult
; secao .bss - Variaveis
section .bss
input1 resb 10
input2 resb 10
result resb 11
; secao .text - Codigo
section .text
global _start
_start:
; Mensagem 1
mov eax, 4
mov ebx, 1
mov ecx, msgInput1
mov edx, lenMsgInput1
int 80h
; Le e armazena numero 1
mov eax, 3
mov ebx, 2
mov ecx, input1
mov edx, 10
int 80h
; Mensagem 2
mov eax, 4
mov ebx, 1
mov ecx, msgInput2
mov edx, lenMsgInput2
int 80h
; Le e armazena numero 1
mov eax, 3
mov ebx, 2
mov ecx, input2
mov edx, 10
int 80h
mov eax, [input1]
sub eax, '0'
mov ebx, [input2]
sub ebx, '0'
add eax, ebx
add eax, '0'
mov [result], eax
; Mensagem 2
mov eax, 4
mov ebx, 1
mov ecx, displayResult
mov edx, lenDisplayResult
int 80h
mov eax, 4
mov ebx, 1
mov ecx, result
mov edx, 11
int 0x80
; Exit programa
mov eax, 1
mov ebx, 0
int 80h