flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > __LINE__ and other useful features? |
Author |
|
Tomasz Grysztar 25 Jan 2006, 20:54
http://board.flatassembler.net/topic.php?t=1154
As for the errors, the reason why not add it were already explained in that other thread where you asked about it. |
|||
25 Jan 2006, 20:54 |
|
Borsuc 25 Jan 2006, 21:01
Thanks for the guide.
EDIT: Why not make this official in next Fasm version (%L, etc.)? about 'err', well, would it be hard to recognize 'err' as a 'valid' instruction that just prints the message as an erroneous message? Instead of telling 'Error: illegal instruction', just display the message? sorry if I'm lost in this area.. i didn't quite understand the other reply. EDIT2: how to add %L (or other symbol) display the line that invoked the macro? this is what i really need, in fact. thanks why not add these in fasm? any reason? |
|||
25 Jan 2006, 21:01 |
|
vid 25 Jan 2006, 21:51
there is "display" for that.
If you meant that "err" should also end assembling at same time, it's imposible because of multi-pass assembling, code like this Code: if used x err 'a' end if x: |
|||
25 Jan 2006, 21:51 |
|
Borsuc 25 Jan 2006, 22:03
right now, 'err' stops assembly and says "Error: illegal instruction", or something like that.
but, instead of coding: Code: if ~ used x display 'a' err end if why not do Code: if ~ used x err 'a' end if I know, it can be done via macros, but it will display 'a' as a message, not an error.. and it says 'illegal instruction' because it found 'err'.. i said, wouldn't it be nice to have 'err' do the same as an 'illegal instruction', but replace that message with the specified message? like err 'a' should display the error "Error: a"? okay, this is a minor feature, but it would be nice to have it.. About %L, or whatever, is there any reason why not add it? thanks vid, you cleared that multi-pass thing a bit now |
|||
25 Jan 2006, 22:03 |
|
vid 25 Jan 2006, 22:25
Whoops, i made mistake i meant "if ~ used x". Condition "if ~used x" is false, because symbol x is used later in source, but in first pass it will be predicted as true, so in this case err will stop on code that shouldn't be assembled.
|
|||
25 Jan 2006, 22:25 |
|
Borsuc 25 Jan 2006, 22:28
yeah, I realized that.. that's why I used '~ used'
i get a lot of these errors, too. it happens all the time EDIT: how does 'used' exactly work? I know only 'defined' that checks if variable is accessible from current position, but 'used'? thx |
|||
25 Jan 2006, 22:28 |
|
vid 25 Jan 2006, 22:34
Same as "defined'. During parsing all symbols (non-reserved words) in source are collected into table. Then during assembling if assembler sees any definition of symbol (a:, label a, load a, ... ) then it marks that symbol has been used in this pass. If it see it used (anything but definition) then it marks it has been used.
|
|||
25 Jan 2006, 22:34 |
|
Tomasz Grysztar 26 Jan 2006, 07:37
A samples of various error signalizings:
Code: if ~ defined x err 'a' end if x: this signalizes the error the first time it meets it during assembly - error happens. Code: if ~ defined x rb -1 end if x: this signalizes the error only when even after resolving the rest of code this one fails - thus you'll get the error only when you remove the "x:". Code: if 0 macro+ end if this causes the error during preprocessing. Adding at least three new directives would cause even more confusion for the newcomers. I try now to write some new article for documentation about the fasm's programming layers, to cover many of such problems and questions. |
|||
26 Jan 2006, 07:37 |
|
Borsuc 26 Jan 2006, 18:26
Tomasz: Do you plan to add %L symbol? or %ML (which is the line that 'invoked' the macro).. maybe in next release? it could be very useful.. any reason for not adding it?
Tomasz Grysztar wrote: Adding at least three new directives would cause even more confusion for the newcomers. I don't think it would be that confusing, because these directives can be placed in another section of manual, and newcomers don't need these directives anyway (and these error directives are not really part of standard Fasm syntax, should be pretty easy to read, since they are not used much)... maybe when newcomers get more 'used' to Fasm and start doing some neat macroinstructions |
|||
26 Jan 2006, 18:26 |
|
Tomasz Grysztar 26 Jan 2006, 18:45
With my personal experience with newcomers I'd rather be very careful about it - especially when feature seems to be so easy to use.
|
|||
26 Jan 2006, 18:45 |
|
Tomasz Grysztar 26 Jan 2006, 18:53
As for the %L, I was never convinced it would be actually so useful, when you don't from which file this line came. And file name cannot be handled this way at assembly time, since assembler operates only on numerical values assigned to symbols.
|
|||
26 Jan 2006, 18:53 |
|
Borsuc 26 Jan 2006, 18:57
Tomasz Grysztar wrote: As for the %L, I was never convinced it would be actually so useful, when you don't from which file this line came. And file name cannot be handled this way at assembly time, since assembler operates only on numerical values assigned to symbols. why not add preprocessor default 'symbols' then? like __LINE__ I suggested, and __FILE__. this helps me alot with some 'debug' macros i wrote. |
|||
26 Jan 2006, 18:57 |
|
Tomasz Grysztar 26 Jan 2006, 19:26
Because adding such new class symbols would make another feature interacting with existing ones in a different way, an I'm already tired enough of explaining such interactions in the current already over-grown complexity of various layers in fasm. In initial design such complexity was not planned at all (since I didn't know fasm is going to be so widely used and universal) and therefore this design a bit limits what can be easily done, and what not. As only true solution I was thinking about writing a new assembler from scratch that wouldn't have such limitations, but I'm afraid it would be very much different assembler, and much slower than fasm is.
|
|||
26 Jan 2006, 19:26 |
|
Borsuc 26 Jan 2006, 19:30
if you don't plan on adding __FILE__, it can be done manually in every source:
Code: define __FILE__ somefile.asm but %L or %ML are really needed, it cannot be done easily manually. pls add them btw: didn't know it can be that complex to add some simple symbolic constants automatically (like __FILE__) |
|||
26 Jan 2006, 19:30 |
|
Tomasz Grysztar 26 Jan 2006, 19:38
I just don't like it enough to force myself to implement it. At least at this moment.
|
|||
26 Jan 2006, 19:38 |
|
Borsuc 26 Jan 2006, 19:43
i don't know how i can make my macros display that info and where it occured without %L.. i guess i'll have to figure out anyhow then
|
|||
26 Jan 2006, 19:43 |
|
Tomasz Grysztar 26 Jan 2006, 19:54
Sorry for that tone, I'm just a bit tired today, after many hours of non assembly-related work now trying to put at least few new lines into planned additions to fasm's documentation...
|
|||
26 Jan 2006, 19:54 |
|
Borsuc 26 Jan 2006, 20:01
just read the new documentation yesterday, and it provided a clear explanation of numerical constants, it will definetely help newcomers (most of them look at examples first anyway I did).
keep up the good work |
|||
26 Jan 2006, 20:01 |
|
revolution 27 Jan 2006, 00:44
Quote: I'm just a bit tired today |
|||
27 Jan 2006, 00:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.