汇编语言字母转换 从键盘输入一个字符串,将其大写字母变为小写字母并显示
发布网友
发布时间:2022-04-29 02:43
我来回答
共2个回答
热心网友
时间:2023-10-07 19:23
DATA SEGMENT
BUF DB 10 DUP(?)
COUNT EQU $-BUF
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
STAPN DB 100 DUP(?)
TOP EQU LENGTH STAPN
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA BX,BUF
MOV CX,COUNT
CALL INPUT
CALL CHANGE
CALL SHOW
MOV AH,4CH
INT 21H
SHOW PROC
PUSH CX
PUSH BX
PUSH AX
MOV AH,2
MOV DL,' '
INT 21H
L6: MOV AH,2
MOV DL,BYTE PTR[BX]
INC BX
INT 21H
LOOP L6
POP AX
POP BX
POP CX
RET
SHOW ENDP
CHANGE PROC
PUSH CX
PUSH BX
PUSH AX
L4: CMP BYTE PTR[BX],'Z'
JBE L2
JA L5
L2: CMP BYTE PTR[BX],'A'
JAE L3
JB L5
L3: ADD BYTE PTR[BX],20H
L5: INC BL
LOOP L4
POP AX
POP BX
POP CX
RET
CHANGE ENDP
INPUT PROC
PUSH CX
PUSH BX
PUSH AX
L1: MOV AH,1
INT 21H
MOV BYTE PTR [BX],AL
INC BX
LOOP L1
POP AX
POP BX
POP CX
RET
INPUT ENDP
CODE ENDS
END START
热心网友
时间:2023-10-07 19:24
要求不高,简单。
程序与运行结果如下所示:
热心网友
时间:2023-10-07 19:24
DATA SEGMENT
BUF DB 10 DUP(?)
COUNT EQU $-BUF
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
STAPN DB 100 DUP(?)
TOP EQU LENGTH STAPN
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA BX,BUF
MOV CX,COUNT
CALL INPUT
CALL CHANGE
CALL SHOW
MOV AH,4CH
INT 21H
SHOW PROC
PUSH CX
PUSH BX
PUSH AX
MOV AH,2
MOV DL,' '
INT 21H
L6: MOV AH,2
MOV DL,BYTE PTR[BX]
INC BX
INT 21H
LOOP L6
POP AX
POP BX
POP CX
RET
SHOW ENDP
CHANGE PROC
PUSH CX
PUSH BX
PUSH AX
L4: CMP BYTE PTR[BX],'Z'
JBE L2
JA L5
L2: CMP BYTE PTR[BX],'A'
JAE L3
JB L5
L3: ADD BYTE PTR[BX],20H
L5: INC BL
LOOP L4
POP AX
POP BX
POP CX
RET
CHANGE ENDP
INPUT PROC
PUSH CX
PUSH BX
PUSH AX
L1: MOV AH,1
INT 21H
MOV BYTE PTR [BX],AL
INC BX
LOOP L1
POP AX
POP BX
POP CX
RET
INPUT ENDP
CODE ENDS
END START
热心网友
时间:2023-10-07 19:25
要求不高,简单。
程序与运行结果如下所示: