My code is:
Mov ah,02
Mov cl,0A
Mov dh,30
Mov dl,dh
Int 21
Mov dl,20
Int 21
Add dh,01
Loop 0106
Mov ah,02
Mov cl,09
Mov bl,31
Mov dl,0A
Int 21
Mov dl,0D
Int 21
Mov dl,bl
Int 21
Add bl,01
Loop 0106
CodePudding user response:
Contrary to what your title says about using TASM, the screenshot and the code correspond to DOS DEBUG.EXE. See this info about writing a TASM program.
Let's start by commenting the code (something that you should have done before posting!):
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
The 1st loop
- When your program starts, you should not rely on pre-existing register content. Don't assume that the
CX
register is 0. You need to initialize the loop counter withmov cx, 0A
(10 decimal). Theloop
instruction depends onCX
, not justCL
. - The screenshot does not have any spaces between the digits on the first row. You should remove the lines that interject a space character
Mov dl,20
Int 21
.
The 2nd loop
- Here it is fine to initialize the loop counter with
mov cl, 09
(9 decimal) because the previousloop
instruction will have left theCX
register at 0. - Because this is a separate loop, the
loop
instruction has to go to another destination.
The program
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