程序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其后指令的偏移地址的。
机器码为E2F2,其中E2表示LOOP指令;F2表示跳转位移量,即其跳转位移量为(F2)h=242;
指令执行到loop s1时,指令寄存器IP=001B,001B+00F2=010D,再将高位舍弃使得IP=000D;
回答问题② ② line44,汇编指令 loop s2 跳转时,是根据位移量跳转的。通过debug反汇编,查看其机 器码,分析其跳转的位移量是多少?(位移量数值以十进制数值回答)从CPU的角度,说明 是如何计算得到跳转后标号s2其后指令的偏移地址的。 机器码为E2F0,其中E2表示LOOP指令;F0表示跳转位移量,即其跳转位移量为(F0)h=240; 指令执行到loop s2时,指令寄存器IP=0039,001B+00F0=0129,再将高位舍弃使得IP=0029; 问题③ ③ 附上上述分析时,在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) = ? 附上调试结果界面截图。 ax)=0021,(bx)=0026,(cx)=076C;
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 byte ptr ds:[len],10
mov bx,0
mov cx,7
s: mov al,ds:[bx]
mov ah,0
inc bx
call printNumber
call printSpace
loop s
mov ax,4c00h
int 21h
printNumber:
div byte ptr ds:[len]
mov dx,ax
mov ah,2
or dl,30h
int 21h
mov ah,2
mov dl,dh
or dl,30h
int 21h
ret
printSpace:
mov dl,' '
mov ah,2
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 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 bl,00000010B
mov bh,0
mov cx,3
mov si,0
call printStr
mov bl,00000100B
mov bh,24
mov cx,3
mov si,0
call printStr
mov ax,4c00h
int 21h
printStr:
mov ax,0b800h
mov es,ax
mov ax,0
mov al,bh
mov dx,160
mul dx
mov di,ax
s: mov al,ds:[si]
mov es:[di],al
inc si
inc di
mov es:[di],bl
inc di
loop s
ret
code ends
end start
运行测试截图
5. 实验任务5
程序源码task5.asm:
assume cs:code, ds:data
data segment
stu_no db '201983290135'
len = $ - stu_no
len1 = (80-len)/2
data ends
code segment
start:
mov ax,data
mov ds,ax
mov bl,00010000b
call printColor
mov si,0
mov bl,00010111b
mov bh,24
call printStr
mov ah,4ch
int 21h
printColor:
mov ax,0b800h
mov es,ax
mov ax,0
mov al,25
mov dx,0
mov dx,80
mul dx
mov cx,ax
mov al,' '
mov di,0
s: mov es:[di],al
inc di
mov es:[di],bl
inc di
loop s
ret
printStr:
mov ax,0b800h
mov es,ax
mov ax,0
mov al,bh
mov dx,160
mul dx
mov di,ax
mov al,'-'
mov cx,len1
s1: mov es:[di],al
inc di
mov es:[di],bl
inc di
loop s1
mov cx,len
s2: mov al,ds:[si]
mov es:[di],al
inc si
inc di
mov es:[di],bl
inc di
loop s2
mov al,'-'
mov cx,len1
s3: mov es:[di],al
inc di
mov es:[di],bl
inc di
loop s3
ret
code ends
end start
运行测试截图