#2
xkwy00002014-06-09 15:25
|
程序代码:
data segment
score dw 76,69,84,90,73,88,99,63,100,80
mess db 'the 10 students score :',13,10,'$'
mess1 db 'the number of the score(60-69):','$'
mess2 db 'the number of the score(70-79):','$'
mess3 db 'the number of the score(80-89):','$'
mess4 db 'the number of the score(90-99):','$'
mess5 db 'the number of the score(100):','$'
data ends
extra segment
num1 dw ?
num2 dw ?
num3 dw ?
num4 dw ?
num5 dw ?
extra ends
code segment
;宏定义输出指令print
print macro addr
mov dx,addr
mov ah,09h
int 21h
endm
main proc far
assume cs:code,ds:data,es:extra
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
;输出这10个成绩
print offset mess
mov cx,10
mov si,offset score
next1:
print si
add si,2
loop next1
call crlf
call son
;输出num1、num2、num3、num4、num5的值
mov cx,5
mov si,offset mess1
mov di,offset num1
result:
print si
print di
call crlf
add si,2
add di,2
loop result
ret
main endp
;回车换行crlf
crlf proc far
push dx
push ax
mov ah,02h
mov dl,0dh
mov dl,0ah
int 21h
pop ax
pop dx
ret
crlf endp
son proc near
push ax
push bx
push cx
push si
push di
mov bx,69
mov cx,10
mov si,offset score
mov di,offset num1
;[si(score)分别与bx(69,79,89,99,109)比较
rotate:
cmp [si],bx
jb count
cmp bx,105
je next2
add bx,10
jmp rotate
count:
;inc [di]
add di,2
next2:
add si,2
loop rotate
pop di
pop si
pop cx
pop bx
pop ax
ret
son endp
code ends
end main
score dw 76,69,84,90,73,88,99,63,100,80
mess db 'the 10 students score :',13,10,'$'
mess1 db 'the number of the score(60-69):','$'
mess2 db 'the number of the score(70-79):','$'
mess3 db 'the number of the score(80-89):','$'
mess4 db 'the number of the score(90-99):','$'
mess5 db 'the number of the score(100):','$'
data ends
extra segment
num1 dw ?
num2 dw ?
num3 dw ?
num4 dw ?
num5 dw ?
extra ends
code segment
;宏定义输出指令print
print macro addr
mov dx,addr
mov ah,09h
int 21h
endm
main proc far
assume cs:code,ds:data,es:extra
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
;输出这10个成绩
print offset mess
mov cx,10
mov si,offset score
next1:
print si
add si,2
loop next1
call crlf
call son
;输出num1、num2、num3、num4、num5的值
mov cx,5
mov si,offset mess1
mov di,offset num1
result:
print si
print di
call crlf
add si,2
add di,2
loop result
ret
main endp
;回车换行crlf
crlf proc far
push dx
push ax
mov ah,02h
mov dl,0dh
mov dl,0ah
int 21h
pop ax
pop dx
ret
crlf endp
son proc near
push ax
push bx
push cx
push si
push di
mov bx,69
mov cx,10
mov si,offset score
mov di,offset num1
;[si(score)分别与bx(69,79,89,99,109)比较
rotate:
cmp [si],bx
jb count
cmp bx,105
je next2
add bx,10
jmp rotate
count:
;inc [di]
add di,2
next2:
add si,2
loop rotate
pop di
pop si
pop cx
pop bx
pop ax
ret
son endp
code ends
end main