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.

65 lines
1019 B
NASM

.686p
.model flat
include kernel32.inc
includelib kernel32.lib
includelib msvcrt.lib
extern _printf:proc
extern _scanf:proc
extern _strlen:proc
extern _getchar:proc
_bss segment
strbuf db 100000 dup(0)
cnt dd 256 dup(0)
_bss ends
.data
strfmt db "%s",0
strPrintfFmt db "Upper:%d Lower:%d",0
.code
_main proc
push ebp
mov ebp, esp
xor ecx, ecx
inp$start:
push ecx
call _getchar
cmp eax, -1
je inp$end
inc cnt[eax*4]
pop ecx
mov byte ptr strbuf[ecx], al
inc ecx
jmp inp$start
inp$end:
xor eax, eax
xor ebx, ebx
xor edx, edx
mov al, 'a'
sum1$start:
cmp al, 'z'
jg sum1$end
add ebx, cnt[eax*4]
inc al
jmp sum1$start
sum1$end:
mov al, 'A'
sum2$start:
cmp al, 'Z'
jg sum2$end
add edx, cnt[eax*4]
inc al
jmp sum2$start
sum2$end:
push ebx
push edx
push offset strPrintfFmt
call _printf
add esp, 12
push 0
call ExitProcess
leave
ret
_main endp
end _main