flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Problem with restore

Author
Thread Post new topic Reply to topic
Hapkidoyoka



Joined: 03 Mar 2008
Posts: 13
Hapkidoyoka
Hi everyone,

If I have a macro that sets an equ like...
Code:
 fred equ [esp+8]     
How can I later restore/undefine it with another macro?

Code:
 restore fred     
Seems to be replaced itself with
Code:
 restore [esp+8]     

Is it possible to restore/reset after such a definition? Can anyone shed some light on this for me?
Post 28 Jun 2010, 22:39
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
use32
fred equ [esp+8]

mov eax, fred
restore fred
mov edx, fred ; undefined symbol 'fred'.    
As you can see, "fred" is undefined after the restore. Could you provide some fragment of your code to see more clearly what's you problem?
Post 28 Jun 2010, 22:53
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Hapkidoyoka,

Probably you've used fred equ something several times, you need proper number of restore fred.

Preprocessor directives and macro invocations together with their arguments are protected from equates expansion (unless noted, e.g. match directive expands them in matched sequence).
Post 29 Jun 2010, 08:50
View user's profile Send private message Reply with quote
Hapkidoyoka



Joined: 03 Mar 2008
Posts: 13
Hapkidoyoka
LocoDelAssembly and baldr,

Thanks for your replies, and I apologise for my late response (work and life interfering with hobbies again Confused).

In my frustration I posted an poorly stated question, and broke one of my rules: Never code when I'm really tired. Maybe that rule should apply to posting questions too Wink.

You were both correct, and I believe this problem solved.

I thought I'd make a proper submission of the relevant code ripped out of my project.

This raised a different problem, which strangely doesn't affect my full project. In submacro.i:
Code:
  if defined SubName#@Args    
Raises an error, but works in my project.

I don't think I can easily replicate the environment of my project (~400KB of source), but you guys know your stuff, eh?

So, if you could look at this and me give any lessons, they will be gratefully received.

With respect,
Hapkidoyoka

EDIT: I'm an idiot... I missed commas on the SubCall lines in testsub.s

They should be:
Code:
SubCall SubbyOne  ,1,2
SubCall SubbyTwo  ,3,4    
It works fine. It seems I don't need to be tired to make simple mistakes!

Still, should any fasm experts take the time to look at these macros, I'd appreciate any tips.

Thanks again,
Hapkidoyoka


Description:
Download
Filename: sub (fixed).zip
Filesize: 2.01 KB
Downloaded: 41 Time(s)

Post 04 Jul 2010, 15:33
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.