0

I am doing an assembly lab for my school and its on printing signed and unsigned numbers. It keeps printing an infinite amount of "-/" but it should be printing a number. Is the offset for number to ascii value 30h?

 Display .EQU 04E9h NumAddr .EQU 0050h Main: mov BX, NumAddr mov DX, Display mainLoop: MOV AH,[BX] cmp AH, 0h ; is number 0? JE EndPrt ; if yes we are done CMP AH,0h JG posNum ; should jump to posNum if AH is positive negNum: mov AL, 2Dh out DX,AL ; print a negative sign NEG AH ; turn AH into a positive number printPos: MOV AL,[BX] ADD AL, 30h ; should add required offset to convert to ASCII out DX,AL MOV AL, 0Dh out DX,AL MOV AL, 0Ah out DX,AL inc BX jmp mainLoop EndPrt: HLT .END Main 
0

1 Answer 1

0

30h is offset of single digit. Ie. (4 + 30h) is 34h, and in ASCII encoding that is '4'. But for (17 + 30h) you will get 41h, which is character 'A'.

If you want two characters for value 17, like 31h '1' and 37h '7', you must split the number into separate base10 (decimal) digits (dividing it by 10 and collecting remainders).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.