【王爽-汇编语言】第八章实验7

时间:2022-02-01 04:54:07

辛辛苦苦折腾到晚上11点半,才把程序调好

累啊.....

 

 

----------------------------------------------------------------------

 

 ssume cs:Codesg
data segment
    ;21年
    db '1975','1976','1977','1978','1979','1980', '1981'
    db '1982', '1983','1984', '1985','1986', '1987','1988'
    db '1989','1990','1991','1992','1993','1994','1995'
   
    ; 21年来,每年的总薪水
    dd 16,22,382,1356,2390,8000,16000,24486,50065,97479
    dd 140417,197514,345980,590827,803530,118300,1843000
    dd 2759000,3753000,4649000,5937000
   
    ;21年来,每年的总员工
    dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037
    dw 5635,8226,11542,14430,15257,17800
data ends

table segment
  ;预留位置,用于显示数据
   db 21 dup ('year summ ne ?? ')
table ends

codesg segment
  start:
            mov ax,data
            mov ds,ax
            mov ax,table
            mov es,ax
            mov si,0
            mov di,0
            mov bx,0
            mov dx,0
            mov cx,21
  s:        mov ax,ds:[si]                         ;年的前两个字节‘19’
             mov es:[di],ax
             mov ax,ds:[si +2]                    ;年的后两个字节‘75','76','77'....
             mov es:[di+2],ax
             mov byte ptr es:[di+4],' '       ;空格
             mov ax,ds:[si +54h]                 ;总薪水的前两个字节,低位(用ax,方便下面进行除法操作)
             mov es:[di+5],ax
             mov dx,ds:[si +56h]                ;总薪水的后两个字节,高位(用dx,方便下面进行除法操作)
             mov es:[di+7],dx
             mov byte ptr es:[di+9],' '       ;空格
             mov ax,ds:[bx+0A8h]              ;总员工数
             mov es:[di+0Ah],ax         
             mov byte ptr es:[di+0Ch],' '   ;空格
             mov ax,ds:[si +54h]           ;因为ax在总员工数已经使用,这里再次用总薪水的前两个字节赋值
             div word ptr ds:[bx+0A8h]     ;计算年人均收入
             mov word ptr es:[di+0Dh],ax   ;计算所得的商
             mov byte ptr es:[di+0Fh],' '    ;空格
            
             add bx,2
             add si,4
             add di,16
             loop s
            
             mov ax,4c00h
             int 21h
 codesg ends
 end start

----------------------------------------------------------------------