user4143467
user4143467

Reputation:

Using loop in assembly language using DOSBOX

Hello I need to show the output like this

9_8_7_6_5_4_3_2_1_0

But I am having a difficulty to store the "underscore" temporarily and as I notice registers like DH, CH, BH, BL can't be use to output using int int 21H. Here is my code

.model small
.stack
.data
.code

begin:
   mov ah, 2
   mov cx, 10
   mov dl, 39h
   int 21h
back: mov dl, 5fh
   int 21h
   sub dl, 39
   int 21h
   loop back    
   mov ah,4ch
   int 21h
end begin

Upvotes: 1

Views: 2984

Answers (1)

You can use another register to store the counter (9..0), for example, bl :

.model small
.stack
.data
.code

begin:
   mov ah, 2
   mov cx, 10
   mov bl, '9'     ;◄■■ COUNTER 9..0.
back:
   mov dl, bl      ;◄■■ MOVE COUNTER INTO DL.
   int 21h         ;◄■■ DISPLAY COUNTER.
   dec bl          ;◄■■ COUNTER-1.
   mov dl, 5fh     ;◄■■ MOVE UNDERSCORE INTO DL.
   int 21h         ;◄■■ DISPLAY UNDERSCORE.
   loop back    
   mov ah,4ch
   int 21h
end begin

Upvotes: 1

Related Questions