I'm afraid there's no way to distinguish between A + A and A * 2 in expression, am I right? The way I see it can be achieved is by `match`ing, but I would like to avoid this for obvious performance reasons. The easiest way would, of course, be using always A + A form, but I'd like to keep macros as 'achieve what you're trying to'.
Thanks for the idea! Interestings, but pretty complex. What's more important, I was afraid of matching for nothing. Only one additional match (and one if were enough): If you know that expr scale 2 = 0 & expr scale 1 = 2 for expression Scale * Index + Base + Displacement (which I compute earlier), only match a*b, addr is enough to solve this case
Joined: 16 Jun 2003
Location: Kraków, Poland
I'd think that you'd need to recognize just a few "special" expressions, since only then one could really expect to get a strictly defined result. That is: you could expect the address to be written exactly as "base+index*scale+displacement" or "index*scale+displacement" and only then enforce the strictly corresponding encoding (this is a bit similar to how the AT&T syntax in GAS handles it), while for any other free-form expression a good fail-safe would be to evaluate it algebraically and then optimize the instruction output just like fasm 1 does it.
If you like your match a*b, addr solution, then you could additionally check if "a" is a register. If we agree that only "eax*2" should be treated specially and variants "(eax+0)*2" should be evaluated and optimized, you'd need to detect if something is exactly a token corresponding to register. I have at least one trick that can do it:
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