flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > break macro definition makes fasm g freeze

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 479
Location: Belarus
break macro definition makes fasm g freeze
EFI Byte Code has BREAK instruction.
After I defined

Code:

macro BREAK? operand1*
  emit 10x00operand1
end macro



fasm g (hq7d2) freezez on while loop having break:

Code:

while 1
  match :, arg_disp
    break
  . . .


Post 23 Oct 2017, 21:11
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 479
Location: Belarus
I tried a workaround which P. Batard used in his macros, but it seems that it doesn't work for me

Code:

macro BREAK? operand1
  match , operand1
    break
  else
    emit 10x00operand1
  end match
end macro




I changed while loop as follows:

Code:

local finish
finish = 0
while ~ finish
  match :, arg_disp
  finish = 1
  . . .



and it resolved the issue. But I don't think that it is a good solution as break fasmg directive seems to be unavailable

I must note, that BREAK macro is defined inside a namespace (probably this matters)
Post 23 Oct 2017, 21:19
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6676
Location: Kraków, Poland

zhak wrote:
I must note, that BREAK macro is defined inside a namespace (probably this matters)

Yes, this matters because then in your namespace BREAK becomes a recursive macro. You need to force it into a variable status to disable recursion so that you'd be able to call the original (outer) BREAK from within it.

What causes the freeze is the infinite recursion. Whenever this happens and you need to diagnose where it comes from, you can use the "-r" switch from command line to reduce the maximum allowed depth of macro call stack to get the error message about where the recursion occured.
Post 24 Oct 2017, 08:28
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 479
Location: Belarus
How do I force it into a variable status? I tried a number of variants like defining other macros inside and outside namespaces, like __break__ and calling it - without any success.

The only solution I found by now is:

I define namespace for selected cpu and all instructions are defined in this namespace:


Code:

macro cpu name
  match =ebcname
    @cpu.target = CPU_EBC
    namespace __ebc__
  end match
end macro

------

namespace __ebc__

macro BREAK? operand
  . . .
end macro



something like this, very simplified.

So, if I define BREAK EBC instruction outside any namespaces like

Code:

macro BREAK? operand1
  match , operand1
    if @cpu.target = CPU_EBC
      break
    end if
  else
    emit 10x00operand1
  end match
end macro



then it works. But I don't like this kind of solution Sad
Post 25 Oct 2017, 22:20
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6676
Location: Kraków, Poland

zhak wrote:
How do I force it into a variable status? I tried a number of variants like defining other macros inside and outside namespaces, like __break__ and calling it - without any success.

This was covered in the second part of my "Tricky stuff" series.
Post 26 Oct 2017, 06:46
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 479
Location: Belarus
Thanks a lot!
Post 26 Oct 2017, 07:53
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.