-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwelcome.asm
77 lines (68 loc) · 1.44 KB
/
welcome.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
section .data
name_msg db 'Please enter your name: '
NAMESIZE EQU $-name_msg
query_msg db 'How many times to repeat welcome message? '
QUERYSIZE EQU $-query_msg
welcome_msg db 'Welcome do Assembly Language Programming '
WELCSIZE EQU $-welcome_msg
nwln db 0Dh, 0Ah
NWLNSIZE EQU $-nwln
section .bss
user_name resb 16
response resb 1
section .text
global _start
_start:
; Imprime name_msg
mov eax, 4
mov ebx, 1
mov ecx, name_msg ; 'Please enter your name: '
mov edx, NAMESIZE
int 80h
; Pega user_name
mov eax, 3
mov ebx, 0
mov ecx, user_name
mov edx, 16
int 80h
; Imprime query_msg
mov eax, 4
mov ebx, 1
mov ecx, query_msg ;'How many times to repeat welcome message? '
mov edx, QUERYSIZE
int 80h
; Pega response
mov eax, 3
mov ebx, 0
mov ecx, response
mov edx, 1
int 80h
; Converte de string para int
mov ECX, 0
mov CL, [response]
sub CL, 0x30
display_msg:
; Imprime welcome_msg com user_name
push ECX
mov eax, 4
mov ebx, 1
mov ecx, welcome_msg
mov edx, WELCSIZE
int 80h
mov eax, 4
mov ebx, 1
mov ecx, user_name
mov edx, 16
int 80h
; mov eax, 4
; mov ebx, 1
; mov ecx, nwln
; mov edx, NWLNSIZE
; int 80h
; Atualiza contador e faz loop
pop ECX
loop display_msg
; Encerra programa
mov eax, 1
mov ebx, 0
int 80h