用汇编编制程序。
把二进制数转换为十进制,在屏幕上显示。
程序如下:
DATA SEGMENT
BIN1 DW 1101111011010101B
DEC1 DB 6 DUP(0)
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP(0)
STACK1 ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK1
START:MOV AX,DATA
MOV DS,AX
MOV DX,BIN1
MOV DI,OFFSET DEC1
MOV CX,0
LOP1:PUSH CX
MOV AX,DX
MOV DX,0
MOV CX,10
DIV CX
XCHG AX,DX
ADD AL,30H
MOV [DI],AL
INC DI
POP CX
INC CX
CMP DX,0
JNZ LOP1
DEC2:DEC DI
MOV AL,[DI]
MOV DL,AL
MOV AH,2
INT 21H
LOOP DEC2
MOV AH,4CH
INT 21H
CODE ENDS
END START