flat assembler
Message board for the users of flat assembler.
Index
> Main > Corresponding MASM operators in FASM |
Author |
|
Tomasz Grysztar 17 Feb 2006, 14:18
There's "eqtype" operator for a bit similar purposes, but there's no true correspondence between those two. It's one of the area where fasm takes substantially different approach.
|
|||
17 Feb 2006, 14:18 |
|
MazeGen 06 Mar 2006, 14:04
Really, eqtype seems to be something like opattr, also very powerful . Thanks, I overlooked it at first.
|
|||
06 Mar 2006, 14:04 |
|
vid 06 Mar 2006, 15:49
and again, "something eqtype something" seems more understandable than checking some bitfield...
Here's my partial translation Code: macro load reg*, adr* { if adr eqtype eax ;register ;.. not sure what this is, maybe this? if ~ reg eq adr ;if "reg" isn't same as "adr" mov reg, adr end if else if adr eqtype 0 ;constant mov reg,adr ;not sure again, but if it is for string you can even declare string with ;usage of idata macro, like this: else if adr eqtype "" ;note: checks only string constants, for string local ..string ;like <"abcd",10,13,"efgh"> you need preprocessor solution idata \{ ..string db adr,0\} mov reg, ..string end if ;no idea how to distinguish near and far pointer. if size of offset ;is known, you could check label's size with "virtual" block } could you give examples for each "if" tests? I believe we can find a solution. |
|||
06 Mar 2006, 15:49 |
|
MazeGen 06 Mar 2006, 17:59
Thanks for this translation, we can compare everyone's features this way.
Quote:
IFDIFI reg, adr means "if <reg> different from <adr>, case insensitive" - if you do something like load ax, ax, the macro doesn't assemble anything. Quote:
Well, this condition means "else if object at <adr> is unsigned byte BYTE (in fasm, defined using DB) or signed byte SBYTE (don't know how it is in fasm)". Therefore, the object can be string or any BYTE or SBYTE variable: Code: .DATA some_str BYTE "blabla" some_var SBYTE -12 .CODE load ax, some_str ; the condition is true load bx, some_var ; the condition is true Quote: and again, "something eqtype something" seems more understandable than checking some bitfield... Quote: ;no idea how to distinguish near and far pointer. if size of offset Isn't this a disability of fasm? You have to always define the type somewhere. As for checking some bitfield, you can always code some resource macro, so it may look like "IF IsReg" or "IF IsImm"... |
|||
06 Mar 2006, 17:59 |
|
vid 06 Mar 2006, 18:24
fasm doesn't know about what you are going to use your variables for. That means that there is no difference between these:
Code: db "abc",10,13,0 db 'a','b',c', 10, 13, 0 db 61h, 62h, 63h, 10, 13, 0 and when you have something like "a dd ?", how can compiler know whether you are going to use it as pointer? By size? It is matter of opinion, but i dislike such "guiding" me with my coding. It is job of compiler to define dword and my job to know how am i going to use it. Tomasz & everyone: This is interesting "problem".. how to get size assigned to label? Is it possible? |
|||
06 Mar 2006, 18:24 |
|
MazeGen 06 Mar 2006, 19:07
vid wrote: fasm doesn't know about what you are going to use your variables for. That means that there is no difference between these: The same is in MASM, of course. vid wrote: and when you have something like "a dd ?", how can compiler know whether you are going to use it as pointer? By size? You probably forget the context of that macro - it loads an address into a register(s). At the line ELSEIF (TYPE (adr) EQ BYTE... you already know the second argument in not a register nor a constant and therefore it can be only a (data) label. If it is label used with BYTE or SBYTE (some_str BYTE "blabla"), you have to load the offset of that label (8-bit variable can't contain a pointer), if it is WORD (ELSEIF (SIZE (TYPE (adr)) EQ 2), it is the pointer itself (we load 16-bit address), so in fasm syntax it assembles MOV reg, [adr], if it is DWORD, it is FAR pointer, so it loads segment:offset pointer into DS:reg. vid wrote: It is matter of opinion, but i dislike such "guiding" me with my coding. It is job of compiler to define dword and my job to know how am i going to use it. I thing you're wrong, this load macro is intended to be as general as possible, and it is just a silly example of all features of TYPE and OPATTR in one macro. It is also not bullet-proof, it should test if the label is in data section in case it is not BYTE or SBYTE label, and it also should report an error in case of SWORD and SDWORD types, which shouldn't contain a pointer. |
|||
06 Mar 2006, 19:07 |
|
vid 06 Mar 2006, 20:00
MazeGen wrote:
i thought some of them are BYTEs and some SBYTEs... Compiler can't know if "_empty_string db 0" is numeric variable or string constant, can it? vid wrote: and when you have something like "a dd ?", how can compiler know whether you are going to use it as pointer? By size? You probably forget the context of that macro - it loads an address into a register(s)...[/quote] okay, so it's reduced to problem with getting size assigned to label if i am right |
|||
06 Mar 2006, 20:00 |
|
Tomasz Grysztar 06 Mar 2006, 20:02
vid wrote: Tomasz & everyone: This is interesting "problem".. how to get size assigned to label? Is it possible? In general, no. If you need to distinguish between BYTE/WORD/DWORD/QWORD label, you can do it with LOAD tricks like I did in the TEST optimization macro. This also shows that, though I noticed the problem, I didn't feel it really an excuse to add another special feature. |
|||
06 Mar 2006, 20:02 |
|
Reverend 06 Mar 2006, 21:24
Can't 'label dword ... at' or 'label byte ... at', etc used to define variable size labels at one memory place? Or maybe I misunderstood vid's question.
|
|||
06 Mar 2006, 21:24 |
|
vid 06 Mar 2006, 21:30
Reverend: i was asking, how to find out what size is assigned to already defined label. like this:
Code: macro a arg* { if sizeoflabel(arg) eq byte movzx ax, [arg] else if sizeoflabel(arg) eq word mov ax, [arg] ... etc } |
|||
06 Mar 2006, 21:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.