0

I have this code below that I created.

.model small
.stack 100h
.data
     var1 DB 1
.code
        main proc
            MOV ax,data
            MOV ds,ax
            
            MOV cx, 10
           
            top:
                MOV dl, var1
                ADD dl, 48
                
                MOV ah, 02h
                INT 21h   
                
                INC var1
            
            LOOP top
    
        endp
        end main

This displays a result of

123456789:

What I want to display is

12345678910

How can I display 10 rather than :

Spadeee
  • 1
  • 2
  • 1
    Since 10 is a two digit number, you will need to display two digits. You can't just blindly add `48` as that only works for single digits. You could do the asm equivalent of `if (dl >= 10) { putchar('1'); dl -= 10; }; putchar(dl + 48);` and that should work for numbers up to 19. If you want arbitrary two (or more) digits then you need to write a generic number to text conversion. Plenty of examples for that on SO. – Jester Nov 20 '20 at 12:58
  • You could use a loop to display `1..9` and special-case the 2-digit number `10`. – Peter Cordes Nov 20 '20 at 20:13

0 Answers0