RE: Simple C++/Asembler question

How are you printing?

The old way of printing was to move 9 to AH, or was it AL,.. god I don't' 
remember. But it was an int 21

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Celia Rodriguez
Sent: Thursday, March 31, 2011 2:17 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Simple C++/Asembler question

Hi Everyone,

Is there someone who can help me on this little simple problem?
I am sure that my main problem is that I do  not understand how the
registers and storage areas work.
The following is a simple console program.  It adds two numbers entered  by
the user. and displays the answer.  My problem is when the anser is > then 9
I have tried adding the two numbers to eax  and displaying from eax, and
moving the numbers to ah, al and adding the two numbers,  all I display is
garbage. 
I hate to bother you with this such a small problem,  but I really do not
understand why I cannot display what is in register eax.
I will greatly appreciate anyone's help on this.

Thank you,
Celia

// reads the first digit then clears the buffer
loop10:
        lea ecx,b;
        call putstr;
        call getch;
        cmp eax,'0';
        je loop10
        sub eax, '0';
        mov x, eax;

        call getch;
        

        // reads the second digit
        
        lea ecx,b;   
        call putstr;
        call getch;
        sub eax,'0';
        mov y, eax;



        mov ebx,x;
        mov ecx,y;
        
        
add eax,ebx;
add eax,ecx;
        
// this part does work when adding two  numbers < 10
        add ecx,ebx;

//cmp eax , '10';

add eax,'0';


add ecx,'0';

        call putch;             

                



        }0;//return 0;   
}




__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: