发布时间:2022-11-13 23:00
汇编语言编写字母转换,大写转换为小写,使用跳转指令较多,并且做了容错处理,目前没有发现太大的bug,希望对大家学习汇编有帮助。
DATAS SEGMENT
STRING DB 30
DB ?
DB 30 DUP (?)
WARN DB 10,'Input error,Please resume load;',10,'$'
HINT DB 'Please input majuscule:',10,'$'
RESULT DB 10,'Switching results:',10,'$'
CHOICE DB 10,'Whether to continue?(Iput ESC end)',10,'$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
RESTORE:
MOV AH,9
LEA DX,HINT
INT 21H
MOV AH,10
LEA DX,STRING
INT 21H
MOV BL,STRING+1
MOV BH,0
LEA SI,STRING+2
MOV BYTE PTR [SI+BX],'$'
MOV CX,BX
MOV BL,2
CHECK:
CMP STRING[BX],'A'
JL ERROR
CMP STRING[BX],'Z'
JG ERROR
ADD BL,1
LOOP CHECK
MOV BL,STRING+1
MOV BH,0
MOV CX,BX
MOV BL,2
CHANGE:
ADD STRING[BX],32
ADD BL,1
LOOP CHANGE
MOV AH,9
LEA DX,RESULT
INT 21H
LEA DX,STRING+2
INT 21H
MOV AH,9
LEA DX,CHOICE
INT 21H
MOV AH,1
INT 21H
CMP AL,27
JZ EXIT
JMP RESTORE
ERROR:
MOV AH,9
LEA DX,WARN
INT 21H
JMP RESTORE
EXIT:
MOV AH,4CH
INT 21H
CODES ENDS
END START
运行结果如下: