phantom11's blog

By phantom11, 13 years ago, In English

I have just started to learn the 8086 assembly language.The task is to print the sum of 2 16 bit numbers.Here's my code:
org 100h
start:
mov al,5
add al,3
mov dl,al
mov ax,2h
int 21h
end start
But the output is the ascii value of 8.I want to know if there is a way to print the decimal value of 8.If yes then how???

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
13 years ago, # |
Rev. 2   Vote: I like it +11 Vote: I do not like it

You have to convert the number to ascii string yourself, it's assebmler :)

In windows you can try to call "printf" from msvc library

»
13 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Ord('0') = 48

you need to add 48 and 8, then assci value will be 56, and assci character will be '8', to print number with more than 1 digit, you must divide it by 10, until it is not zero.

  • »
    »
    13 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    But then the number will be in reverse order!!
    • »
      »
      »
      13 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      You can use the stack.
    • »
      »
      »
      13 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it
      I think you must to learn programming with one of the languages of high level, then you can try assembler. But now it is to early for you, assembler programming is too complicated for you at this monemt.
      • »
        »
        »
        »
        13 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        I know my rating does not suggest that, but it is not that i am dumb in a high level programming language.I may not be as expert as you are but I know and understand Java.I have just started to learn assembly language 2-3 days ago and so I am very raw at it.Anyways thanks for your efforts:)
»
13 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Hi,
I'm learning assembler in school this year and I find it very interesting. :)

Here is my code for Sum Of Two Numbers problem.

http://pastebin.com/Wuwi9Azd