欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

汇编语言(第三版)王爽,实验七

程序员文章站 2022-04-13 11:40:58
...

(原题目在王爽的《汇编语言》(第三版),p172)

Power idea公司从1975年成立一直到1995年的基本情况如下:

年份                收入(千美元)                雇员(人)                人均收入(千美元)

1975                                 16                               3                              ?

1976                                 22                               7                              ?

1977                                382                              9                              ?

1978                              1356                            13                              ?

1979                              2390                            28                               ?

1980                              8000                            38                               ?

...

1995                         5937000                      17800                              ?

下面的程序中,已经定义好了这些数据:

assume cs:codesg


datasg 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'
    ;year
    dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
    dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
    ;income
    dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
    dw 11542,14430,15257,17800
    ;number
datasg ends

table segment
    db 21 dup('year summ ne ?? ')
table ends

编程,将data段中的数据按如下格式写入到table段中,并计算21年中的人均收入(取整),结果也按照下面的格式保存在table段中。

汇编语言(第三版)王爽,实验七

assume cs:code


datasg 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'
    ;year
    dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
    dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
    ;income
    dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
    dw 11542,14430,15257,17800
    ;number
datasg ends

table segment
    db 21 dup('year summ ne ?? ')
table ends
    
code segment 
start:   
    mov ax,datasg
    mov ds,ax
    
    mov ax,table
    mov es,ax
    
    mov bx,0
    mov cx,21
    mov si,0
    mov di,0a8h;移到雇员数
    
      
t1:
    mov ax,[bx]
    mov es:[si],ax
    mov ax,[bx+2]
    mov es:[si+2],ax;年份完毕
             
    mov ax,[bx+84]  
    mov es:[si+5],ax
    mov ax,[bx+86]
    mov es:[si+7],ax;收入完毕
    
    mov ax,ds:[di]
    mov es:[si+0ah],ax;雇员数完毕     
    
    mov ax,es:[si+5];low 16bit
    mov dx,es:[si+7];high 16bit
    div word ptr es:[si+0ah];avg income
    
    mov es:[si+0dh],ax;存整数商
    
    add bx,4;下一组数据的年份
    add di,2;下一年的雇员数
    add si,16;table 换行
    loop t1 
    
    
    
        
    mov ax,4c00h
    int 21h
    
code ends
end start
    

相关标签: 汇编