flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Small bug in "allow_nesting macro", but easy fix.

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 14 Oct 2007, 23:10
I found a minor bug in the allow_nesting macro. When recompiling my opengl examples, fasmw kept giving me an illegal parameter error, even though the parameter count was correct. So with a little snooping around in the fasmw macro files, I found the error. In the allow_nesting macro there is a line that simply has the word 'err' on it, commenting out this line solves the problem. It seems to only happen when using the invoke macro's double keyword to pass double floats to a function.

See code below to see where to fix this, goto where the invoke and stdcall macro are defined:
Code:
macro allow_nesting
{ macro pushd value
  \{ match ,value \\{
      pushx equ \\}
     match =pushx =invoke proc,pushx value \\{
      allow_nesting
      invoke proc
      purge pushd,invoke,stdcall,cinvoke,ccall
      push eax
      pushx equ \\}
     match =pushx =stdcall proc,pushx value \\{
      allow_nesting
      stdcall proc
      purge pushd,invoke,stdcall,cinvoke,ccall
      push eax
      pushx equ \\}
     match =pushx =cinvoke proc,pushx value \\{
      allow_nesting
      cinvoke proc
      purge pushd,invoke,stdcall,cinvoke,ccall
      push eax
      pushx equ \\}
     match =pushx =ccall proc,pushx value \\{
      allow_nesting
      ccall proc
      purge pushd,invoke,stdcall,cinvoke,ccall
      push eax
      pushx equ \\}
     match =pushx,pushx \\{
      pushd <value>
      pushx equ \\}
     restore pushx \}
  macro invoke proc,[arg]
  \{ \common count@stdcall = 0
             if ~ arg eq
     \forward count@stdcall = count@stdcall+1
              match =double value, arg \\{ count@stdcall = count@stdcall+1 \\}
     \common end if
             if defined proc \# %
              if count@stdcall <> proc \# %
               display "Error: invalid count of parameters for ",\`proc,".",0Dh,0Ah
               err ; <- [***COMMENT THIS LINE OUT***]
              end if
             end if
     \reverse pushd <arg>
     \common call [proc] \}
  macro stdcall proc,[arg]
  \{ \common count@stdcall = 0
             if ~ arg eq
     \forward count@stdcall = count@stdcall+1
              match =double value, arg \\{ count@stdcall = count@stdcall+1 \\}
     \common end if
             if defined proc \# %
              if count@stdcall <> proc \# %
               display "Error: invalid count of parameters for ",\`proc,".",0Dh,0Ah
               err ; <- [***COMMENT THIS LINE OUT***]
              end if
             end if
     \reverse pushd <arg>
     \common call proc \}
  macro cinvoke proc,[arg]
  \{ \common \local size
             size = 0
             if ~ arg eq
     \reverse pushd <arg>
              size = size+4
              match =double any,arg \\{ size = size+4 \\}
     \common end if
             call [proc]
             if size
             add esp,size
             end if \}
  macro ccall proc,[arg]
  \{ \common \local size
             size = 0
             if ~ arg eq
     \reverse pushd <arg>
              size = size+4
              match =double any,arg \\{ size = size+4 \\}
     \common end if
             call proc
             if size
             add esp,size
             end if \} }
    
Post 14 Oct 2007, 23:10
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.