.386P
.model FLAT
_DATA SEGMENT ; The NULL-terminated scanf format
$SG397 DB '%s', 00H ; string is stored in global data space.
_DATA ENDS
_TEXT SEGMENT
_string$ = -8 ; Location of "string" in local stack
_main PROC NEAR
sub esp, 8 ; Allocate stack space to store "string"
lea eax, DWORD PTR _string$[esp+8]
push eax ; Push arguments to scanf
push OFFSET FLAT:$SG397
call _scanf
lea ecx, DWORD PTR _string$[esp+16]
push ecx ; Push argument to UpcaseString
call _UpcaseString
add esp, 20 ; Release local stack space
ret 0
_main ENDP
_inputString$ = 8 ; "inputString" location in local stack
_UpcaseString PROC NEAR
mov ecx, DWORD PTR _inputString$[esp-4]
cmp BYTE PTR [ecx], 0
je SHORT $L404 ; If inputString[0]==0, skip the loop
$L403: mov al, BYTE PTR [ecx] ; Load inputString[i] into AL
cmp al, 97 ; 97 == 'a'
jl SHORT $L405
cmp al, 122 ; 122 == 'z'
jg SHORT $L405
sub al, 32 ; 32 == 'a' - 'A'
mov BYTE PTR [ecx], al
$L405: inc ecx ; i++
mov al, BYTE PTR [ecx]
test al, al
jne SHORT $L403 ; Loop if inputString[i] != 0
$L404: ret 0
_UpcaseString ENDP
_TEXT ENDS
END