MODEL SMALL
.DATA
MSG DB 0DH,0AH, ' ENTER THE STRING :-----> : $'
MSG2 DB 0DH,0AH, ' YOUR STRING IS :-----> : $'
STR1 DB 255 DUP(?)
ONE DB ?
TWO DB ?
.CODE
BEGIN:
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG
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
;CMP BL,0DH
JMP READ
DISPLAY:
MOV AL,'$'
MOV [SI],AL
LEA DX,MSG2
MOV AH,09H
INT 21H
LEA DX,STR1
MOV AH,09H
INT 21H
; MOV AH,4CH
; INT 21H
.EXIT
END BEGIN
这段代码应该将字符串的小写字母改为大写字母,但我不明白......
答案 0 :(得分:3)
正在进行转换的部分在入口循环中被“隐藏”
MOV AH,01H
READ:
INT 21H ; DOS 21h/01h reads char from stdin
MOV BL,AL
CMP AL,0DH ; exit loop if Enter was pressed
JE DISPLAY
XOR AL,20H ; <-- here the case is switched, in ascii
; Bit 0x20 defines upper/lowercase
MOV [SI],AL ; store converted byte in output string
INC SI
;CMP BL,0DH
JMP READ ; perform the loop
ps:你在这个循环中有一个问题,它正在转换输入的所有内容,即使它不是一个字母