- Assembly code
datarea segment arry dw 76,69,84,90,73,88,99,63,100,80 S6 dw ? S7 dw ? S8 dw ? S9 dw ? S10 dw ?datarea endsprognam segmentmain proc far assume cs:prognam,ds:datareastart: push ds sub ax,ax push ax mov ax,datarea mov ds,ax mov S6,0 mov S7,0 mov S8,0 mov S9,0 mov S10,0 call switch retmain endpswitch proc near mov cx,10 mov si,0first: mov ax,arry[si] add si,2 cmp ax,70 jnb next1 inc S6 loop firstnext1: cmp ax,80 jnb next2 inc S7 loop firstnext2: cmp ax,90 jnb next3 inc S8 loop firstnext3: cmp ax,100 jnb next4 inc S9 loop firstnext4: inc S10 loop first retswitch endpprognam ends end start
------解决方案--------------------------------------------------------
datarea segment
arry dw 76,69,84,90,73,88,99,63,100,80
S6 dw ?
S7 dw ?
S8 dw ?
S9 dw ?
S10 dw ?
datarea ends
prognam segment
main proc far
assume cs:prognam,ds:datarea
start:
push ds
sub ax,ax
push ax
mov ax,datarea
mov ds,ax
mov S6,0
mov S7,0
mov S8,0
mov S9,0
mov S10,0
call switch
ret
main endp
switch proc near
mov cx,10
mov si,0
first:
mov ax,arry[si]
add si,2
cmp ax,70
jnb next1
inc S6
loop first
jmp exit
next1:
cmp ax,80
jnb next2
inc S7
loop first
jmp exit
next2:
cmp ax,90
jnb next3
inc S8
loop first
jmp exit
next3:
cmp ax,100
jnb next4
inc S9
loop first
jmp exit
next4:
inc S10
loop first
exit:
ret
switch endp
prognam ends
end start