Question:

How to add 21 and 31 in assembly language?

by  |  earlier

0 LIKES UnLike

iam using masm32 assembler and windows operating system. when iam trying to add 21 and 31 the result is ascii charcter not the desired result 52 could any one help?

 Tags:

   Report

5 ANSWERS


  1. mvi a 21

    mvi b 31

    add b

    hlt


  2. My answer here was pretty clear:

    http://answers.yahoo.com/question/index;...

    Try making the procedure in C or C++ without using any pre-made functions from the standard C/C++ libraries.  Then look at the code with a disassembler.  (Microsoft's C/C++ IDE had a built-in disassembler, or you can download one.)

    If you can't create the algorithm in C/C++, then you're not ready for Assembly Language yet, or you haven't learned enough about AL programming to make the program that you want.

    Nobody ever taught me how to make a 'number to ASCII string' algorithm - I figured it out myself.  So, you should be able to do it, if not in Assembly Language, then in a high-level language.

  3. 21 can be represented by 10101  (16+8+1) and 31 buy 11111 (16+8+4+2+1)

    If you now add in binary you get

    (remember 1+1=10

       10101

       11111

        -------

    110100  

    that is equal to 32 + 16 + 4 = 52

            

  4. It depends on what assembler/masim etc

    Look at this site

    http://jntuimplab.blogspot.com/2007/12/a...

  5. in assembler, the number 52 is an ascii char "4".  it all depends how you use it.  how are you displaying the result?

Question Stats

Latest activity: earlier.
This question has 5 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.