Since a simple for-loop counting to zero using an integer should compile on any reasonable compiler to something like
mov thingy, count
start-of-loop:
whatever code you want
dec thingy
jnz start-of-loop
where "thingy" is either a global variable in ds or a local variable in ss (doesn't matter which, they're both equally efficient to access), it's hard to think how you can make something substantially more efficient than this.
The only obvious improvement is to keep the loop counter in a register, but your compiler will probably have done this for you already if it is more efficient. It might not be, if the loss of a register for other purposes causes problems. I gather some compilers even have the sense to convert a count-up loop to a count-down loop if the loop variable isn't used elsewhere.
As I see there is something about an ArrayList. It is a .NET class. For that reason, the best way to iterate in my opinion is using of the API provided by that class.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.