task1-1源码
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
此时,DS=076a,ss=076b,cs=076c
假设程序加载后,code段地址是x,data段地址是x-2,stack段地址是x-1
task1-2源码
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
此时,DS=076a,SS=076b,CS=076c
假设程序加载后,code段地址是x,data段地址是x-2,stack段地址是x-1
task1-3源码
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
此时,DS=076a,SS=076c,CS=076e
假设程序加载后,code段地址是x,data段地址是x-4,stack段地址是x-2
task1-4源码
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
此时,DS=076c,SS=076e,CS=076a
假设程序加载后,code段地址是x,data段地址是x+2,stack段地址是x+4
任务1-5
xxx segment db N dup(0) xxx ends
(1):程序加载后,实际分配给该段的内存空间大小是 N/16向上取整后再乘以16。
(2):end start是告诉程序,从start处开始执行,task1-1,task1-2,task1-3都是先定义数据段,再执行代码,移出end start之后,代码不能正确执行。而task1-4是先执行代码,再定义数据段,移除end start之后仍然是从第一行开始执行,不会出错。
task1-1修改后调试截图
代码执行出错
task1-2修改后调试截图
代码执行出错
task1-3修改后调试截图
代码执行出错
task1-4修改后调试截图
代码可以执行
实验任务2
assume cs:code code segent start: mov ax,0b800h mov ds,ax mov bx,0f00h mov cx,80 mov ax,0304h s:mov ds:[bx],ah inc bx mov ds:[bx],al inc bx loop s mov ah,4ch int 21h code ends end atart
实验任务三
assume cs:code data1 segment db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 data1 ends data2 segment db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 data2 ends data3 segment db 16 dup(0) data3 ends code segment start: mov ax, data1 mov ss, ax mov ax, data2 mov es, ax mov ax, data3 mov ds, ax mov bx, 0 mov cx, 10 s: mov al, ss:[bx] mov al, es:[bx] mov [bx], al add bx, 1 loop s mov ah, 4ch int 21h code ends 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 es, ax mov ax, data2 mov ss, ax mov sp, 10h mov bx, 0 mov cx, 8 s: push [bx] add bx, 2 loop s mov ah, 4ch int 21h code ends end start
加载反汇编调试截图
数据空间截图
实验任务五
assume cs:code, ds:data data segment db 'Nuist' db 2, 3, 4, 5, 6 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
line19的作用:把小写字母变成大写字母
line4的作用:在显示字母的时候设置颜色
实验任务6
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, 00100000b mov [bx], al add bx, 16 loop s mov ah, 4ch int 21h code ends end start
加载反汇编调试截图
代码执行前数据截图
执行后
实验任务七
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 ax, table mov es, ax mov cx, 5 mov bx, 0 mov si, 0 s: mov ax, [si] mov es:[bx], ax mov ax, [si+2] mov es:[bx+2], ax add bx, 16 add si, 4 loop s mov cx, 5 mov bx, 5 mov si, 20 s1: mov ax, [si] mov es:[bx], ax mov ax, 0000h mov es:[bx+2], ax add bx, 16 add si, 2 loop s1 mov cx, 5 mov bx, 10 mov si, 30 s2: mov ax, [si] mov es:[bx], ax add bx, 16 add si, 2 loop s2 mov cx, 5 mov si, 5 s3: mov ax, es:[si] mov bl, es:[si+5] div bl mov es:[si+8], al add si, 16 loop s3 mov ah, 4ch int 21h code ends end start
调试
原始数据
执行后