实验3 多个段的汇编源程序编写与调试
一.实验内容
task1
代码:
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
实验结果:
改变代码后:
line 15~25 将字符转换成大写,并修改成后五个字表示的颜色,输出到界面的底部;这里修改的是存储输出的字符颜色
task2
代码:
assume cs:code, ds:data data segment db 23,50,66,71,35 data ends code segment start: mov ax,data mov ds,ax mov dh,0ah mov di,0 mov cx,5 s: mov al,[di] mov ah,00h div dh add al,30h add ah,30h mov bx,ax inc di mov ah,2 mov dl,bl int 21h mov dl,bh int 21h mov dl,20h int 21h loop s mov ah,4ch int 21h code ends end start
截图:
task3
代码:
assume cs:code, ds:data, ss:stack data segment dw 0123h, 0456h, 0789h, 0abch, 0defh, 0fedh, 0cbah, 0987h data ends stack segment dw 0, 0, 0, 0, 0, 0, 0, 0 stack ends code segment start: mov ax,stack mov ss, ax mov sp,16 mov ax, data mov ds, ax push ds:[0] push ds:[2] pop ds:[2] pop ds:[0] mov ax,4c00h int 21h code ends end start
问题1:
data段中数据为:23 01 56 04 89 07 BC 0A EF 0D ED 0F BA 0C 97 09
问题2:cs=076c,ss076b,ds=076a.
问题3:data段段地址为X-1;stack段段地址为X-2
task4
代码:
assume cs:code, ds:data, ss:stack data segment dw 0123h, 0456h data ends stack segment dw 0, 0 stack ends code segment start: mov ax,stack mov ss, ax mov sp,16 mov ax, data mov ds, ax push ds:[0] push ds:[2] pop ds:[2] pop ds:[0] mov ax,4c00h int 21h code ends end start
问题1:
data段中的数据为:23 01 56 04 00 00 00 00 00 00 00 00 00 00 00 00
问题2:
cs=076c;ss=076b;ds=076a.
问题3:data段段地址为X-1;stack段段地址为X-2
问题4:实际占有空间为N
task5
代码:
assume cs:code, ds:data, ss:stack code segment start: mov ax,stack mov ss, ax mov sp,16 mov ax, data mov ds, ax push ds:[0] push ds:[2] pop ds:[2] pop ds:[0] mov ax,4c00h int 21h code ends data segment dw 0123h, 0456h data ends stack segment dw 0,0 stack ends end start
问题1:data段中的数据为:23 01 56 04 00 00 00 00 00 00 00 00 00 00 00 00
问题2:cs=076a;ss=076e;ds=076d。
问题3:data段段地址为X+3,stack段段地址为X+4
task6
只有 task5 中的代码能正确执行。
只有task5 中将代码书写在前面,当代码存在"end start"时,程序会从start标记的位置开始执行,否则从头开始执行程序从头执行,
所以只有task5可以正确执行
task7
代码:
assume cs:code a segment db 1,2,3,4,5,6,7,8 a ends b segment db 1,2,3,4,5,6,7,8 b ends c segment ; db 8 dup(0) c ends code segment start: mov ax,a mov ds,ax mov bx,0 mov cx,8 s: mov ax,ds:[bx] add ax,ds:[bx+16] mov ds:[bx+32],ax inc bx loop s mov ah,4ch int 21h code ends end start
截图:
task8
代码:
assume cs:code a segment dw 1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffh a ends b segment dw 8 dup(0) b ends code segment start: mov ax,a mov ds,ax mov bx,0 mov cx,8 s1: push ds:[bx] add bx,2 loop s1 mov ax,b 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
截图: