哈哈 有了 共享一下吧
DATA SEGMENT
DAT DW 32768D,16384D,8192D,4096D,2048D,1024D,512D,256D,128D,64D,32D,16D,8D,4D,2D,1D
DATAW DW 2710H,03E8H,64H,0AH,0001H
TEMP DB 0
TEMPDEC DW 0
DATA ENDS
;**********************************************;
STACK SEGMENT STACK 'STACK'
STA DB 50 DUP(?)
STACK ENDS
;**********************************************;
CODE SEGMENT
ASSUME CS:CODE,DS:DATA ;,SS:STACK
START: MOV AX,DATA
MOV DS,AX
LEA BX,DAT
MOV SI,0
MOV DX,0
MOV CX,0
CLOOP: CALL ENTER_BIN ;return TEMP
NOPOP: CMP TEMP,1
JE YES_1
CMP TEMP,0
JE YES_0
JMP EXITLOOP
YES_1: ADD CX,WORD PTR[BX]
YES_0: INC BX
INC BX
INC SI
CMP SI,15D
JBE CLOOP
EXITLOOP:MOV DX,CX
INC SI
MOV CX,SI
RCL DX,CL
CALL CR_LF
CALL PRINT_DEC ;DX enter to PRINT_DEC or PRINT_HEX
CALL CR_LF
EXIT: MOV AX,4C00H
INT 21H
;-------------------------------------------------;
ENTER_BIN PROC NEAR ;return TEMP
MOV AH,01H
INT 21H
SUB AL,30H
MOV TEMP,AL
RET
ENTER_BIN ENDP
;-------------------------------------------------;
;PRINT_HEX PROC NEAR ;DX enter to PRINT_DEC or PRINT_HEX
;MOV AH,2
;INT 21H
;RET
;PRINT_HEX ENDP
;-------------------------------------------------;
PRINT_DEC PROC NEAR ;DX enter to PRINT_DEC or PRINT_HEX
MOV AX,DX
LEA BX,DATAW
MOV SI,0
MOV CX,05H
PLOOP: XOR DX,DX
DIV WORD PTR [BX+SI]
ADD AX,30H
XCHG AX,DX
MOV TEMPDEC,AX
MOV AH,02H
INT 21H
MOV AX,TEMPDEC
INC SI
INC SI
LOOP PLOOP
RET
PRINT_DEC ENDP
;-------------------------------------------------;
CR_LF PROC NEAR
MOV TEMP, DL
MOV DL,0DH
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
MOV DL,TEMP
RET
CR_LF ENDP
;-------------------------------------------------;
CODE ENDS
END START