1、屏蔽方式:DATA SEGMENTDATA0 DB Please enter a hexadecimal number sixteen: ,0DH,0AH,$ DATA2 DB 0DH,0AH,OUT:$ DATA1 DB 100,0 DUP(0)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA DX,DATA0MOV AH,9INT 21HLEA DX,DATA1MOV AH,0AHINT 21HMOV CX,0MOV CL,DATA1+1ADD DX,CXMOV BX,DXMOV BYTE PT
2、RBX+2,$MOV DX,0LEA DX,DATA1+2MOV AH,9INT 21HLEA DX,DATA2MOV AH,9INT 21HLEA DI,DATA1+2NEXT:MOV AL,DISUB AL,30HCMP AL,09HJA NEXT3JMP NEXT1NEXT3: SUB AL,07HCMP AL,0FHJA NEXT4JMP NEXT1NEXT4:SUB AL,20HJMP NEXT1 NEXT1: MOV BL,ALPUSH CXMOV CX,0MOV CX,4ROL BL,CLNEXT2: ROL BL,1MOV DL,BLAND DL,1ADD DL,30HMOV
3、AH,2INT 21HLOOP NEXT2MOV DL,20HMOV AH,2INT 21HPOP CXINC DILOOP NEXTMOV AH,4CHINT 21HCODE ENDSEND STARTCF 寄存器方式DATA SEGMENTDATA0 DB Please enter a hexadecimal number sixteen: ,0DH,0AH,$ DATA2 DB 0DH,0AH,OUT:$ DATA1 DB 100,0 DUP(0)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLE
4、A DX,DATA0MOV AH,9INT 21HLEA DX,DATA1MOV AH,0AHINT 21HMOV CX,0MOV CL,DATA1+1ADD DX,CXMOV BX,DXMOV BYTE PTRBX+2,$MOV DX,0LEA DX,DATA1+2MOV AH,9INT 21HLEA DX,DATA2MOV AH,9INT 21HLEA DI,DATA1+2NEXT:MOV AL,DISUB AL,30HCMP AL,09HJA NEXT3JMP NEXT1NEXT3: SUB AL,07HCMP AL,0FHJA NEXT4JMP NEXT1NEXT4:SUB AL,20HJMP NEXT1 NEXT1: MOV BL,ALPUSH CXMOV CX,0MOV CX,4ROL BL,CLNEXT2: ROL BL,1MOV DL,0ADC DL,30HMOV AH,2INT 21HLOOP NEXT2MOV DL,20HMOV AH,2INT 21HPOP CXINC DILOOP NEXTMOV AH,4CHINT 21HCODE ENDSEND START运行结果: