flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macroinstruction to replace instruction? |
Author |
|
bitRAKE 23 Jul 2009, 01:35
I've posted part of solution here:
http://board.flatassembler.net/topic.php?p=98098#98098 Code: macro pop [reg] { local ..reg ; assume reg is okay ..reg equ reg ; update only if reg is R32 R64FromR32 ..reg,reg ; do the POP pop ..reg } |
|||
23 Jul 2009, 01:35 |
|
Azu 23 Jul 2009, 02:02
bitRAKE wrote: I've posted part of solution here: Thank you I run into the same problem though.. it says the push in it is illegal "push ..reg Error: illegal instruction." |
|||
23 Jul 2009, 02:02 |
|
bitRAKE 23 Jul 2009, 02:13
Bah, I tested it and it works fine.
You show me yours because I already showed you mine. |
|||
23 Jul 2009, 02:13 |
|
Azu 23 Jul 2009, 02:17
I meant with yours, it is giving the same error I got with mine which I posted in the first post in this topic.
The changes I made to yours are only semantic see for yourself. Code: e64 equ 1 if defined e64 macro R64FromR32 [r64,r32] { match A:=r32==B:C,::eax=rax:edx=rdx:ecx=rcx:ebx=rbx:ebp=rbp:esi=rsi:edi=rdi:esp=rsp:r8d=r8:r9d=r9:r10d=r10:r11d=r11:r12d=r12:r13d=r13:r14d=r14:r15d=r15:: \{ r64 equ B \} } macro pop [reg] { local ..reg ..reg equ reg ; assume reg is okay R64FromR32 ..reg,reg ; update only if reg is R32 pop ..reg ; do the POP } macro push [reg] { local ..reg ..reg equ reg ; assume reg is okay R64FromR32 ..reg,reg ; update only if reg is R32 push ..reg ; do the PUSH } end if push eax pop eax |
|||
23 Jul 2009, 02:17 |
|
bitRAKE 23 Jul 2009, 02:26
First, the IF is done by the assembler - after the pre-processor is finished. I.E. the MACROs are defined no matter what "e64" is. Second, I'm guessing you have another PUSH macro somewhere because the exact same code works here. (You aren't really showing all the code.) You could further debug with the .FAS output to be sure.
See section 2.3.7 Order of Processing in the FASM manual. |
|||
23 Jul 2009, 02:26 |
|
Azu 23 Jul 2009, 03:13
No other macro, nothing. That's all I have in the file. It doesn't compile. I tried removing the IF, and it still fails to compile with the same error I mentioned above. I took out all of my code to make sure it's a problem with the macro and not something else..
Code: macro R64FromR32 [r64,r32] { match A:=r32==B:C,::eax=rax:edx=rdx:ecx=rcx:ebx=rbx:ebp=rbp:esi=rsi:edi=rdi:esp=rsp:r8d=r8:r9d=r9:r10d=r10:r11d=r11:r12d=r12:r13d=r13:r14d=r14:r15d=r15:: \{ r64 equ B \} } macro pop [reg] { local ..reg ..reg equ reg ; assume reg is okay R64FromR32 ..reg,reg ; update only if reg is R32 pop ..reg ; do the POP } macro push [reg] { local ..reg ..reg equ reg ; assume reg is okay R64FromR32 ..reg,reg ; update only if reg is R32 push ..reg ; do the PUSH } push eax pop eax Edit: I think I found the problem. In the little example I forgot to put use64. Very strange that it ran for you I'm not sure why it isn't working in my program though. It fails with my invoke macro Code: macro invo func,[args]{ reverse push args common call func } Last edited by Azu on 23 Jul 2009, 03:30; edited 1 time in total |
|||
23 Jul 2009, 03:13 |
|
bitRAKE 23 Jul 2009, 03:28
Of course you'll need a USE64 - FASM defaults to 16-bit instructions.
|
|||
23 Jul 2009, 03:28 |
|
Azu 23 Jul 2009, 03:31
Whoops I was editing my post right when you replied
Could you respond to my edited post please ^^ |
|||
23 Jul 2009, 03:31 |
|
bitRAKE 23 Jul 2009, 03:48
How are you using "invo" MACRO?
What kind of error are you getting? What diagnostic measures have you taken to resolve the error? (Go ahead and post these questions after your posts to save me some time.) |
|||
23 Jul 2009, 03:48 |
|
Azu 23 Jul 2009, 07:06
bitRAKE wrote: How are you using "invo" MACRO? invo function,arg1,arg2,arg3 etc.. bitRAKE wrote: What kind of error are you getting? Error: illegal instruction." bitRAKE wrote: What diagnostic measures have you taken to resolve the error? Oh and also since I can't use the if statement for toggling this off and on, what should I use? |
|||
23 Jul 2009, 07:06 |
|
bitRAKE 23 Jul 2009, 13:46
Yet, you are still unwilling to post the complete code, or a smaller version demonstrating the same effects.
The PREPSRC tool that comes with FASM can show you exactly what is happening with the macros. Use the -S switch to output .FAS file and then use PREPSRC on the .FAS data. Toggling will require a pre-processor directive (obviously) - MATCH seems the easiest, but others can work. (An example exists in the manual, iirc.) |
|||
23 Jul 2009, 13:46 |
|
Azu 23 Jul 2009, 18:39
Thanks. All is well now.
|
|||
23 Jul 2009, 18:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.