0

I have to print number greater than 9 in Assembly and I've managed to write this code, but for me it prints "_ _" as an answer. What is wrong?

xor ax,ax
mov al,bl
mov bl,0Ah
div bl

mov bl,ah
add bl,48

mov ah,2h
mov dh,offset bl
int 21h

mov bl,al
add bl,48   

mov ah,2h
mov dh,offset bl
int 21h
  • 4
    A place to start would be the docs for [int 21](http://spike.scu.edu.au/~barry/interrupts.html#ah02). The character to print goes into a register you aren't using. Also, what do you think `mov dh,offset bl` is supposed to do? – David Wohlferd Sep 27 '17 at 07:59
  • 2
    you don't print numbers, you print ascii-characters (that's why you add 48 before printing, you know?). for numbers > 9, you need to convert it into a string, and print this instead. Google will help you to find one of the hundreds of ready made solutions for this – Tommylee2k Sep 27 '17 at 08:09
  • So I should do mov ah,9h? I am new to assembly so I can think not properly, but in my opinion, mov dh, offset bl and int 21h should output string. Sorry for my little knowledge... – Deividas Bražėnas Sep 27 '17 at 10:08
  • 2
    `bl` is 8 bit register, it has no memory address, thus it can't have any offset. So you misunderstood what `offset` directive does. Makes me even wonder why the TASM would compile it without error. `mov dh,bl` will copy value from `bl` into `dh`. ... Check the link from David for the `int 21h` service**s** (!) description, and proper arguments, with `ah=2` the content of `dh` is not important. – Ped7g Sep 27 '17 at 12:21
  • Thank you @Ped7g, I'll try that when I come back home – Deividas Bražėnas Sep 27 '17 at 14:04

0 Answers0