-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab5.asm
82 lines (64 loc) · 1.16 KB
/
lab5.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
section .data
input db "Input anything here:"
leninput equ $ - input
output1 db "Your string entered:"
lenoutput1 equ $-output1
output2 db "Your strings entered is not contain lower case."
lenoutput2 equ $-output2
section .bss
strings resb 32
n resb 1
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, strings
mov edx, 32
int 0x80
mov ecx, strings
mov edx, 0
convert:
mov al, [ecx + edx]
cmp al, 0
je end
cmp al, 'a'
jl nextchar
cmp al, 'z'
jg nextchar
sub al, 32
mov [ecx + edx], al
mov byte [n], 1
inc edx
jmp convert
nextchar:
inc edx
jmp convert
end:
cmp byte [n], 0
jne stringslowercase
mov eax, 4
mov ebx, 1
mov ecx, output2
mov edx, lenoutput2
int 0x80
jmp endprogram
stringslowercase:
mov eax, 4
mov ebx, 1
mov ecx, output1
mov edx, lenoutput1
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, strings
mov edx, 32
int 0x80
endprogram:
mov eax, 1
int 0x80