数据段填入前4个
assume cs:codesg data segment db '1975','1976','1977','1978' ;year dd 16,22,382,1356 ;takein dw 3,7,9,13 ;person data ends table segment db 4 dup ('year summ ne ?? ') table ends codesg segment start: mov ax,data mov ds,ax mov ax,table mov es,ax mov cx,4 mov si,0 mov bp,0 mov bx,0 s: mov ax,ds:[bp] mov es:[si],ax add si,2 mov ax,ds:[bp+2] mov es:[si],ax ;year part add si,3 mov ax,ds:[bp+16] ;low word mov es:[si],ax add si,2 mov ax,ds:[bp+18] ;high word mov es:[si],ax ; summ part add si,3 mov ax,ds:[bx+32] ;person 2byte, year sum 4byte,每次循环所加间隔不同 mov es:[si],ax ;person part add si,3 mov ax,ds:[bp+16] ;重新赋值low word mov dx,ds:[bp+18] ;重新赋值low word div word ptr ds:[bx+32] mov es:[si],ax ;商赋值到平均薪水上 add si,3 ;下一轮 add bp,4 add bx,2 loop s mov ax,4c00h int 21h codesg ends end start
可以看到保存table段的es中第一行:
前四个字节是年份1975(31 39 37 35),然后是空格(20),收入16(10 00 00 00),空格,员工人数3(03 00 ),空格,平均收入(取整)5(05 00)空格
符合我们的预期