机器码为E2F2,其中E2表示LOOP指令;F2表示跳转位移量,即其跳转位移量为(F2)h=242;
指令执行到loop s1时,指令寄存器IP=001B,001B+00F2=010D,再将高位舍弃使得IP=000D;
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
运行测试截图