[英]Loops in Assembly: TASM on 8086 (DosBox) Solve on how to Horizontal and Vertical Number
與你的標題所說的使用 TASM 相反,屏幕截圖和代碼對應於 DOS DEBUG.EXE。 請參閱有關編寫 TASM 程序的信息。
讓我們從注釋代碼開始(您應該在發布之前完成的事情:):
Mov ah,02 ; DOS.PrintCharacter
Mov cl,0A ; Count for the 1st loop
Mov dh,30 ; '0'
0106 is address of top of the 1st loop.
Mov dl,dh
Int 21 ; This prints a digit
Mov dl,20 ; ' '
Int 21 ; This interjects a space character
Add dh,01 ; Next character
Loop 0106 ; Go to top of the 1st loop
Mov ah,02 ; DOS.PrintCharacter
Mov cl,09 ; Count for the 2nd loop
Mov bl,31 ; '1'
01?? is address of top of the 2nd loop.
Mov dl,0A ; Linefeed
Int 21
Mov dl,0D ; Carriage return
Int 21
Mov dl,bl ; Current character
Int 21
Add bl,01 ; Next character
Loop 0106 ; Go to top of the 1st (????????) loop
CX
寄存器為 0。您需要使用mov cx, 0A
(十進制 10)初始化循環計數器。 loop
指令取決於CX
,而不僅僅是CL
。Mov dl,20
Int 21
。mov cl, 09
(十進制 9)初始化循環計數器,因為之前的loop
指令會將CX
寄存器保留為 0。loop
指令必須將 go 發送到另一個目的地。 Mov ah,02 ; DOS.PrintCharacter
Mov cx,0A ; Count for the 1st loop
Mov dl,30 ; '0'
0107 is address of top of the 1st loop.
Int 21 ; This prints a digit
Add dl,01 ; Next character
Loop 0107 ; Go to top of the 1st loop
Mov cl,09 ; Count for the 2nd loop
Mov bl,31 ; '1'
0112 is address of top of the 2nd loop.
Mov dl,0D ; Carriage return
Int 21
Mov dl,0A ; Linefeed
Int 21
Mov dl,bl ; Current character
Int 21
Add bl,01 ; Next character
Loop 0112 ; Go to top of the 2nd loop
int 20 ; DOS.Terminate
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.