当前位置: 代码迷 >> 汇编语言 >> 为什么这个程序的结果不对?小弟我想在s6、s7、s8、s9、s10中分别存放60-69,70-79,80-89,90-99,100这些范围的数的个数
  详细解决方案

为什么这个程序的结果不对?小弟我想在s6、s7、s8、s9、s10中分别存放60-69,70-79,80-89,90-99,100这些范围的数的个数

热度:1744   发布时间:2013-02-26 00:00:00.0
为什么这个程序的结果不对?我想在s6、s7、s8、s9、s10中分别存放60-69,70-79,80-89,90-99,100这些范围的数的个数
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
  相关解决方案