flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > Array of String->String: Unsetable

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 613
Code:
macro tmp {
  local type
  macro ucall fun, [arg] \{
    common
    local n
    if defined type#fun
      type#fun arg
    else
      push edi
      n=0
      reverse
      pushd arg
      n=n+4
      common
      lea edi, [esp+n]
      call fun
      mov esp, edi
      pop edi
    end if
  \}
  macro setcall fun, t \{
    type#fun equ t
  \}
}
tmp
purge tmp

setcall fun1, cdecl
use32
ucall fun1, 1
fun1:    

I mean to have fun using the calling type when set, and if not, just use the common way. However, the code made a 15-byte bin file, meaning that setcall was ignored.
Post 06 Aug 2016, 15:32
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6902
Location: Kraków, Poland
Your "if defined type#fun" line becomes "if defined cdecl" (because "equ" defines symbolic variable that is replaced text-for-text by the preprocessor), and "defined" only checks for existence of a label / numeric variable, it does not check for the existence of a macro.
Post 06 Aug 2016, 16:24
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 613
Tomasz Grysztar wrote:
Your "if defined type#fun" line becomes "if defined cdecl" (because "equ" defines symbolic variable that is replaced text-for-text by the preprocessor), and "defined" only checks for existence of a label / numeric variable, it does not check for the existence of a macro.
Solved.
Code:
    match =type#fun, type#fun \\{
      r equ 0
    \\}
    if ~defined r    
works.
Post 06 Aug 2016, 16:59
View user's profile Send private message 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-2018, Tomasz Grysztar.

Powered by rwasa.