DATA SEGMENT DATA1 DB DUP(0) DATA3 DB 20 DUP(0) MES2 DB 'The result is:','$' MES4 DB 0DH,0AH,'$' MES5 DB 'Input four hexadecimals:','$' MES6 DB 'Input Error!','$' MES7 DB '0000','$' MES8 DB '0001','$' MES9 DB '0010','$' MES10 DB '0011','$' MES11 DB '0100','$' MES12 DB '0101','$' MES13 DB '0110','$' MES14 DB '0111','$' MES15 DB '1000','$' MES16 DB '1001','$' MES17 DB '1010','$' MES18 DB '1011','$' MES19 DB '1100','$' MES20 DB '1101','$' MES21 DB '1110','$' MES22 DB '1111','$' DATA ENDS STACK SEGMENT ;堆栈段 STA DB 20 DUP(0) TOP EQU LENGTH STA STACK ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATA START: MOV AX,DATA MOV DS,AX MOV ES,AX MOV AX,STACK MOV SS,AX MOV AL,STA MOV SP,AX LEA DX,MES5 MOV AH,09H INT 21H LEA SI,DATA3 MOV CL,20 MOV BL,0 A: MOV AH,01H INT 21H CALL JUDGE INC BL MOV DATA1,BL CMP [SI],24H JE P INC SI CMP CL,0 DEC CL JG A P: LEA DX,MES4 MOV AH,09H INT 21H LEA DX,MES2 MOV AH,09H INT 21H MOV AL,0 LEA SI,DATA3 MOV CL,DATA1 DEC CL B: CALL JUDGE2 INC SI CMP CL,0 DEC CL JG B HLT JUDGE PROC NEAR PUSH AX PUSH SI CMP AL,24H JE B4 CMP AL,30H JGE B1 LEA DX,MES6 MOV AH,09H INT 21H HLT B1: CMP AL,39H JLE B4 CMP AL,41H JGE B2 LEA DX,MES6 MOV AH,09H INT 21H HLT B2: CMP AL,46H JLE B4 CMP AL,61H JGE B3 LEA DX,MES6 MOV AH,09H INT 21H HLT B3: CMP AL,66H JLE B4 LEA DX,MES6 MOV AH,09H INT 21H HLT B4: MOV [SI],AL POP SI POP AX RET JUDGE ENDP JUDGE2 PROC NERA PUSH SI MOV AL,[SI] CMP AL,30H JE C0 CMP AL,31H JE C1 CMP AL,32H JE C2 CMP AL,33H JE C3 CMP AL,34H JE C4 CMP AL,35H JE C5 CMP AL,36H JE C6 CMP AL,37H JE C7 CMP AL,38H JE C8 CMP AL,39H JE C9 CMP AL,41H JE C10 CMP AL,42H JE C11 CMP AL,43H JE C12 CMP AL,44H JE C13 CMP AL,45H JE C14 CMP AL,46H JE C15 CMP AL,61H JE C10 CMP AL,62H JE C11 CMP AL,63H JE C12 CMP AL,64H JE C13 CMP AL,65H JE C14 CMP AL,66H JE C15 C0: LEA DX,MES7 MOV AH,09H INT 21H JMP BBS C1: LEA DX,MES8 MOV AH,09H INT 21H JMP BBS C2: LEA DX,MES9 MOV AH,09H INT 21H JMP BBS C3: LEA DX,MES10 MOV AH,09H INT 21H JMP BBS C4: LEA DX,MES11 MOV AH,09H INT 21H JMP BBS C5: LEA DX,MES12 MOV AH,09H INT 21H JMP BBS C6: LEA DX,MES13 MOV AH,09H INT 21H JMP BBS C7: LEA DX,MES14 MOV AH,09H INT 21H JMP BBS C8: LEA DX,MES15 MOV AH,09H INT 21H JMP BBS C9: LEA DX,MES16 MOV AH,09H INT 21H JMP BBS C10: LEA DX,MES17 MOV AH,09H INT 21H JMP BBS C11: LEA DX,MES18 MOV AH,09H INT 21H JMP BBS C12: LEA DX,MES19 MOV AH,09H INT 21H JMP BBS C13: LEA DX,MES20 MOV AH,09H INT 21H JMP BBS C14: LEA DX,MES21 MOV AH,09H INT 21H JMP BBS C15: LEA DX,MES22 MOV AH,09H INT 21H BBS: POP SI RET JUDGE2 ENDP CODE ENDS END START