flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > Using source line numbers |
Author |
|
Tomasz Grysztar 01 Mar 2004, 22:43
OK, here's quick guide how you can quickly add support for the %L symbol that gives you the number of currently processed source line.
First, you need to modify the PARSER.INC file, so the parser will be able to recognize the %L symbol. Find the "get_predefined_id" label (somewhere around line 826), somewhere below it you can find those two lines: Code: cmp al,'t' je get_timestamp_id just after them you can add check for any additional "%+letter" symbols you want to use, in this case: Code: cmp al,'l' je get_linenumber_id The "get_timestamp_id" routine is defined somewhere above, you can add the "get_linenumber_id" just after it, and it should look like: Code: get_linenumber_id: mov eax,3 ret where 3 is the identifier of %L symbol which will appear in the parsed source. Now you have to modify also EXPRESSI.INC file to allow the assembler to recognize this new type of symbol and get the right value for it during the calculations. Find the "predefined_label" routine (around line 999), it looks like: Code: predefined_label: or eax,eax jz current_offset_label cmp eax,1 je counter_label cmp eax,2 je timestamp_label of course you have to add there something like: Code: cmp eax,3 je linenumber_label The "timestamp_label" routine is just above, after it you can add the routine that gets the number of current line: Code: linenumber_label: mov eax,[current_line] mov eax,[eax+4] jmp make_dword_label_value And that's all - now you can use %L symbol to get the line number. Please note that in case of line inside the macro, it has the bit 31 set, and the lower bits contain the number of line in the macro, not in the file. To get number of source line that invoked the macro or number of line in macro definition, you would have to make some more modifications. |
|||
01 Mar 2004, 22:43 |
|
Posetf 02 Mar 2004, 00:20
WOW!
Coded, working, thanks! |
|||
02 Mar 2004, 00:20 |
|
Posetf 02 Mar 2004, 00:36
Forgot to ask:
Yeah/nay on this being in 1.52? (nay is ok, just would like to know) |
|||
02 Mar 2004, 00:36 |
|
comrade 02 Mar 2004, 01:14
Certainly "yay" on my part
|
|||
02 Mar 2004, 01:14 |
|
Posetf 02 Mar 2004, 01:49
comrade wrote: Certainly "yay" on my part Although it wouldn't be any practical use to me at the moment, I'm compelled to suggest %s for the current source file as a possible addition as well. |
|||
02 Mar 2004, 01:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.