write a loop to print 0 to 99 in decrement order (assembly)
<p>I am new in assembly , I am using <strong>emu8086</strong>
question :
user will input a number between 99 to 0 , let it is 88
i have to print 88 to zero .</p>

<p>to do this , i was trying this technique :</p>

<ol>
<li><p>call <code>AH,1</code> two times for <strong>MSB</strong> and <strong>LSB</strong></p></li>
<li><p>copy <strong>MSB</strong> TO <strong>BH</strong> and <strong>LSB</strong> to <strong>BL</strong></p></li>
<li><p>for each bh </p>

<p>->check if bh is 0</p>

<p>->true,then check bl trough update_it if it is 0</p>

<pre><code>    -&gt;true,then goto exit (because number is 00)

    -&gt;false,then decrement msb and add 9 to lsb ( make 80 to 79 ) 
      and goto loop 2 to print it
</code></pre>

<p>->false then do normal lsb decrement ( 77 to 76 )</p></li>
</ol>

<p>but i always get the wrong output combining many characters , please mention my mistake . thanks in advance .</p>

<p>here is my code</p>

<pre><code>.MODEL SMALL

.STACK 100H  

.DATA 

.CODE 
MAIN PROC

;INITIALIZE DS
MOV AX,@DATA
MOV DS,AX

MOV AH,1         ;SCAN MSB
INT 21H          ;MSB IS NOW AT AH
MOV BH,AL        ;SAVE IT TO BH

                 ;SCAN LSB
MOV AH,1         ;LSB IS NOW AT AL
INT 21H          ;SAVE IT TO BL
MOV BL,AL  

MOV AH,2         ;SINGLE CHAR PRINT
MOV DL,0DH       ;CARRIAGE RETURN
INT 21H          ;AL = 0DH

MOV DL,0AH       ;LINE FEED
INT 21H          ;AL = 0AH

;PRINT THE FIRST NUMBER

MOV DL,BH        ;MSB
INT 21H          ;

MOV DL,BL        ;LSB
INT 21H          ;



LOOP1:

    CMP BL,0       ;LET 70 
                   ;SO UPDATE O TO 9
                   ;AND 7 TO 6
    JE  UPDATE_IT  ;IF TRUE

    JMP LOOP2      ;IF FASLE


LOOP2:


    MOV DL,' '     ;SPACE
    INT 21H

    MOV DL,BH      ;MSB
    INT 21H

    MOV DL,BL      ;LSB
    INT 21H 


    DEC BL         ;DECREMENT LSB


    JMP LOOP1 

UPDATE_IT:

    CMP BH,0       ;BOTH MSB 
                   ;AND LSB ARE ZERO
    JE  EXIT_      ;IF TRUE EXIT = 00


    DEC BH         ;IF FALSE 
                   ;DEC MSB
    ADD BL,9       ;TURN LSB O TO 9
                   ;EXAMPLE 80 TO 79
    JMP LOOP2      ;DO NORMAL DECREMENT

;DOS EXIT                    
EXIT_:             
MOV AH,4CH         ;DOS EXIT FUNCTION
INT 21H            ;EXECUTE

MAIN ENDP

END MAIN
</code></pre>