任务一:
1-1
1.DS=076A SS=076B CS=076C
2.data =X-2;stack=X-1.
1-2
1-3
1.DS=076A ;SS=076C;CS=076E
2.Data =X-4; stack =X-2;
1-4
1-5
1.N
2.task1_4可以正常运行
任务二
代码:
assume cs:code code segment start: mov ax,0b800h mov ds,ax mov bx,0f00h mov cx,50h mov ax,0403h s: mov ds:[bx],ax add bx,2 loop s mov ah,4ch int 21h code ends end start
运行结果:
显示会冒出爱心....
任务三
代码:
1 assume cs:code 2 data1 segment 3 db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers 4 data1 ends 5 6 data2 segment 7 db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 ; ten numbers 8 data2 ends 9 10 data3 segment 11 db 16 dup(0) 12 data3 ends 13 14 code segment 15 start: 16 mov ax,data1 17 mov ds,ax 18 mov bx,0 19 mov cx,0ah 20 s: mov ax,ds:[bx] 21 add ax,ds:[bx+10h] 22 mov ds:[bx+20h],ax 23 inc bx 24 loop s 25 mov ah,4ch 26 int 21h 27 code ends 28 end start
相加前:
执行后:
任务四
代码:
assume cs:code data1 segment dw 2, 0, 4, 9, 2, 0, 1, 9 data1 ends data2 segment dw 8 dup(?) data2 ends code segment start: mov ax,data1 mov ds,ax mov sp,9 mov bx,0 mov cx,8 s1: push ds:[bx] add bx,2 loop s1 mov ax,data2 mov ds,ax mov bx,0 mov cx,8 s2: pop ds:[bx] add bx,2 loop s2 mov ah, 4ch int 21h code ends end start
运行前:
执行后:
任务五:
源代码执行后
左下角被遮住的彩色NUIST
改为 db 5 dup(2) 字体变为绿色
改为 db 5 dup(5) 字体变为紫色
Line 19行作用 将小写字母转为大写
任务六
代码:
assume cs:code, ds:data data segment db 'Pink Floyd ' db 'JOAN Baez ' db 'NEIL Young ' db 'Joan Lennon ' data ends code segment start: mov ax,data mov ds,ax mov ax,data mov es,ax mov bx,0 mov cx,4 s1: mov si,cx mov cx,4 s2: mov al,es:[bx] or al,20h mov es:[bx],al inc bx loop s2 mov cx,si mov bx,0 mov ax,es inc ax mov es,ax loop s1 mov ah, 4ch int 21h code ends end start
执行前
执行后:
任务七:
代码:
1 assume cs:code, ds:data, es:table 2 3 data segment 4 db '1975', '1976', '1977', '1978', '1979' 5 dw 16, 22, 382, 1356, 2390 6 dw 3, 7, 9, 13, 28 7 data ends 8 9 table segment 10 db 5 dup( 16 dup(' ') ) ; 11 table ends 12 13 code segment 14 start: 15 mov ax, data 16 mov ds, ax 17 mov ax, table 18 mov es, ax 19 20 mov bx, 0 21 mov si, 0 22 mov di, 0 23 mov cx, 5 24 year: mov dx, cx 25 mov cx, 4 26 yearnum: mov al, byte ptr ds:[di] 27 mov byte ptr es:[bx][si], al 28 inc si 29 inc di 30 loop yearnum 31 32 mov cx, dx 33 add bx, 10h 34 mov si, 0 35 loop year 36 37 mov bx, 0 38 mov si, 5 39 mov cx, 5 40 income: mov ax, word ptr ds:[di] 41 mov word ptr es:[bx][si], ax 42 add si, 2 43 add di, 2 44 mov ax, word ptr ds:[di] 45 mov word ptr es:[bx][si], ax 46 add si, 2 47 add di, 2 48 add bx, 10h 49 mov si, 5 50 loop income 51 52 mov bx, 0 53 mov si, 0Ah 54 mov cx, 5 55 employee: mov ax, word ptr ds:[di] 56 mov word ptr es:[bx][si], ax 57 add si, 2 58 add di, 2 59 add bx, 10h 60 mov si, 0Ah 61 loop employee 62 63 mov bx, 0 64 mov si, 5 65 mov cx, 5 66 average: mov ax, word ptr es:[bx][si] 67 add si, 2 68 mov dx, word ptr es:[bx][si] 69 add si, 3 70 div word ptr es:[bx][si] 71 add si, 3 72 mov word ptr es:[bx][si], ax 73 add bx, 10h 74 mov si, 5 75 loop average 76 77 mov ah, 4ch 78 int 21h 79 code ends 80 end start
存储:
执行结果:
实验总结:
本次实验的完成需要掌握loop指令中寄存器间数据的转存,理清楚每一次寄存器跳过的地址数。
使用debug工具对程序进行调试,使用g命令一次性执行到程序返回前.