汇编语言:从键盘接受一串以“$”结束的字符串,统计其中非数字字符个数。

额、设标号那段怎么写(again~~~~~~~~~~~~~~)以十六进制显示、
2024-12-01 09:42:49
推荐回答(1个)
回答1:

RLF MACRO
MOV DL,0DH
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
ENDM ;回车换行

DATA SEGMENT
MESS1 DB "INPUT STRING,THE END FLAG IS $"
MESS2 DB "TOTAL CHAR COUNT=$"
MESS3 DB "DIGITAL CHAR COUNT=$"
MESS4 DB "NON-DIGITAL CHAR COUNT=$"
SHUL DB 00,00
DATA ENDS

STACK SEGMENT STACK
STA DW 32 DUP(?)
TOP EQU LENGTH STA
STACK ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK
A1 PROC FAR
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV AX,STACK
MOV SS,AX
MOV AX,TOP
MOV SP,AX
MOV BX,0H ;字符计数器
MOV CX,0H ;数字计数器
MOV AH,09H
MOV DX,OFFSET MESS1
INT 21H
RLF
LOOP1:MOV AH,01H
INT 21H
CMP AL,24H
JZ OUTT
CMP AL,30H ;比较是不是“$”是退出
JAE SHU
JMP ZONG
SHU:CMP AL,39H
JA ZONG
INC BX ;数字计数器加一
MOV AX,00H
MOV AX,BX
AAA ;数字调整成十进制
MOV BX,AX
ZONG:INC CX ;总数计数器加一
MOV AX,00H
MOV AX,CX
AAA ;总数调整成十进制
MOV CX,AX
JMP LOOP1
OUTT: ;输出部分
RLF
MOV AH,09H
MOV DX,OFFSET MESS2
INT 21H ;总数输出
MOV AH,02H
MOV DL,CH
ADD DL,30H
INT 21H
MOV DL,CL
ADD DL,30H
INT 21H

RLF
MOV AX,0H
MOV AX,CX
SUB AL,BL ;符号数调整成十进制输出
SUB AH,BH
AAS
MOV CX,AX
MOV AH,09H
MOV DX,OFFSET MESS4
INT 21H
MOV AH,02H
MOV DL,CH
ADD DL,30H
INT 21H
MOV DL,CL
ADD DL,30H
INT 21H

RLF
MOV AH,09H
MOV DX,OFFSET MESS3
INT 21H ;数字输出
MOV AH,02H
MOV DL,BH
ADD DL,30H
INT 21H
MOV DL,BL
ADD DL,30H
INT 21H

MOV AX,4C00H
INT 21H
A1 ENDP
CODE ENDS
END START