1.实验任务1
任务1-1
task1_1.asm源码:
assume ds:data, cs:code, ss:stack data segment db 16 dup(0) data ends stack segment db 16 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 16 mov ah, 4ch int 21h code ends end start
调试到line17结束、line19之前截图:
问题回答:
(1)在debug中将执行到line17结束,line19之前,记录此时寄存器(DS)= 076A ,寄存器(SS)= 076B ,寄存器(CS)= 076C
(2)假设程序加载后,code段的段地址是X,则data段的段地址是X-2,stack的段地址是X-1
任务1-2
task1_2.asm源码:
assume ds:data, cs:code, ss:stack data segment db 4 dup(0) data ends stack segment db 8 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 8 mov ah, 4ch int 21h code ends end start
调试到line17结束,line19之前寄存器DS,CS,SS的截图:
问题回答
(1)在debug中将执行到line17结束、line19之前,此时,寄存器(DS)= 076A,寄存器(SS)= 076B,寄存器(CS)= 076C
(2)假设程序加载后,code段的段地址是X,则data段的段地址是X-2,stack的段地址是X-1
任务1-3
task1_3.asm源码:
assume ds:data, cs:code, ss:stack data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends end start
调试到line17结束、line19之前寄存器DS,CS,SS的截图:
问题回答:
(1)在debug中将执行到line17结束、line19之前,此时,寄存器(DS)= 076A,寄存器(SS)= 076C,寄存器(CS)= 076E
(2)假设程序加载后,code段的段地址是X,则data段的段地址是X-4,stack的段地址是X-2
任务1-4
task1_4.asm源码:
assume ds:data, cs:code, ss:stack code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends end start
调试到line17结束、line19之前DS、CS、SS的截图:
问题回答:
(1)在debug中将执行到line17结束、line19之前,此时,寄存器(DS)= 076C,寄存器(SS)= 076E,寄存器(CS)= 076A
(2)假设程序加载后,code段的段地址是X,则data段的段地址是X+2,stack的段地址是X+4
任务1-5
(1)对于如下定义的段,程序加载后,实际分配给该段的内存空间大小是 ceil(N/16) x 16
xxx segment db N dup(0) xxx ends
(2)task1_1、1_2、1_3均不能正常执行,task1_4可以执行,因为程序无法找到end start,将从头开始执行,而前3个程序的开头均为数据段,程序无法执行,只有task1_4开头是代码段,程序能够正常识别运行。
2.实验任务2
源代码:
assume cs:code code segment start: mov ax,0b800h mov ds,ax mov bx,0f00h mov cx,80 s:mov [bx],0403h add bx,2 loop s mov ah,4ch int 21h code ends end start
运行结果截图:
3.实验任务3
源代码:
assume cs:code data1 segment db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers data1 ends data2 segment db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 ;ten numbers data2 ends data3 segment db 16 dup(0) data3 ends code segment start: mov bx,0 mov cx,10 s: mov ax,data1 mov ds,ax mov dl,[bx] mov ax,data2 mov ds,ax add dl,[bx] mov ax,data3 mov ds,ax mov [bx],dl inc bx loop s mov ah,4ch int 21h code ends end start
相加之前data1,data2,data3截图:
相加之后data1,data2,data3截图:
4.实验任务4
源代码:
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,data2 mov ss,ax mov sp,10h mov ax,data1 mov ds,ax mov bx,0 mov cx,8 s: push [bx] add bx,2 loop s mov ah, 4ch int 21h code ends end start
使用d命令查看data2对应内存的截图:
5.实验任务5
task5.asm源码:
assume cs:code, ds:data data segment db 'Nuist' db 5 dup(2) data ends code segment start: mov ax, data mov ds, ax mov ax, 0b800H mov es, ax mov cx, 5 mov si, 0 mov di, 0f00h s: mov al, [si] and al, 0dfh mov es:[di], al mov al, [5+si] mov es:[di+1], al inc si add di, 2 loop s mov ah, 4ch int 21h code ends end start
运行结果截图:
g命令一次性执行到程序返回前的截图:
源代码中line19的作用是:将小写字母转换为大写字母
源代码中data段line4的字节数据的用途是控制字体颜色
替换之后效果如下:
6.实验任务6
task6.asm源码:
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 bx,0 mov cx,4 s: mov al,[bx] or al,20h mov [bx],al mov al,[bx + 1] or al,20h mov [bx + 1],al mov al,[bx + 2] or al,20h mov [bx +2],al mov al,[bx + 3] or al,20h mov [bx+3],al add bx,16 loop s mov ah, 4ch int 21h code ends end start
使用d命令查看data段对应的内存空间的截图:
7.实验任务7
task7.asm源码:
assume cs:code, ds:data, es:table data segment db '1975', '1976', '1977', '1978', '1979' dw 16, 22, 382, 1356, 2390 dw 3, 7, 9, 13, 28 data ends table segment db 5 dup( 16 dup(' ') ) ; table ends code segment start: mov ax,data mov ds,ax mov bx,0 mov ax,table mov es,ax mov cx,5 mov bp,0 year: mov ax,[bx] mov es:[bp],ax mov ax,[bx+2] mov es:[bp+2],ax add bp,10h add bx,4 loop year mov cx,5 mov bp,6 salary: mov ax,[bx] mov es:[bp],ax add bp,10h add bx,2 loop salary mov cx,5 mov bp,9 employee:mov ax,[bx] mov es:[bp],ax add bp,10h add bx,2 loop employee mov cx,5 mov si,6 ren: mov ax,es:[si] mov bl,es:[si+3] div bl mov es:[si+6],al add si,10h loop ren mov ah, 4ch int 21h code ends end start
table段原始数据信息截图:
程序退出前,使用D命令查看table段对应的内存空间截图: