输入9个字节数,统计显示0和非0的个数

来源:互联网 发布:java写一个单例模式 编辑:程序博客网 时间:2024/05/21 08:38

;输入9个字节数,统计显示0和非0的个数

data segment
   table db 10 dup (0)
    zct db 0
    nzct db 0
data ends
 
CODE SEGMENT
    ASSUME  CS:CODE,DS:data

START:
    MOV AX,data
    MOV DS,AX
    mov ax,0
    MOV CX,9
   
     ;lea si,table
   ;mov si,0 
  S:MOV AH,1
    INT 21H
    MOV table[si],al
    inc si
    ;MOV AH,2
    ;mov dl,20h
    ;INT 21H
    LOOP S 
 
   mov ax,0
   mov si,0
     mov cx,9
     ;lea si,table
  ;mov di,30h
lop1:  
      cmp  table[si],30H
      jz zero            
     
      add nzct,1
      jmp over
      
   
    
zero:  add zct,1
    
over:  inc si
      
      loop lop1
   
       mov cx,9
       ;mov di,0
    lea si,table
 output:
        mov dl, [si]
       ;add dl,30h
       mov ah,2
       int 21h
       ;mov dl,20h
     
      ; mov ah,2
       ;int 21h
       ;mov dl, nzct
       ;add dl,30h
       ;mov ah,2
       ;int 21h
     ;mov ah,4ch
     ; int 21h
     inc si
    loop output
    mov dl, nzct
       add dl,30h
       mov ah,2
    int 21h
    mov dl, zct
       add dl,30h
       mov ah,2
    int 21h
    mov ah,4ch
      int 21h
CODE ENDS
    END START

 

——————————————————————————————————————————————————————

 

 

——————————————————————————————————————————————————————

 

data segment
     table db 10 dup (0)
  zct db 0
  nzct db 0
data ends
code segment
     assume cs:code,ds:data
start: mov ax,data
       mov ds,ax
    mov ax,0
       MOV CX,9
   
      ;lea si,table
      ;mov si,0 
  S:  MOV AH,1
      INT 21H
      MOV table[si],al
      inc si
      ;MOV AH,2
      ;mov dl,20h
      ;INT 21H
      LOOP S
  
      lea si,table 
      mov cx,9
       cld  
lop1:  lodsb
       cmp al,30h
       jz zero            
     
       add nzct,1
       jmp over
      
   
    
zero:  add zct,1
    
over:  nop
      
       loop lop1
   
       mov cx,9
       ;mov di,0
    lea si,table
output:
        mov dl, [si]
       ;add dl,30h
       mov ah,2
       int 21h
       ;mov dl,20h
     
      ; mov ah,2
       ;int 21h
       ;mov dl, nzct
       ;add dl,30h
       ;mov ah,2
       ;int 21h
     ;mov ah,4ch
     ; int 21h
     inc si
    loop output
    mov dl, nzct
       add dl,30h
       mov ah,2
    int 21h
    mov dl, zct
       add dl,30h
       mov ah,2
    int 21h
    mov ah,4ch
      int 21h
CODE ENDS
    END START