flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 20 Feb 2008, 07:42
Code: macro IfNotDef_Set labl,value { local here if ~defined labl | defined here labl = value here = 1 end if } IfNotDef_Set SizeOfKernel, 10000 |
|||
![]() |
|
qeos 20 Feb 2008, 07:58
It does not approach (
|
|||
![]() |
|
DOS386 20 Feb 2008, 23:01
.
> I try compile this: > if ~defined > compiler say me: > error: code cannot be generated. RTFM ... FASM.TXT , 2.2.6 , line 2590 ![]() Anyway, wouldn't it be nice to have #if defined at preprocess level, working like in C ? _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
![]() |
|
vid 21 Feb 2008, 02:21
yup... we do have match, but that is at least a bit tricky to use. But i am not very sure if it would be "implementable" to current FASM.
|
|||
![]() |
|
AlexP 02 Mar 2008, 21:17
I use "if ~defined" in my code alot, it works just fine. What I think (don't wanna make a whole thread), is that the FASM pre-processor should check operands (constants) of certain instructions. for example, FASM actually allowed me to compile "shl eax,55". This is not alllowed to execute, yet FASM let it compile. Just like dividing by zero...
|
|||
![]() |
|
vid 02 Mar 2008, 23:46
Alex: you are mixing things. Preprocessor has nothing to do with instruction operands.
And FASM simply translates from human language to machine code, if instruction is encodeable in current mode, it is fine for FASM to allow it. By the way, did you check that "shl eax, 55" causes exception? AFAIK shift value is truncated, and shift by contant larger than register is one of tricks to detect processor. |
|||
![]() |
|
AlexP 03 Mar 2008, 00:04
hmm, I've debugged in Olly a program where I used a shift by more than 60, and Olly had a comment by it saying "value out of range", or something of the sorts. Maybe I'm wrong, but I thought that it doesn't execute when you try.
Yeah, I generalize when I think of pre-processor. |
|||
![]() |
|
revolution 03 Mar 2008, 00:46
shl reg,55 is a valid instruction so fasm should assemble it. Internally the CPU masks all shift and rotate counts to 5bits in 32bit modes and 6bit in 64bit modes. So shl reg,55 is the same as shl reg,23
|
|||
![]() |
|
bitRAKE 03 Mar 2008, 04:07
Some people hide data in extra bits of instructions - immediate shifts is one case of this. Selective encoding can also be a signature of code generation.
As to the thread topic, I found myself trying to do the same thing - even though I knew better - until I wrote these macros. Code: macro IFDEF nm,val { match =val,nm { } FEDFI fix } macro IFNDEF nm { match =nm,nm { } FEDNFI fix } Code: IFNDEF DEBUG
DEBUG equ int3
FEDNFI;DEBUG Another possible problem exists if DEBUG is defined as a macro. match can't do anything with a macro definition - only works with symbols/constants. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.