diff --git a/3.1.asm b/3.1.asm new file mode 100644 index 0000000..771bae5 --- /dev/null +++ b/3.1.asm @@ -0,0 +1,93 @@ +.686p +.model flat +include kernel32.inc +includelib kernel32.lib +includelib msvcrt.lib +extern _printf:proc +extern _scanf:proc +extern _strlen:proc +_bss segment +strbuf db 100000 dup(0) +_bss ends +.data +strfmt db "%s",0 +strPrintfFmt db "%s",10,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, 74 + cdq + mov ebx, 26 + idiv ebx + add edx, 97 + mov al, dl + jmp end_of_proc + +uppercase: + sub eax, 42 + 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 +start: + push offset strbuf + push offset strfmt + call _scanf + not eax + test eax, eax + jz exit + 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 strPrintfFmt + call _printf + add esp, 8 + jmp start +exit: + push 0 + call ExitProcess + leave + ret +_main endp +end _main