;6.ASM
PUBLIC CHANGE5
DATA SEGMENT
BINARY DW 7FFFH,50H
N=($-BINARY)/2
BUF DB 7 DUP(0)
INFO1 DB 0AH,0DH,'THIS IS THE CHANGE FROM HEXNUMBER TO DECIMAL:$'
INFO2 DB 0AH,0DH,'THE NUMBER IS:7FFFH,50H$',0AH,0DH
INFO3 DB 0AH,0DH,'THE RESULT IS:$'
DATA ENDS
STACK SEGMENT STACK
DB 200 DUP(0)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
F2TO10 PROC NEAR
PUSH BX
PUSH DX
PUSH SI
PUSH CX
DISP MACRO M
LEA DX,M
MOV AH,9
INT 21H
ENDM
LEA SI,BUF
OR AX,AX
JNS PLUS
NEG AX
MOV [SI],BYTE PTR '-'
INC SI
PLUS: MOV BX,10
MOV CX,0
LOP1: MOV DX,0
DIV BX
PUSH DX
INC CX
OR AX,AX
JNE LOP1
LOP2: POP AX
CMP AL,10
JB L1
ADD AL,7
L1: ADD AL,30H
MOV [SI],AL
INC SI
DEC CX
JNE LOP2
MOV [SI],BYTE PTR 'D'
INC SI
MOV [SI],BYTE PTR '$'
DISP INFO3
DISP BUF
POP CX
POP SI
POP DX
POP BX
RET
F2TO10 ENDP
CHANGE5 PROC FAR
START: MOV AX,DATA
MOV DS,AX
DISP INFO1
DISP INFO2
MOV CX,N
LEA DI,BINARY
LOPA: MOV AX,[DI]
CALL F2TO10
ADD DI,2
LOOP LOPA
RET
CHANGE5 ENDP
CODE ENDS
END