You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
1.2 KiB
NASM
86 lines
1.2 KiB
NASM
.686p
|
|
.model flat
|
|
include kernel32.inc
|
|
includelib kernel32.lib
|
|
includelib msvcrt.lib
|
|
extern _printf:proc
|
|
extern _scanf:proc
|
|
extern _strlen:proc
|
|
.data
|
|
strbuf db 1000 dup(0)
|
|
strfmt db "%s",0
|
|
.code
|
|
process_char proc
|
|
mov eax, [esp+4]
|
|
cmp eax, 65
|
|
jl check_if_lower
|
|
cmp eax, 90
|
|
jg check_if_lower
|
|
jmp uppercase
|
|
check_if_lower:
|
|
cmp eax, 97
|
|
jl end_of_proc
|
|
cmp eax, 122
|
|
jg end_of_proc
|
|
|
|
lowercase:
|
|
sub eax, 84
|
|
cdq
|
|
mov ebx, 26
|
|
idiv ebx
|
|
add edx, 97
|
|
mov al, dl
|
|
jmp end_of_proc
|
|
|
|
uppercase:
|
|
sub eax, 52
|
|
cdq
|
|
mov ebx, 26
|
|
idiv ebx
|
|
add edx, 65
|
|
mov al, dl
|
|
|
|
end_of_proc:
|
|
ret
|
|
|
|
process_char endp
|
|
_main proc
|
|
push ebp
|
|
mov ebp, esp
|
|
|
|
push offset strbuf
|
|
push offset strfmt
|
|
call _scanf
|
|
add esp, 8
|
|
|
|
push offset strbuf
|
|
call _strlen
|
|
add esp, 4
|
|
|
|
mov ecx, eax
|
|
test ecx, ecx
|
|
jz for@end
|
|
for@start:
|
|
dec ecx
|
|
|
|
movzx eax, byte ptr strbuf[ecx]
|
|
push eax
|
|
call process_char
|
|
add esp, 4
|
|
|
|
mov byte ptr strbuf[ecx], al
|
|
|
|
test ecx, ecx
|
|
jnz for@start
|
|
for@end:
|
|
push offset strbuf
|
|
push offset strfmt
|
|
call _printf
|
|
add esp, 8
|
|
push 0
|
|
call ExitProcess
|
|
leave
|
|
ret
|
|
_main endp
|
|
end _main
|