DATA SEGMENT
A DB 148 ;在这里写入:0~255
B DB 28 ;在这里写入:0~255
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, A ;取来A
MOV AH, 0
MOV BL, B ;取来B
MOV BH, 0
ADD AX, BX ;相加
SHR AX, 1 ;除以2
DISP: ;以16进制形式显示
MOV AH, 0
MOV BL, 16
DIV BL
PUSH AX
CMP AL, 10
JB A30
ADD AL, 7
A30:
ADD AL, 30H
MOV DL, AL
MOV AH, 2
INT 21H
POP AX
CMP AH, 10
JB A302
ADD AH, 7
A302:
ADD AH, 30H
MOV DL, AH
MOV AH, 2
INT 21H
MOV DL, 'H'
MOV AH, 2
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
程序运行后,将以16进制形式显示平均值58H。
编制程序完成 12h,45h,0F3h,6Ah,20h,0FEh,90h,0C8h,57h 和34h等10DATAS SEGMENT bdata db 01h,02h,03h,04h,05h,06h,07h,08h,09h,