汇编语言,如何判断一个字符是字母还是数字?? 30
4个回答
展开全部
CODE SEGMENT
ASSUME CS:CODE
BUF DB '1qaz2w,,,,,sx3eASBX7dc'
NUM EQU $-BUF
START:
PUSH CS
POP DS
PUSH CS
POP ES
MOV CX,NUM
LEA SI,BUF
CLD
@M0:
LODSB
CALL ISNUMBER
CMP AH,1
JNE @M1
CALL DISPNUM
JMP @MM
@M1:
CALL ISALPHA
CMP AH,1
JNE @M2
CALL DISPALPHA
JMP @MM
@M2:
MOV AH,2
MOV DL,32
INT 21H
@MM:
LOOP @M0
MOV AH,4CH
INT 21H
;======================================
ISNUMBER PROC NEAR
CMP AL,'0'
JB @NONUMBER
CMP AL,'9'
JA @NONUMBER
MOV AH,1
@NUMEXIT:
RET
@NONUMBER: MOV AH,0
JMP @NUMEXIT
ISNUMBER ENDP
;=========================================
ISALPHA PROC NEAR
CMP AL,'A'
JB @NOALPHA
CMP AL,'z'
JA @NOALPHA
CMP AL,'Z'
JBE @ALPHA
CMP AL,'a'
JAE @ALPHA
JMP @NOALPHA
@ALPHA:
MOV AH,1
@ALPHAEXIT:
RET
@NOALPHA:
MOV AH,0
JMP @ALPHAEXIT
ISALPHA ENDP
;==========================================
DISPNUM PROC NEAR
PUSH AX
PUSH DX
MOV AH,2
MOV DL,'N'
INT 21H
POP DX
POP AX
RET
DISPNUM ENDP
;==========================================
DISPALPHA PROC NEAR
PUSH AX
PUSH DX
MOV AH,2
MOV DL,'A'
INT 21H
POP DX
POP AX
RET
DISPALPHA ENDP
;========================================
CODE ENDS
END START
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
通过ASCII的码值来判断
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询