汇编语言,将ASCII码十进制数转换为二进制数
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DATA SEGMENT
MES1 DB 'The ascii code of decimal code are:$'
BUF DB 31H,32H,33H
DB 10H DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET BUF
MOV BX,000AH
MOV CX,0002H
MOV AH,00H
MOV AL,[SI]
SUB AL,30H
A1: IMUL BX
ADD AL,[SI+01]
SUB AL,30H
INC SI
LOOP A1
MOV [SI],AX
MOV DX,OFFSET MES1
MOV AH,09H
INT 21H
INC SI ;显示高字节
CALL SHOW
DEC SI ;显示低字节
CALL SHOW
MOV AX,4C00H
INT 21H
SHOW PROC NEAR
MOV AL,DS:[SI]
AND AL,0F0H ;取高4位
SHR AL,4
CMP AL,0AH ;是否是A以上的数
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,DS:[SI]
AND AL,0FH ;取低4位
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
RET
ENDP
CODE ENDS
END START
摘自 jbx929205249的专栏
补充:软件开发 , 其他 ,