汇编语言:输入一串数字字母字符串,把其中的数字去掉,把大写改小写,小写改大写 15
显示在屏幕上。如:输入15fswSWEE78522sdDAAD,则输出:FSWsweeSDaad...
显示在屏幕上。如:输入15fswSWEE78522sdDAAD,则输出:FSWsweeSDaad
展开
2个回答
展开全部
下列程序符合题目要求:
;=======================================
DATA SEGMENT
MSG1 DB 13, 10, 'Input a STR : $'
MSG2 DB 13, 10, 'The STR is: $'
I1_L DB 100
I1_N DB ?
I1_B DB 100 DUP (?)
I2_B DB 100 DUP (?)
DATA ENDS
;---------------------------------------
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
LEA DX, I1_L
MOV AH, 10
INT 21H
;---------------------------------------
LEA SI, I1_B
LEA DI, I2_B
MOV CL, I1_N
MOV CH, 0
LOP:
MOV AL, [SI]
CMP AL, 'A'
JB NEXT
CMP AL, 'z'
JA NEXT
CMP AL, 'Z'
JB TO_XXX
CMP AL, 'a'
JB NEXT
TO_XXX:
XOR AL, 00100000B
MOV [DI], AL
INC DI
NEXT:
INC SI
LOOP LOP
MOV BYTE PTR [DI], '$'
;---------------------------------------
DISP:
LEA DX, MSG2
MOV AH, 9
INT 21H
LEA DX, I2_B
MOV AH, 9
INT 21H
;---------------------------------------
MOV AH, 4CH
INT 21H
CODE ENDS
END START
;=======================================
程序运行后,将以下列形式显示:
C:\MASM>z
Input a STR : skdpa9293fa okq pPOKSFDPKPASP
The STR is: SKDPAFAOKQPpoksfdpkpasp
;=======================================
DATA SEGMENT
MSG1 DB 13, 10, 'Input a STR : $'
MSG2 DB 13, 10, 'The STR is: $'
I1_L DB 100
I1_N DB ?
I1_B DB 100 DUP (?)
I2_B DB 100 DUP (?)
DATA ENDS
;---------------------------------------
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
LEA DX, I1_L
MOV AH, 10
INT 21H
;---------------------------------------
LEA SI, I1_B
LEA DI, I2_B
MOV CL, I1_N
MOV CH, 0
LOP:
MOV AL, [SI]
CMP AL, 'A'
JB NEXT
CMP AL, 'z'
JA NEXT
CMP AL, 'Z'
JB TO_XXX
CMP AL, 'a'
JB NEXT
TO_XXX:
XOR AL, 00100000B
MOV [DI], AL
INC DI
NEXT:
INC SI
LOOP LOP
MOV BYTE PTR [DI], '$'
;---------------------------------------
DISP:
LEA DX, MSG2
MOV AH, 9
INT 21H
LEA DX, I2_B
MOV AH, 9
INT 21H
;---------------------------------------
MOV AH, 4CH
INT 21H
CODE ENDS
END START
;=======================================
程序运行后,将以下列形式显示:
C:\MASM>z
Input a STR : skdpa9293fa okq pPOKSFDPKPASP
The STR is: SKDPAFAOKQPpoksfdpkpasp
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询