汇编程序21:实验7
1 assume cs:code,ds:data,ss:stack 2 //同时复制程序1 3 data segment 4 db '1975','1976','1977','1978','1979','1980','1981','1982','1983' 5 db '1984','1985','1986','1987','1988','1989','1990','1991','1992' 6 db '1993','1994','1995' 7 8 dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514 9 dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000 10 11 dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226 12 dw 11542,14430,15257,17800 13 data ends 14 15 stack segment 16 dw 0,0,0,0,0,0,0,0 17 stack ends 18 19 table segment 20 db 21 dup ('year sumn ne ?? ') 21 table ends 22 23 code segment 24 start: 25 mov ax,data 26 mov ds,ax //遍历段 27 mov ax,table 28 mov es,ax //储存段 29 mov bx,0 //行偏移 30 mov si,0 //4字节数据偏移 31 mov di,0 //2字节数据偏移 32 mov cx,21 //循环次数 33 s: 34 push cx //压栈的直接目的就是不想让其值在内部改变 35 push di 36 push si 37 mov cx,4 //获取年份字符串,循环遍历单个字符 38 mov di,0 //借di一用 39 s0: 40 mov al,ds:[si] 41 mov es:[bx+di],al 42 inc si 43 inc di 44 loop s0 45 pop si //取出si,使其值改变 46 mov ax,ds:[si+84] //4字节赋值 47 mov dx,ds:[si+86] 48 mov es:[bx+5],ax 49 mov es:[bx+7],dx 50 add si,4 51 pop di //取出di,使其值改变 52 mov ax,ds:[di+168] 53 mov es:[bx+10],ax 54 add di,2 55 mov ax,es:[bx+5] //除法运算 56 mov dx,es:[bx+7] 57 div word ptr es:[bx+10] 58 mov es:[bx+13],ax 59 add bx,10h //行地址+10h 60 pop cx 61 loop s 62 mov ax,4c00h 63 int 21h 64 code ends 65 66 end start
1 assume cs:code,ds:data,ss:stack 2 //分别复制程序2 3 data segment 4 db '1975','1976','1977','1978','1979','1980','1981','1982','1983' 5 db '1984','1985','1986','1987','1988','1989','1990','1991','1992' 6 db '1993','1994','1995' 7 8 dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514 9 dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000 10 11 dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226 12 dw 11542,14430,15257,17800 13 data ends 14 15 stack segment 16 dw 0,0,0,0,0,0,0,0 17 stack ends 18 19 table segment 20 db 21 dup ('year sumn ne ?? ') 21 table ends 22 23 code segment 24 start: 25 mov ax,data 26 mov ds,ax 27 mov ax,table 28 mov es,ax 29 mov bx,0 30 mov si,0 31 mov cx,21 32 s: 33 push cx 34 mov di,0 35 mov cx,4 36 s0: 37 mov al,ds:[si] 38 mov es:[bx+di],al 39 inc si 40 inc di 41 loop s0 42 add bx,10h 43 pop cx 44 loop s 45 mov bx,0 46 mov si,0 47 mov cx,21 48 s3: 49 mov ax,ds:[84+si] 50 mov dx,ds:[86+si] 51 mov es:[bx+5],ax 52 mov es:[bx+7],dx 53 add si,4 54 add bx,10h 55 loop s3 56 mov bx,0 57 mov si,0 58 mov cx,21 59 s5: 60 mov ax,ds:[168+si] 61 mov es:[bx+10],ax 62 add si,2 63 add bx,10h 64 loop s5 65 mov bx,0 66 mov si,0 67 mov cx,21 68 s7: 69 mov ax,es:[bx+5] 70 mov dx,es:[bx+7] 71 div word ptr es:[bx+si+10] 72 mov es:[bx+13],ax 73 add bx,10h 74 loop s7 75 mov ax,4c00h 76 int 21h 77 code ends 78 79 end start