News:

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

safe way to use .if

Started by ecube, May 21, 2008, 01:20:50 AM

Previous topic - Next topic

jj2007

Quote from: PBrennick on June 02, 2008, 09:55:32 AM
Is it okay to add this to the GeneSys macro set?
Paul
I feel honoured, Paul - please go ahead. It's just a pity that Masm would not accept a .sif...

PBrennick

Thanks and thanks. About MS: It will happen

    .if They_ever_get_around_to_it  == 1

or

   sif They_ever_get_around_to_it  == -1


Paul
The GeneSys Project is available from:
The Repository or My crappy website

jj2007

Here is another option: .if signed eax<0

include \masm32\include\masm32rt.inc

signed equ sdword ptr

.data
IsLower   db "Operand is < 0", 0
IsHigher   db "Operand is > 0", 0

.code

;read-only data before start
AppName     db "Test app:", 0
MyVar   dd 0

start:   call TestWin
   invoke ExitProcess, 0

TestWin proc

  mov eax, -123
  .if signed eax<0
   invoke MessageBox, NULL, addr IsLower, addr AppName, MB_OK
  .else
   invoke MessageBox, NULL, addr IsHigher, addr AppName, MB_OK
  .endif

  mov eax, 123
  .if signed eax<0
   invoke MessageBox, NULL, addr IsLower, addr AppName, MB_OK
  .else
   invoke MessageBox, NULL, addr IsHigher, addr AppName, MB_OK
  .endif

  ret
TestWin endp
end start