I wanna print what the user inputted first. However, it displays the converted uppercase already before the result.
Here's my code:
org 100h
BEGIN:
LEA DX, DASH1
MOV AH, 9
INT 21H
LEA DX,LOWERCASE
MOV AH,09H
INT 21H
LEA SI,STR1
MOV AH,01H
READ:
INT 21H
MOV BL,AL
CMP AL,0DH
JE DISPLAY
XOR AL,20H
MOV [SI],AL
INC SI
JMP READ
DISPLAY:
MOV AL,"$"
MOV [SI],AL
LEA DX,UPPERCASE
MOV AH,09H
INT 21H
LEA DX, STR1
MOV AH, 09H
INT 21H
MOV DL, BH ; space
MOV AH, 02H
INT 21H
LEA DX, UPPERCASE_
MOV AH, 9
INT 21H
LEA DX,STR1
MOV AH,09H
INT 21H
LEA DX, DASH2
MOV AH, 9
INT 21H
MOV AH,4CH
INT 21H
ret
LOWERCASE DB 0DH,0AH,0AH, " Input a 5-letter string: $"
UPPERCASE DB 0DH,0AH, " The uppercase equivalent of $"
UPPERCASE_ DB "is $"
DASH1 DB 0AH,0DH, " ================================================================= $"
DASH2 DB 0AH,0AH,0DH, " ================================================================= $"
STR1 DB 255 DUP(?)
Output:
Input a 5-letter string: asdfg
The uppercase equivalent of ASDFG is ASDFG
^ i want this part to print as `asdfg`
making it The uppercase equivalent of asdfg is ASDFG
P.S. also, how do I make the string limited to 5 only? Its because the string a user can input can exceed more than 5. Any tips?
==============================================================================
CodePudding user response:
You are displaying strings UPPERCASE
, STR1
, UPPERCASE_
,STR1
, respectively, no wonder that STR1
remains the same. You need to reserve one more string STRorig
where you should store the obtained character before its case is changed.
You can use DI
to address STRorig
and then perform STOSB
for saving original AL
to ES:DI
and incrementing DI
.
When you want to limit the size of input string, compare SI
with STR1 5
and if it's above, act as if AL
was equal to 0DH
.