在下面的数据段中,给出了全班3名同学OS、AL、SE、DB课程的成绩,请编程计算出平均成绩,写在 ? 处。
用jcxz指令构造循环:
data segment
db ‘201658501101’,’JiangY ‘,90,100,76,89,?
db ‘201658501102’,’XuYY ‘,97,82,79,88,?
db ‘201658501103’,’ZhangT ‘,77,98,89,91,?
db 4 ;这是课程门数,将要用于作除数,偏移量为75
data ends
下面是程序,以及运行后的截图
源程序:
assume cs:code ,ds:data,ss:stack
data segment
db '201658501101','JiangY ',90,100,76,89,?
db '201658501102','XuYY ',97,82,79,88,?
db '201658501103','ZhangT ',77,98,89,91,?
db 4 ;这是课程门数,将要用于作除数,偏移量为75
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start: mov ax, stack
mov ss, ax
mov sp, 16
mov ax, data
mov ds, ax
mov bp, 0
mov cx, 4
s0: jcxz ko
push cx
mov si, 0
mov cx, 4
mov ax, 0
s: jcxz ok
mov bl, ds:[bp+si+20]
mov bh, 0
add ax, bx
add si, 1
loop s
ok: div byte ptr ds:[75]
mov ds:[bp+si+20], al
add bp, 25
pop cx
loop s0
ko: mov ax,4c00h
int 21h
code ends
end start