求一个长为N(小于255)的ARRAY字数组中正数、负数与零的个数,正数的个数存放在DH中,负数的个数存放在DL中,零的个数存放在BH中。

求一个长为N(小于255)的ARRAY字数组中正数、负数与零的个数,正数的个数存放在DH中,负数的个数存放在DL中,零的个数存放在BH中。
(扩展:将统计的结果显示出来)

data segment
         s1 db"the number of positive numbers is:","$"
         s2 db"the number of negative numbers is:","$"
         s3 db"the number of zeros is:","$"
		 crlf db 0ah,0dh,"$";回车换行
        array db 7,2,-9,1,3,-1,0,-3,0
data ends

code segment
         assume cs:code,ds:data
start:
       mov ax,data
       mov ds,ax
       mov si,offset array
       mov cl,0;用于计数,总共9个
      mov bh,0;用于数字为零的计数
      mov ch,0;用于数字为正数的计数
      mov bl,0;用于数字为负数的计数
a:
      cmp cl,9
      je output
      mov al,[si]
     cmp al,0h
      jz zero
     js negative
     jmp positive

zero:
     add bh,1;1h
     jmp o;每一次增加后移动指针

negative:
     add bl,1
     jmp o

positive:
      add ch,1
      jmp o
    
o:
     add cl,1;计数
     add si,1;偏移量
     jmp a;回到起点

output:
     mov dx,offset s1
     mov ah,9
     int 21h
     
     add ch,30h
    mov dl,ch
    mov ah,2
    int 21h
	
	lea dx, crlf                                   
    mov ah, 09h							 
    int 21h
    
     mov dx,offset s2
     mov ah,9
     int 21h
     
     add bl,30h
    mov dl,bl
    mov ah,2
    int 21h
	
	lea dx, crlf                                   
    mov ah, 09h							 
    int 21h

     mov dx,offset s3
     mov ah,9
     int 21h
     
     add bh,30h
    mov dl,bh
    mov ah,2
    int 21h
	
	sub ch,30h
	mov dh,ch
	sub bl,30h
	mov dl,bl
	
mov ah,4ch
int 21h
code ends
end start
          
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nabobess

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值