I am new to MASM coding. I found that it is really difficult to handle with registers, due to lack of knowledge in built-in functions.
I am trying to write a program to change all letters in input string to CAPITAL letters. Here is my code:
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
include msvcrt.inc
includelib msvcrt.lib
.data
InputMsg db "String Input: (At most 20 characters)", 10, 0
OutputMsg db "Your string is ", 0
StringFormat db "%s", 0
.data?
StringData db 20 dup(?)
.code
start:
invoke crt_printf, addr InputMsg
invoke crt_scanf, addr StringFormat, addr StringData, 20
;Change lowercase letter to uppercase
lea ecx, StringData
CounterLoop:
.if [ecx] >= 97
.if [ecx] <= 122
sub [ecx], 32
.endif
.endif
inc ecx
.if [ecx] != 0
jmp CounterLoop
.endif
invoke crt_printf, addr OutputMsg
invoke crt_printf, addr StringData
invoke ExitProcess, NULL
end start
I want to use ecx to store the effective address of StringData. However, A2070 error occured when I want to get the content of StringData.
Is [ecx] incorrect? How can I get the character in StringData using direct addressing? Thank you very much!