Can someone tell me how many possibities of the .while instruction there is on masm ?

I mean, .while can be written as

.while (data)

.while eax!

.while data1>0

.wile data1<0


All of hem generate coding as jne instructions

Adress1: cmp data1,0
jne Adress02
jmp Adress1

The point is what is the code for a e instruction ? Like:

Adress1: cmp data1,0
je Adress02
jmp Adress1

There is a .while data <>0 ????


Posted on 2002-07-15 13:26:14 by Beyond2000!
I bet your while loop wouldn't exit.
[color=#3366FF]while(myvar != 0)

//...some sloppy, slow code here

test eax, eax
jz __exit_while

;...some sloppy, slow code here

jmp __while
The first thing that a While-Loop is going to do is compare if the argument is TRUE, if it is, it will exit the loop, else continue with the instruction then jump back.

I don't think there would be any more variations of While-Loop since if you deviate from the concept, it wouldn't be a While-Loop in the first place. ;)


correct me if I'm wrong since I don't use HLL loops in MASM but I think .while data <> 0 is just comparing data with the value of 0.
Posted on 2002-07-15 13:53:19 by stryker


Think of it as a looping .if

.while TRUE
;No Exit, because expression never evaluates to false.

Syntax: .WHILE condition


Used for clear coding of common loop blocks. Generates code so
that, while <condition> is true, the processor loops through the
following block of statements.

The .ENDW statement marks the end of the <statements> block,
causing the processor to return to the .WHILE directive to
reevaluate whether <condition> is still true. If <condition> is

initially false, the <statements> will not be executed.

.WHILE blocks can be nested, and the assembler will optimize to get
the best possible code.

Enjoy your work, P1
Posted on 2002-07-15 14:34:20 by Pone
Hi Pone

tks for the explanations.

I assume that an
.if al == data


will also generate

cmp al ==data
jne AdressXX

But what abut the je condition ?

If we have

cmp al == data
je AdressXX

AdressXX : xor ebx, ebx

How the .if condition aplies to it ?

I would like some examples, becasue all checked is that .if generates jne and not je.


Posted on 2002-07-15 16:42:49 by Beyond2000!

The .if example was to illustrate the logical condition after the .while are the same.

I pointed you in this direction, because there are alot of .if's in working pieces of code to learn from.

But when this assembles with different syntax, the conditional jumps form an execution loop for .while ( jumps to leave execution loop, when false ) and a branch for .if ( jumps to branch code and continues with program ).

Enjoy your work, P1
Posted on 2002-07-16 09:05:16 by Pone