flat assembler
Message board for the users of flat assembler.

Index > Windows > IF in Tasm to FASM

Author
Thread Post new topic Reply to topic
LAS3R



Joined: 17 Oct 2003
Posts: 6
LAS3R
Really love FASM but one thing really miss that is:

xor eax,eax
mov ax, word ptr [wmsg]
.IF ax==WM_DESTROY
jmp _wmdestroy
.ELSEIF ax==WM_CLOSE
jmp _wmdestroy
.ELSEIF ax==WM_COMMAND
jmp _wmcommand
.ELSEIF ax==WM_INITDIALOG
jmp _initdlg
.ENDIF
xor eax,eax
ret

This piece of code works in tasm but not in fasm and i haven't found any opposite to it in fasm, beacuse this code below does not do same thing 100%

xor eax,eax
;mov ax, word ptr [wmsg]
cmp [wmsg],WM_DESTROY
je _wmdestroy
cmp [wmsg],WM_CLOSE
je _wmdestroy
cmp [wmsg],WM_COMMAND
je _wmcommand
cmp [wmsg],WM_INITDIALOG
je _initdlg
;.ENDIF
xor eax,eax
ret

in tasm the first code does it if u put letter or anything in text box that is connected to piece of code as first then it jumps directly but this code that is second here don't jmp until i connected it to a button or similar!

any idea how to get same result in fasm as tasm?
Post 21 Feb 2004, 10:59
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Did you check Privalov's "if" and other style macros? They come with the Fasmw package:
Code:
; macroinstructions for HLL-style conditional operations

macro .if v1,c,v2
{
  __IF equ
  local ..endif
  __ENDIF equ ..endif
  local ..else
  __ELSE equ ..else
  if v2 eq & c eq
   cmp v1,0
   je __ELSE
  else
   cmp v1,v2
   jn#c __ELSE
  end if
}

macro .else
{
  jmp __ENDIF
  __ELSE:
  restore __IF
  __IF equ ,
}

macro .elseif v1,c,v2
{
  local ..else
  jmp __ENDIF
  __ELSE:
  restore __ELSE
  __ELSE equ ..else
  if v2 eq & c eq
   cmp v1,0
   je __ELSE
  else
   cmp v1,v2
   jn#c __ELSE
  end if
}

macro .endif
{
  if __IF eq
   __ELSE:
  end if
  __ENDIF:
  restore __ELSE
  restore __ENDIF
  restore __IF
}

macro .while v1,c,v2
{
  local ..while
  __WHILE equ ..while
  local ..endw
  __ENDW equ ..endw
  __WHILE:
  if v2 eq & c eq
   cmp v1,0
   je __ENDW
  else
   cmp v1,v2
   jn#c __ENDW
  end if
}

macro .endw
{
  jmp __WHILE
  __ENDW:
  restore __ENDW
  restore __WHILE
}

macro .repeat
{
  local ..repeat
  __REPEAT equ ..repeat
  __REPEAT:
}

macro .until v1,c,v2
{
  if v2 eq & c eq
   cmp v1,0
   je __REPEAT
  else
   cmp v1,v2
   jn#c __REPEAT
  end if
  restore __REPEAT
}

jnne equ je
jnna equ ja
jnnb equ jb
jnng equ jg
jnnl equ jl
jnnae equ jae
jnnbe equ jbe
jnnge equ jge
jnnle equ jle
    

_________________
Code it... That's all...
Post 21 Feb 2004, 11:22
View user's profile Send private message Visit poster's website Reply with quote
LAS3R



Joined: 17 Oct 2003
Posts: 6
LAS3R
Ah thank you!

*Some while later*

Hmm can't get it work, compiles correct but program won't run correct, just loop forever and i have to kill it with taskmanager!

can u give example how to convert that exempel i gave in first post?

*5Min later*

Found solution for problem, taken from tasm, if can't get macro work like u want then use this trick!

proc DialogProc,hwndDlg,uMsg,wParam,lParam
enter
push ebx esi edi
mov ax,word [uMsg] ; convert to word from dword!
cmp ax,WM_COMMAND ;Compare if ax is WM_COMMAND
jne IfClose ; No? then jump to next check
jmp WMCommand ;Yes? then jump to WMCommand
IfClose:
cmp ax,WM_CLOSE
jne IfInitDialog
jmp WMClose
IfInitDialog:
cmp ax,WM_INITDIALOG
jne IfDestroy
jmp WMInitdialog
IfDestroy:
cmp ax,WM_DESTROY
jne IfFinish
jmp WMClose
IfFinish:
xor eax,eax
jmp Finish

This solution will make change appear instant , instead of using button or similar "trigger" function to get result, this trick is useful when u got textbox and want text in it be processed soon as user enter something in textbox!
Post 21 Feb 2004, 11:50
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Code:
cmp ax,WM_COMMAND
    


Code:
Masm syntax:
.if ax==WM_COMMAND
Fasm syntax: 
.if ax,e,WM_COMMAND
    

_________________
Code it... That's all...
Post 23 Feb 2004, 10:52
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.