已知一个班的成绩,进行60,70,80,90,100分段统计
程序运行:
代码:
datas segmentstudents_number dw 10students dw 76,69,84,90,73,88,99,63,100,80s6 dw 0hs7 dw 0hs8 dw 0hs9 dw 0hs10 dw 0houtput_s6 db 's6=$'output_s7 db 0dh,0ah,'s7=$'output_s8 db 0dh,0ah,'s8=$'output_s9 db 0dh,0ah,'s9=$'output_s10 db 0dh,0ah,'s10=$'datas endsstacks segment stackdb 100h dup(?)stacks endscodes segmentassume cs:codes,ds:datas,ss:stacks
main proc far
start:push dsmov ax,0hpush axmov ax,datas ;初始化dsmov ds,axmov cx,students_numbercmp cx,0 jz no_studentmov si,0s:mov ax,students[si]cmp ax,100ja nextjb low100inc s10 ;为100,计数器s10加一jmp nextlow100:cmp ax,90 jb low90inc s9 ;为90-99,计数器s9加一jmp nextlow90:cmp ax,80 jb low80inc s8 ;为80-89,计数器s8加一jmp nextlow80:cmp ax,70 jb low70inc s7 ;为70-79,计数器s7加一jmp nextlow70:cmp ax,60 jb nextinc s6 ;为60-69,计数器s6加一next: add si,type studentsloop s lea dx,output_s6 ;输出s6mov ah,9int 21h mov ax,s6call print_decimallea dx,output_s7 ;输出s7mov ah,9int 21h mov ax,s7call print_decimallea dx,output_s8 ;输出s8mov ah,9int 21h mov ax,s8call print_decimallea dx,output_s9 ;输出s9mov ah,9int 21h mov ax,s9call print_decimallea dx,output_s10 ;输出s10mov ah,9int 21h mov ax,s10call print_decimaljmp exitno_student:exit:retmain endp
print_decimal proc near uses ax bx cx dx mov cx,0mov bx,10 de: xor dx,dx div bx push dx inc cx cmp ax,0 jnz de de1:pop dx add dl,30h mov ah,2 int 21h loop de1ret
print_decimal endp
codes endsend main