News:

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

what is .if !

Started by ic2, August 04, 2008, 10:54:59 PM

Previous topic - Next topic

jj2007

Quote from: japheth on August 05, 2008, 10:12:47 AM
Didn't know that anything in Masm is implemented "by design".  :U


  mov esi, 4
  .While esi<3
inc esi
  .Endw


...translates to:

  mov esi, 4
  jmp L2

L1: inc esi
L2: cmp esi, 3
jb L1


Show me how to make it shorter and/or more efficient.

japheth

Quote from: jj2007 on August 05, 2008, 10:22:31 AM
  mov esi, 4
  jmp L2

L1: inc esi
L2: cmp esi, 3
jb L1


Show me how to make it shorter and/or more efficient.

Perhaps this way?:

  mov esi, 4
  jmp L2

L1: inc esi
cmp esi, 3
jb L1
L2:


Why do you ask?


jj2007

Quote from: japheth on August 05, 2008, 11:10:57 AM

Perhaps this way?:

  mov esi, 4
  jmp L2

L1: inc esi
cmp esi, 3
jb L1
L2:

Will work perfectly but requires an intelligent compiler knowing in advance that the loop will never be touched :toothy

Quote
Why do you ask?

> Didn't know that anything in Masm is implemented "by design"

Because you expressed doubts on the ability of Masm authors to design their tool. Remember it was invented a long time before the BloatOS era. Those guys still had control over their code.

japheth

> Because you expressed doubts on the ability of Masm authors to design their tool.
> Remember it was invented a long time before the BloatOS era. Those guys still had control over their code.

Yes, but be aware that Masm exists since 1981. It might have been "well-designed" in the beginning, but if you are experienced in software development you will know that quality of a project's software tends to decrease and it might become a mess eventually, virtually unmaintainable.

ic2

Still can't find any kind of listing but ...
operator (!) is a Logical NOT

http://www.google.com/search?q=Logical+NOT&hl=en&btnG=Search

GregL

QuoteStill can't find any kind of listing but ...

Well, I gave you the link, but you said you couldn't load it. Here's what it says:

Microsoft Macro Assembler Reference

operator !

!expression

Logical negation. Used only within .IF, .WHILE, or .REPEAT blocks and evaluated at run time, not at assembly time.


ic2

No.  I was looking for the list that ragdog requested.  I lost the only two links that I did find last night during the heat of my seach before posting.  Nither had what I was looking for (!) so I keep seaching.

I think I see now.  In masm it's represent Logical negation.  In java or C it represent Logical NOT. That's why jj said *NOT is not a NOT*.


QuoteMasm says no, condition not true - so this is not the binary not operator, which would yield -2 aka "condition is true"

Time to test all of above than go find me a new Service Provider

jj2007

Quote from: ic2 on August 05, 2008, 05:39:12 PM
Still can't find any kind of listing but ...
operator (!) is a Logical NOT

Download the Programmer's Guide, go to Chapter 7, and find this:

Expression Operators
The binary relational operators in MASM 6.1 are the same binary operators used in C. These operators generate MASM compare, test, and conditional jump instructions. High-level control instructions include:
Operator Meaning

== Equal
!= Not equal
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
& Bit test
! Logical NOT
&& Logical AND
|| Logical OR


To make it crystal clear: Logical not means "take the first branch if the operand is zero". I prefer the syntax .if operand==0, also because it is easy to overlook a ! in .if !operand