"Assembly Language" - Reading Notes - Experiment 4 [bx] and the use of loop

"Assembly Language" - Reading Notes - Experiment 4 [bx] and the use of loop

  1. Programming, 0:200~0:23Fsequentially transfer data to memory 0~63(3FH).
  2. Programming, 0:200~0:23Ftransfer data to the memory sequentially 0~63(3FH), only 9 instructions can be used in the program, and the 9 instructions include mov ax, 4c00handint 21h
assume cs:code
code segment
	mov ax, 20h			;配合bx正好得到 20h*16 + 0 =0200h
	mov ds, ax			;设置(ds)=0
	mov bx, 0			
	
	mov cx, 64			;设置循环次数(0时结束,所以要多给一次)
 s: mov [bx], bx		;0 送到 200 遍历63次,每次bx+1
	inc bx				;偏移地址向前移动
	loop s				;检测循环条件,符合就循环,否则向下继续
	
	mov ax, 4c00h		
	int 21h
code ends
end

insert image description here

  1. The function of the following program is to mov ax,4c0hcopy the previous instruction to the memory 0:200 处and complete the program. Debug on the machine and track the running results.
assume cs:code
code segment
	mov ax, cs			;配合bx正好得到 20h*16 + 0 =0200h
	mov ds, ax			;设置(ds)=0
	mov ax, 0020h
	mov es, ax
	mov bx, 0
	mov cx, cx			;设置循环次数(0时结束,所以要多给一次)
 s: mov al, [bx]		;
	mov es:[bx], al
	inc bx				;偏移地址向前移动
	loop s				;检测循环条件,符合就循环,否则向下继续
	mov ax, 4c00h		
	int 21h
code ends
end

insert image description here

But I don't know what is the end CC21 ???

Summarize

bx + loop can achieve the effect similar to for loop

		mov bx, 0			; i = 0
		mov cx, 8			; len = 8
	s:	push [bx]		
		inc bx				; i++
		loop s				; i < len 循环

Inc self-increment is equivalent to i++
dec self-decrementi--

Guess you like

Origin blog.csdn.net/jx520/article/details/130865327