第2个回答 2012-10-21
DATA SEGMENT
MSG1 DB 0AH,0DH,'Please enter the string:',0AH,0DH,'$'
MSG2 DB 0AH,0DH,'The result is',0AH,0DH,'$'
MSG3 DB 0AH,0DH,'Press enter to exit!',0AH,0DH,'$'
BUF DB 100
DB ?
DB 100 DUP(0)
DATA ENDS
STACK SEGMENT
DB 100H DUP(0)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,100H
MOV DX,OFFSET MSG1
MOV AH,9
INT 21H
MOV DX,OFFSET BUF
MOV AH,0AH
INT 21H
MOV SI,OFFSET BUF
MOV CL,[SI+1]
XOR CH,CH
ADD SI,2
LP: MOV AL,[SI]
CMP AL,41H
JB NEXT
CMP AL,5AH
JNA CHANGE
CMP AL,61H
JB NEXT
CMP AL,7AH
JNA CHANGE
JMP NEXT
CHANGE:
CMP AL,61H
JNB CH2
CH1: ADD AL,4
CMP AL,5AH
JNA NEXT
SUB AL,1AH
JMP NEXT
CH2: ADD AL,4
CMP AL,7AH
JNA NEXT
SUB AL,1AH
NEXT:MOV [SI],AL
INC SI
LOOP LP
MOV BYTE PTR [SI],24H
MOV DX,OFFSET MSG2
MOV AH,9
INT 21H
MOV DX,OFFSET BUF
ADD DX,2
MOV AH,9
INT 21H
MOV DX,OFFSET MSG3
MOV AH,9
INT 21H
EX: MOV AH,7
INT 21H
CMP AL,0DH
JNZ EX
MOV AH,4CH
INT 21H
CODE ENDS
END START