用汇编语言编写一个代码:从键盘上输入一个字符;把其中的大写字母改为小写

2025-01-05 17:31:55
推荐回答(2个)
回答1:

从键盘输入的任何字符的字符串,一个字母大写输出。

数据段

MSG1 DB 13,10,'请输入一个STR:$

MSG2 DB 13,10,'上的STR是:$'
> I1_L DB 100

I1_N DB? I1_B DB 100 DUP(?)

数据

代码段

假设CS:CODE,DS:DATA

START:

MOV结束AX,DATA

MOV DS,AX

LEA DX,MSG1

MOV AH,9

INT 21H

LEA DX,I1_L BR /> MOV AH,10

INT 21H

LEA BX,I1_B

MOV CL I1_N MOV CH,0

LOP:
> MOV AL,[BX]

CMP AL','

JB NEXT

CMP AL,'Z'

JA NEXT

与to_upper:

AL,11011111B

MOV [BX],AL

NEXT:

INC BX

LOOP LOP

DISP:

MOV BYTE PTR [BX ,'$'

LEA DX,MSG2

MOV AH,9

INT 21H

LEA DX,I1_B

MOV AH,9
> INT 21H

MOV AH,4CH

INT 21H

CODE ENDS

结束开始

回答2:

DATA SEGMENT
MSG1 DB 13, 10, 'Please input a STR : $'
MSG2 DB 13, 10, 'The STR in Upper is: $'
I1_L DB 100
I1_N DB ?
I1_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 BX, I1_B
MOV CL, I1_N
MOV CH, 0
LOP:
MOV AL, [BX]
CMP AL, 'a'
JB NEXT
CMP AL, 'z'
JA NEXT
TO_UPPER:
AND AL, 11011111B
MOV [BX], AL
NEXT:
INC BX
LOOP LOP
DISP:
MOV BYTE PTR [BX], '$'
LEA DX, MSG2
MOV AH, 9
INT 21H
LEA DX, I1_B
MOV AH, 9
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START