flat assembler
Message board for the users of flat assembler.
Index
> Main > Instruction/Command aliases in fasmg |
Author |
|
Tomasz Grysztar 17 Jul 2022, 07:43
In this case you need to define a symbol of "labeled instruction" class, which is done with STRUC directive:
Code: struc (label) DH data& label DB data end struc Code: macro DH data&
DB data
end macro Code: struc (label) DH data& label EMIT 1: data end struc macro DH data& EMIT 1: data end macro BTW, in fasm 1 EQU could not alias preprocessor's directives or macros in very much the same way - and fasmg has a unified language, meaning every directive is like a preprocessor's directive of fasm. |
|||
17 Jul 2022, 07:43 |
|
ScriptTiger 17 Jul 2022, 08:55
Brilliant! I never even thought of using struc, but it totally makes sense in retrospect. Thank you so much!
What about alias word size/casting? For example, I also have something like the following in fasm: HCX equ rcx HAX equ rax HWORD equ qword mov HWORD[HCX],HAX Substituting HCX and HAX both work as regular (equ)ates, but HWORD gets thrown as an invalid expression. I realize I was probably abusing equ a bit from the start as kind of a universal "replace all". So, hopefully I'll do things properly this time with fasmg. |
|||
17 Jul 2022, 08:55 |
|
Tomasz Grysztar 17 Jul 2022, 09:19
ScriptTiger wrote: Substituting HCX and HAX both work as regular (equ)ates, but HWORD gets thrown as an invalid expression. Code: include 'cpu/x64.inc' HCX equ rcx HAX equ rax HWORD equ qword use64 mov HWORD[HCX],HAX |
|||
17 Jul 2022, 09:19 |
|
ScriptTiger 17 Jul 2022, 09:56
My apologies, I think I probably gave you a bad example. The exact error is as follows:
invoke HeapFree,\ [os.Prchp],\ 0,\ HWORD[HCX] macro invoke? [1] macro fastcall? [72] mov? [3] x86.parse_operand@src [32] (CALM) Error: invalid expression. Using the mov instruction versus the invoke macro are probably totally different, so sorry about that again. I just tried copying HWORD[HCX] into the HCX register first and then just passing HCX and it works fine. mov HCX,HWORD[HCX] invoke HeapFree,\ [os.Prchp],\ 0,\ HCX I'm not sure if that's just a difference between the way invoke works between fasm and fasmg or maybe I'm just using it wrong. |
|||
17 Jul 2022, 09:56 |
|
Tomasz Grysztar 17 Jul 2022, 10:09
Oh, the "fastcall" macro puts additional proxy variable in there, which hides the EQU replacement. It's a quirk of how the internal implementations of these macros interact, I should correct it.
A quick fix is to take PROC64.INC, and replace all occurrences of "redefine value " with "value reequ ". This makes the EQU replacements processed when the proxy is defined. |
|||
17 Jul 2022, 10:09 |
|
ScriptTiger 17 Jul 2022, 10:24
Thank you again!
I also tried just dropping the cast altogether and it works, too. invoke HeapFree,\ [os.Prchp],\ 0,\ [HCX] I'm assuming the invoke macro already casts it correctly, so there wasn't any need to cast it again on my part. Maybe it was actually a problem with the fasm 1 invoke macro that I felt the need to cast it, I'm not sure. But your quick fix will definitely come in handy on other parts. Thanks again! |
|||
17 Jul 2022, 10:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.