Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Assembly langauge

Options
  • 25-04-2006 3:53pm
    #1
    Registered Users Posts: 8,438 ✭✭✭


    hey i'm playing around with assembly language here as a complete noob to it. just wondering if anyone could tell me how to count the number of times a loop runs, the program just takes numbers you enter and is supposed to tell you how many after wards. i'm just confused if you use the cx register or should you assign a new variable for it?

    cheers


Comments

  • Closed Accounts Posts: 888 ✭✭✭themole


    it reallt depends on what assembly language you are using and for what chip.

    but the general idea would be to use a register as a counter and this would be incremented each time the loop runs


  • Closed Accounts Posts: 3,285 ✭✭✭Smellyirishman


    xor ax,ax
    mov bx, userVariable
    
    loop:
    inc ax
    dec bx
    jnz loop
    
    end
    

    Something like that, assuming your using x86 stuff. Of course, I am not sure if you take in a sentinal to end the loop or if you take in a single number representing how many times to loop? I think it may be the first , in which case the code is off base, but the loop counting element is consistant.

    Of course, as the above poster said, it all depends on your language , output, etc...


  • Closed Accounts Posts: 102 ✭✭RedXIII


    Just to let u know im a different Red but...i think i know that guy(BigDave?) from my class and were usin 8086 if thats ne help...;)


  • Closed Accounts Posts: 3,285 ✭✭✭Smellyirishman


    The above should work fine then. Output will vary, depending on your medium.


Advertisement