+ -
当前位置:首页 → 问答吧 → 循环cx怎么从6 -> 0 -> ffff 了?

循环cx怎么从6 -> 0 -> ffff 了?

时间:2011-12-13

来源:互联网

data segment
  M dw 0001h,0002h,0000h,0f234h,1455h,0fa69h
  P dw 6 dup(?) ;正数存入此数组 di
  N dw 6 dup(?) ;负数存入此数组
data ends
stack segment stack
  buff dw 100 dup(?)
stack ends
code segment
;-------------------------------
main proc far
  assume ds:data,cs:code,ss:stack
start:
  push ds
  sub ax,ax
  push ax
  mov ax,data
  mov ds,ax 
  mov ax,stack
  mov ss,ax  
  mov di,0
  mov si,0
  mov bx,0
  mov cx,6
rotate:
  mov ax,M[bx]
  cmp ax,0
  jl less
  jg great
  add bx,2
  loop rotate
  jmp print
less:
  mov N[si],ax
  add si,2
  add bx,2
  loop rotate
great:
  mov P[di],ax
  add di,2
  add bx,2
  loop rotate
print:
  shr di,1
  mov dx,di
  add dx,30h
  mov ah,02h
  int 21h ;输出正数的个数
  shr si,1
  mov dx,si
  add dx,30h
  mov ah,02h
  int 21h ;输出负数的个数?
  ret
main endp
;------------------------------------
code ends
end start
  

作者: zk3389   发布时间: 2011-12-13

题目要求将数组N中的正数存入P数组,负数存入N数组,并输出原数组中正数,负数的个数,但我调试程序的时候发现cx为0的时候循环还在继续,并且还继续dec,ffff,fffe...

作者: zk3389   发布时间: 2011-12-13