一、实验目的
二、实验结论
1. 实验任务1
- 给出程序task1.asm源码,及,运行截图
assume cs:code, ds:data data segment x db 1, 9, 3 len1 equ $ - x y dw 1, 9, 3 len2 equ $ - y data ends code segment start: mov ax, data mov ds, ax mov si, offset x mov cx, len1 mov ah, 2 s1:mov dl, [si] or dl, 30h int 21h mov dl, ' ' int 21h inc si loop s1 mov ah, 2 mov dl, 0ah int 21h mov si, offset y mov cx, len2/2 mov ah, 2 s2:mov dx, [si] or dl, 30h int 21h mov dl, ' ' int 21h add si, 2 loop s2 mov ah, 4ch int 21h code ends end start - 回答问题①
① line27, 汇编指令 loop s1 跳转时,是根据位移量跳转的。通过debug反汇编,查看其机器码,分析其跳转的位移量是多少?(位移量数值以十进制数值回答)从CPU的角度,说明是如何计算得到跳转后标号s1其后指令的偏移地址的。
位移量为001B-000D为14,由loop指令结束的位置001B减s1位置得出 - 回答问题②
② line44,汇编指令 loop s2 跳转时,是根据位移量跳转的。通过debug反汇编,查看其机器码,分析其跳转的位移量是多少?(位移量数值以十进制数值回答)从CPU的角度,说明是如何计算得到跳转后标号s2其后指令的偏移地址的。
位移量为0039-0029为16,由loop指令结束的位置0039减s2位置得出 - 问题③
③ 附上上述分析时,在debug中进行调试观察的反汇编截图![]()
![]()
2. 实验任务2
- 给出程序task2.asm源码
assume cs:code, ds:data data segment dw 200h, 0h, 230h, 0h data ends stack segment db 16 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov word ptr ds:[0], offset s1 mov word ptr ds:[2], offset s2 mov ds:[4], cs mov ax, stack mov ss, ax mov sp, 16 call word ptr ds:[0] s1: pop ax call dword ptr ds:[2] s2: pop bx pop cx mov ah, 4ch int 21h code ends end start- 给出分析、调试、验证后,寄存器(ax) = ? (bx) = ? (cx) = ? 附上调试结果界面截图。
① 根据call指令的跳转原理,先从理论上分析,程序执行到退出(line31)之前,寄存器(ax) = ? 寄存器(bx) = ? 寄存器(cx) = ?
② 对源程序进行汇编、链接,得到可执行程序task2.exe。使用debug调试,观察、验证调试结果与理论分析结果是否一致。
ax最后一次赋值是在25行的pop ax处,此时栈顶的值为s1的地址,则ax值为25行的地址
bx最后一次赋值是在28行的pop ax处,此时栈顶的值为s2的地址,则bx值为28行的地址
cx最后一次赋值是在29行的pop cx处,此时栈内为空,继续pop的话会提出data段中最后一个值,该值为cs的值即为code段的短地址
结果上,寄存器(ax) =0021 寄存器(bx) = 0026 寄存器(cx) = 076C
与s1位置、s2位置与cs值一致
- 给出分析、调试、验证后,寄存器(ax) = ? (bx) = ? (cx) = ? 附上调试结果界面截图。
3. 实验任务3
- 给出程序源码task3.asm
assume cs:code, ds:data data segment x db 99, 72, 85, 63, 89, 97, 55 len equ $- x data ends code segment start: mov ax, data mov ds, ax mov si, offset x mov cx, len s:mov al, [si] mov ah, 0 mov bl, 10 div bl or ah, 30h or al, 30h mov bh, ah mov bl, al call s1 call s2 inc si loop s mov ah, 4ch int 21h s1: mov ah, 2 mov dl, bl int 21h mov dl, bh int 21h ret s2: mov ah, 2 mov dl, ' ' int 21h ret code ends end start - 运行测试截图
![]()
4. 实验任务4
- 给出程序源码task4.asm
assume cs:code, ds:data
data segment
str db 'try'
len equ $ - str
data endscode segment
start:
mov ax, data
mov ds, ax
mov ax, 0b800h
mov es, ax
mov si, offset strmov bh, 0
mov bl, 160
mov al, bh
mul bl
mov di, axmov bl, 2
mov cx, lens:call s1
inc si
loop smov si, offset str
mov bh, 24
mov bl, 160
mov al, bh
mul bl
mov di, axmov bl, 4
mov cx, lens2:call s1
inc si
loop s2mov ah, 4ch
int 21hs1:mov al, [si]
mov es:[di], al
inc di
mov es:[di], bl
inc di
retcode ends
end start - 运行测试截图
![]()
5. 实验任务5
- 给出程序源码task5.asm
assume cs:code, ds:data data segment stu_no db '----------------------------------201983290423----------------------------------' len = $ - stu_no data ends code segment start: mov ax, data mov ds, ax mov ax, 0b800h mov es, ax mov si, offset stu_no mov ah, 00010111B mov cx, 0f00h mov al, ' ' mov di, 0 s2:call s1 loop s2 mov di, 0f00h mov cx, len s:mov al, [si] call s1 inc si loop s mov ah, 4ch int 21h s1:mov es:[di], al inc di mov es:[di], ah inc di ret code ends end start - 运行测试截图
![]()





浙公网安备 33010602011771号