02是输出一个字符,9是输出字符串,而且你的程序应该只烂陪是把字符串转铅滑换程序数字,并没有把十进制转换成二进制。这样试试饥激蠢
LOOP
LOOP1
MOV
[DI],AX
MOV
AH,9
INT
21H
MOV
AH,4CH
INT
21H
-------------------------------------DATA1 SEGMENT
NUM DW 13579
ASC DB ?, ?, ?, ?
DATA1 ENDS
-------------------------------------
CODE SEGMENT PARA PUBLIC
ASSUME CS:CODE, DS:DATA1
START:
MOV AX, DATA1
MOV DS, AX
MOV BX, NUM
LEA DI, ASC
CALL HEX_ASC
MOV AH, 2
MOV DL, ASC + 0
INT 21H
MOV DL, ASC + 1
INT 21H
MOV DL, ASC + 2
INT 21H
MOV DL, ASC + 3
INT 21H
MOV AH, 4CH
INT 21H
====================================
HEX_ASC PROC NEAR
MOV CX, 0404H
CC: ROL BX, CL循环左移,慧裤将最高为郑碧段喊誉存到BL的低四位
MOV DL, BL
AND DL, 0FH
CMP DL, 10
JBBB
ADD DL, 7
BB: ADD DL, '0'
MOV [DI], DL
INC DI
DEC CH
JNZ CC
RET
HEX_ASC ENDP
====================================
CODE ENDS
-------------------------------------
END START
--------------------------------------------DATASEGMENT
PROMPT DB 'INPUT HEXADECIMAL: $'
HEX DB 5
NNN DB 0 实际输入的字符数
DB 5 DUP(?)
BIN DW ?
ERR DB 0AH, 0DH, 'ERROR ! I HAVE NO TIME TO PLAY WITH YOU ! $'
DATAENDS
--------------------------------------------
STACK1 SEGMENT PARA STACK
DW 20H DUP(0)
STACK1 ENDS
--------------------------------------------
CODESEGMENT
ASSUME CS:CODE, DS:DATA, ES:DATA, SS:STACK1
START:
MOV AX, DATA
MOV DS, AX
MOV AX, STACK1
MOV SS, AX
LEA DX, PROMPT
MOV AH, 09H
INT 21H
LEA DX, HEX输入ASCII码
MOV AH, 0AH
INT 21H
---------------------------------------
MOV BIN, 0
LEA SI, HEX + 2
MOV CH, NNN
CONV: 代迟渗码转换
MOV BL, [SI]
CMP BL, 0DH
JZ END0 回车即结束
CMP BL, '0'
JB ERROR 小于纤旅'0'转移
CMP BL, '毁旦凳9'
JA ERROR 大于'9'转移
BIN1:
AND BL, 0FH转换二进制数
MOV BH, 0 弄成16位数
PUSH CX
MOV AX, BIN原来的数字乘以10
MOV CX, 10
MUL CX
ADD AX, BX 加上新输入的
MOV BIN, AX存结果
INC SI
POP CX
DEC CH
JNZ CONV
---------------------------------------
DISP:
MOV DL, 13 显示回车
MOV AH, 2
INT 21H
MOV DL, 10 显示换行
MOV AH, 2
INT 21H
---------------------------------------
MOV AX, BIN取来数字
MOV CX, 16 显示16位数
DDDD:
MOV DL, '0'先计划显示0
TEST AX, 8000H 测试最高位
JZ DDD1
INC DL 非0就显示1
DDD1:
PUSH AX
MOV AH, 2
INT 21H
POP AX
SHL AX, 1 左移
LOOP DDDD
JMP END0
---------------------------------------
ERROR:
LEA DX, ERR
MOV AH, 09H
INT 21H
---------------------------------------
END0:
MOV AH, 4CH
INT 21H
CODE ENDS
---------------------------------------
END START
---------------------------------------
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)