第五章 [BX]和LOOP指令
实验四
1,编程,向内存0:200~0:23F依次传送数据0~63(3FH)
assume cs:code
code segment
mov ax,0
mov ds,ax
mov bx,200h
mov dx,0
mov cx,3fh
s: mov ds:[bx],dx
inc dx
inc bx
loop s
mov ax,4c00h
int 21h
code ends
end
2,编程,向内存0:200~0:23F依次传数据0~63(3FH),程序中只能使用9条指令
,9条指令中包括"mov ax,4c00h" 和"int 21h".
assume cs:code
code segment
mov ax,20h
mov ds,ax
mov bl,0
mov cx,64
s: mov ds:[bx],bl
inc bl
loop s
mov ax,4c00h
int 21h
code ends
end
3,下面的程序的功能是将"MOV AX,4C00H"之前的指令复制到内存0:200处,
补全程序。上机调试,跟踪运行结果。
assume cs:code
code segment
mov ax,cs
mov ds,ax
mov ax,0020h
mov es,ax
mov bx,0
mov cx,17h
s:mov al,[bx]
mov es:[bx],al
inc bx
loop s
mov ax,4c00h
int 21h
code ends
end
//CX的初始值是代码总长度,CS-5
D:/masm/src>debug test4.exe
-r
AX=0000 BX=0000 CX=001C DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=0B7D ES=0B7D SS=0B8D CS=0B8D IP=0000 NV UP EI PL NZ NA PO NC
0B8D:0000 8CC8 MOV AX,CS
-g
5个字节为mov ax,4c00h,int 21h的长度,计算此用u查看代码数机器码字节数
0B8D:0017 B8004C MOV AX,4C00
0B8D:001A CD21 INT 21