王爽《汇编语言》实验7

我的未来我决定 提交于 2019-12-22 08:39:38
      DATAS  SEGMENT
              DB        '1975','1976','1977','1978','1979','1980','1981','1982','1983'
              DB        '1984','1985','1986','1987','1988','1989','1990','1991','1992'
              DB        '1993','1994','1995'

              DD        16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
              DD     345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000

              DW        3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
              DW        11542,14430,15257,17800
       DATAS  ENDS
       
      TABLES  SEGMENT
              DB        21 DUP ('year summ ne ?? ')
      TABLES  ENDS
       
      STACKS  SEGMENT   STACK
              DW        8 DUP(0)
      STACKS  ENDS
             
       CODES  SEGMENT
              ASSUME    CS:CODES,DS:DATAS
      START:  MOV       AX,DATAS
              MOV       DS,AX
              MOV       AX,TABLES
              MOV       ES,AX
              
              
              MOV       BX,0
              MOV       BP,0
              MOV       DX,0
              MOV       CX,21

         S1:  PUSH      CX          ;insert the years to the table
              MOV       SI,0
              MOV       DI,0
              MOV       CX,4

         S2:  MOV       AL,DS:[BP+SI]           ;DS:0开始逐个提取年份数字
              MOV       ES:[BX+SI],AL           ;ES:0即为TALBE:0
              INC       SI
              LOOP      S2

              XOR       AX,AX
              MOV       AX,DS:[BP+DI+54H]
              MOV       DX,DS:[BP+DI+56H]
              MOV       ES:[BX+5],AX
              MOV       ES:[BX+7],DX
              
              ADD       BX,10H      ;表格下一行差10H字节
              ADD       BP,4
              ADD       DI,2
                           
              POP       CX
              LOOP      S1
        
              MOV       AX,0
              MOV       BX,0
              MOV       BP,0
              MOV       CX,21
              
         S3:  MOV       AX,DS:[BP+0A8H]         ;雇员数据首地址DS:0A8H
              MOV       ES:[BX+0AH],AX          ;雇员人数在表格区0AH字节处
              
              MOV       AX,ES:[BX+5]            ;从表格中取出收入数据低字放入AX
              MOV       DX,ES:[BX+7]            ;从表格中取出收入数据高字放入DX

              DIV       WORD PTR ES:[BX+0AH]    ;计算人均收入
              MOV       ES:[BX+0DH],AX          ;将ax中的商存入table的0EH处

              ADD       BX,10H
              ADD       BP,2
              LOOP      S3
 
              MOV       AX,4C00H
              INT       21H
       CODES  ENDS
              END       START

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!