News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Use MASM32 For Loops

Started by etow, February 18, 2008, 01:21:51 PM

Previous topic - Next topic

etow

Hi

How do I use MASM32 For Loop?

FOR parameter[:REQ|:=default], <argument [,argument]...>
     statements
ENDM

I just don't know what to put the initial value and the stop value

For example,
    For i := 1 to 10
       statements
    end   

Here 1 is the initial value of the for loop and 10 is the stop value in the for loop

Please help thanks


hutch--

Egan,

Use a .WHILE loop and either add or sub the reference value until you get the exit condition.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

etow


Tedd

It's not a 'code' for-loop, it's for macros to repeat things.
.while/.endw does produce looping code though :wink
No snowflake in an avalanche feels responsible.

hutch--

Egan,

Have a look in either the older HLHELP.HLP file or the later CHM version for both .WHILE and .REPEAT loops as they are useful for emulating high level loop code methods. Note that they are off the pace with highly speed critical code but for most high level type constructions they are fine and allow you to test for multiple conditions in a simple and clear way.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

newAsm

Hi,

Give my 2-cents worth to this. If I use .while/.endw

mov  ecx,10

.while ecx > 0                        .repeat

   do something                            do something
   dec  ecx                                   dec  ecx

.endw                                   .until ecx == 0

Hope this helps..newAsm

etow