Summed data, averaging

Note: The original blog account password is lost, it will be transported during the undergraduate notes so far

Buf address in the first memory, the continuous storage in 20 single-byte unsigned numbers, adds them together, to obtain 16-bit result, and store it as a unit to the first site of the res. Please design their own data, such as they are designed to 9 and 90 to 0 to 99, then the result should be summed 990 (03DEH), continue averaging these data, the final result of the operation - and, quotient, a remainder are stored in RES1 (word) and RES2 (bytes) RES3 (bytes) or the like at three
 

DATAS SEGMENT
    ;此处输入数据段代码
    buf db 0,1,2,3,4,5,6,7,8,9,90,91,92,93,94,95,96,97,98,99
   res1 dw ?
   res2 db ?
   res3 db ?  
DATAS ENDS

STACKS SEGMENT
    ;此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX
    ;此处输入代码段代码
      ;宏 显示一个字符
dispchar macro char
         mov ah,2
         mov dl,char
         int 21h
         endm
    ;宏定义完成

    ;宏 显示字符串
dispmsg   macro message
          mov ah,9
          lea dx,message
          int 21h
          endm
    ;宏定义完成

    ;宏 显示十六进制数的四位
disphex   macro hexdata
          local disphex1
          push ax
          push bx
          push cx
          push dx
          mov bx,hexdata
          mov cx,0404h
disphex1: rol bx,cl
          mov al,bl
          and al,0fh
          call htoasc
          dispchar al
          dec ch
          jnz disphex1
          pop dx
          pop cx
          pop bx
          pop ax
          endm
    ;宏定义完成

    mov cx,lengthof buf
    mov bx,0h
    lea si,buf

again: 
    mov al,byte ptr [si]
    cbw 
    adc bx,ax

    inc si
    loop again

    mov word ptr res1,bx
    disphex bx
    mov ax,bx
    mov cl,lengthof buf
    div cl
    mov res2,al
    mov res3,ah
    disphex ax

    MOV AH,4CH
    INT 21H 

    ;子程序十六进制转ASCII
 HTOASC proc
        push bx
        mov bx,offset ASCII
        and al,0fh
        xlat ASCII
        pop bx
        ret
ASCII db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h
      db 41h,42h,43h,44h,45h,46h
HTOASC  endp    
CODES ENDS
    END START
--------------------- 
作者:D??? 
来源:CSDN 
原文:https://blog.csdn.net/qq_31424383/article/details/53319581 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

Published 32 original articles · won praise 7 · views 7586

Guess you like

Origin blog.csdn.net/Isaacddx/article/details/85057529