汇编语言实现显示16进制数 发表于 2018-12-02 | 更新于 2019-03-18 | 阅读次数: 本文字数: 1.9k | 阅读时长 ≈ 2 分钟 将内存单元存储的8个两位16进制数:01H, 25H, 38H, 62H, 8DH, 9AH, BAH, CEH依次显示在屏幕上。 直接转换。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 DATA SEGMENTBUF DB 01H,25H,38H,62H,8DH,9AH,0BAH,0CEHN DW $-BUFX DW 0DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV CX,NBE: MOV N,CX MOV BX,X MOV DL,BUF[BX] INC BX MOV X,BX CALL DELY MOV CX,N CMP CX,1 JE FINISH MOV DL,',' MOV AH,2 INT 21H LOOP BEFINISH:MOV AX,4C00H INT 21HDELY PROC NEAR MOV BL,DL MOV CL,4 SHR DL,CL OR DL,30H CMP DL,39H JBE AD1 ADD DL,7AD1: MOV AH,2 INT 21H MOV DL,BL AND DL,0FH OR DL,30H CMP DL,39H JBE AD2 ADD DL,7AD2: MOV AH,2 INT 21H MOV DL,'H' MOV AH,2 INT 21H RETDELY ENDPCODE ENDS END START 打表法: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 DATA SEGMENTBUF DB 01H,25H,38H,62H,8DH,9AH,0BAH,0CEHN DW $-BUFASCII DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H DB 41H,42H,43H,44H,45H,46HX DW 0Y DB 0DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV CX,NBE: MOV N,CX MOV BX,X MOV DL,BUF[BX] INC BX MOV X,BX MOV CX,N CMP CX,1 JE FINISH MOV DL,',' MOV AH,2 INT 21H LOOP BEFINISH:MOV AX,4C00H INT 21HDELY PROC NEAR MOV Y,DL MOV CL,4 SHR DL,CL MOV BX,OFFSET ASCII MOV AL,DL AND AL,0FH XLAT MOV DL,AL MOV AH,2 INT 21H MOV AL,Y AND AL,0FH XLAT MOV DL,AL MOV AH,2 INT 21H MOV DL,'H' MOV AH,2 INT 21H RETDELY ENDPCODE ENDS END START