求王爽汇编语言 课程设计1 的代码!
跪求,有种被它折磨的遍体鳞伤的感觉……求大神解救我啊!!!
assume cs:code,ds:data,es:table data segment db '1975','1976','1977','1978','1979','1980','1981' ;year offset scale [0,53h] db '1982','1983','1984','1985','1986','1987','1988' db '1989','1990','1991','1992','1993','1994','1995' dd 16,22,382,1356,2390,8000,16000 ;income offset scale [54h,0a7h] dd 24486,50065,97479,140417,197514,345980,590827 dd 803530,1183000,1843000,2759000,3753000,4649000,5937000 dd 3,7,9,13,28,38,130 ;person offset scale [0a8h,unconcerned] dd 220,476,778,1001,1442,2258,2793 dd 4037,5635,8226,11542,14430,15257,17800 data ends table segment ;statistics db 21 dup ('year summ ne ?? ') ;+0h +5h +0ah +0dh table ends ;year income person avg table2 segment ;dumpinfo db 21 dup (27 dup (' ')) ;+0h +5h +0dh +13h +17h 1Ah table2 ends ;year income person avg crlf '$' ;xxxx xxxxxxx xxxxx xxx xx x code segment start: mov ax,data mov ds,ax mov ax,table mov es,ax ;ds->data,es->table xor si,si xor di,di mov cx,21 mov bx,10 ;si,di used as struct index next: push ds:[si+2] push ds:[si] pop es:[di] pop es:[di+2] ;copy year push ds:[si+56h] push ds:[si+54h] pop es:[di+5] pop es:[di+7] ;copy income push ds:[si+0a8h] pop es:[di+10] ;copy person mov dx,[si+56h] mov ax,[si+54h] div word ptr[si+0a8h] ;calc avg mov es:[di+13],ax ;save avg add si,4 add di,16 ;index -> next struct loop next ;stage1 complete call dumpinfo mov ax,4c00h ;---------------; int 21h ; struct offset ; dumpinfo: ;---------------; max_len(bytes) mov ax,table ; year ; +0h 4 mov ds,ax ; income ; +5h 7 mov ax,table2 ; person ; +0Ah 5 mov es,ax ; avg ; +0Dh 3 xor si,si ;---------------; total = 4+7+5+3 (+5 space) (+2 crlf)(+1 '$') xor di,di ; ; = 19+5++2+1 = 27 mov cx,21 s: push ds:[si+2] push ds:[si] pop es:[di] pop es:[di+2] ;copy year add di,5 ;di->struct.income mov dx,ds:[si+7] mov ax,ds:[si+5] call dtoc add di,8 ;di->struct.person xor dx,dx mov ax,ds:[si+0ah] call dtoc add di,6 ;di->struct.avg xor dx,dx mov ax,ds:[si+0dh] call dtoc mov word ptr es:[di+4],0d0ah ;di->struct.crlf mov byte ptr es:[di+7],'$' ;di->struct.eof add si,16 add di,8 ;di->next struct loop s dumpall: mov cx,21 push es pop ds xor dx,dx s0: mov ah,9 int 21h add dx,27 loop s0 ret ;dump all info dtoc: push cx push di xor cx,cx s3: cmp dx,0ah jna s1 call divdw or bx,30h push bx inc cl mov bx,10 jmp short s3 ;use divdw to fix overflow s1: inc cl div bx or dx,30h push dx xor dx,dx test ax,ax jnz s1 ;normal atoi s2: pop dx mov es:[di],dl inc di loop s2 pop di pop cx ret ;save to table2 divdw: ;quotient=dx:ax,remainder:bx push ax mov ax,dx xor dx,dx div bx mov bp,ax pop ax div bx mov bx,dx mov dx,bp ret ;overflow solution code ends end startstage1: