1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

loop sum, loop mult, divide

Discussion in 'Assembly Language Programming (ALP) Forum' started by dakobbie03, Sep 23, 2009.

  1. dakobbie03

    dakobbie03 New Member

    Joined:
    Sep 23, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    inside my block _asm i am creating a couple loops and then taking the mult loop and dividing it by the sum. i am new to assembly. the numbers i'm adding up are 1-100 = 5050. The numbers that are multiplied are 1-10 = 3628800. Then multiply the value in Total by -1 and divide by the Sum. this is a start below....need some guidance.

    PHP:
    #include <iostream>

    using namespace std;

    void main ()
        {
        
    long Sum;
        
    long Total;
        
    long Result;
        
    long Remainder;
        
    _asm
            
    {
             
    mov eax0
             mov ecx
    100

    l1
    :
             
    add eaxecx
             mov Sum
    eax
             inc eax
             loop l1

             
    xor eaxeax
             mov ecx
    10
    l2
    :
             
    imul eax
             mov Total
    edx
             inc eax
             loop l2    


             mov eax
    Total
             mov ebx
    Sum
             idiv ebx
             mov Result
    eax
             mov Remainder
    edx
     
    }
        
    cout << "Sum is        " << Sum << endl;
        
    cout << "Total is      " << Total << endl;
         
    cout << "Result is     " << Result << endl;
        
    cout << "Remainder is  " << Remainder << endl;
    }
     

Share This Page