flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > delayed references |
Author |
|
afw2004 27 Sep 2006, 08:16
Thanks, I guess.
macro m1 { dd some_counter_complete } macro m2 { ... some_counter = some_counter + 1 ... } macro m3 { some_counter_complete = some_counter } |
|||
27 Sep 2006, 08:16 |
|
Tomasz Grysztar 27 Sep 2006, 08:37
Section 2.2.1 of manual contains an example of this, BTW.
|
|||
27 Sep 2006, 08:37 |
|
vid 27 Sep 2006, 09:48
it's easy:
- numeric constants that are defined only once in source can be forward-referenced, their value is same in entire source - numeric constants that are defined more than once in source cannot be forward referenced. so this trick works nice: Code: dd final_value value = 1 value = value + 1 value = value + 1 final_value = value |
|||
27 Sep 2006, 09:48 |
|
afw2004 27 Sep 2006, 11:21
Thanks
|
|||
27 Sep 2006, 11:21 |
|
afw2004 27 Sep 2006, 15:30
And one more question.
Suppose i have a counter variable: macro m1 { counter = counter + 1 } Can I generate variables named as some_name#counter (some_name1, some_name2 ...) if counter variable has integer type? |
|||
27 Sep 2006, 15:30 |
|
LocoDelAssembly 27 Sep 2006, 15:46
|
|||
27 Sep 2006, 15:46 |
|
afw2004 29 Sep 2006, 07:07
I trying to define symbols such as page1_has_fixup, page2_has_fixup and so on.
Code: repeat module_page_count_complete dw 0 dw % match curpage,% \{ page\#curpage\#_has_fixup = 0 \} end repeat And later I retrieve this symbols: Code: fixup_page = offset_from_fsection shr module_shift match curpage, fixup_page \{ if page\#curpage\#_has_fixup = 0 page\#curpage\#_has_fixup = 1 page\#curpage\#_fixup_offset = start_fixup - fixup_records end if \} But the line "if page\#curpage\#_has_fixup = 0" generates error "Undefined symbol". What is wrong? |
|||
29 Sep 2006, 07:07 |
|
Tomasz Grysztar 29 Sep 2006, 07:44
afw2004 wrote:
You are mixing the preprocessor code with an assembler code in a way that suggests you think of them at happening at the same time. The preprocessing is a separate process and is done before the actual assembly happens - it also has a different kind of syntax to make it distinguishable, the assembly constructs are block ended with "end" directive, while preprocessor constructs are the block enclosed within braces (also, in general, assembler uses more textual operators, while preprocessor uses a bunch of "cryptic" characters for its additional operations). I recommend reading the Understanding fasm article first (even though it may still be unfinished), otherwise you'll get constantly confused with how the things work (or don't work) if you make a false assumptions about what should be happening. You must remember you are dealing with two separate layers and languages here. |
|||
29 Sep 2006, 07:44 |
|
afw2004 29 Sep 2006, 08:13
I trying to develop macroses for building VxD files in FASM, but I have not experience with FASM macro processing, so I can't resolve few errors.
The one problem remaining is a building fixup page table table. If somebody also wants to build VxD drivers, but don't want to use Microsoft DDK, please help me to finish the job.
|
|||||||||||||||||||||
29 Sep 2006, 08:13 |
|
afw2004 29 Sep 2006, 10:54
Code: repeat module_page_count_complete dw 0 dw % match curpage,% \{ display 'Init page ', curpage+30h, 0dh, 0ah page\#curpage\#_has_fixup = 'no' display 'Init page ', page\#curpage\#_has_fixup, 0dh, 0ah; <-- error \} end repeat Line "page\#curpage\#_has_fixup = 'no'" defines some symbol. But line "display 'Init page ', page\#curpage\#_has_fixup, 0dh, 0ah" generates error. How can I view the value of symbol defined in previus line? |
|||
29 Sep 2006, 10:54 |
|
LocoDelAssembly 29 Sep 2006, 13:16
afw2004, the "match" gets executed before "%" exists as a number ("repeat" is not in action here). The example I posted is just to use with integers generated by REPT (which is handled by the preprocessor). If you can't generate the number at preprocessor time in any way then forget it but try to make counters using equates (and the REPT trick) or use another approach to get what you want.
remember, preprocessor directives doesn't handle assembly time values (like "%" on "repeat") Regards PS: display 'Init page ', page\#curpage\#_has_fixup, 0dh, 0ah; <-- error . Possibly because at assembly time it gets interpreted as Code: display 'Init page ', page%_has_fixup, 0dh, 0ah; <-- error [edit] Well Actually the error is a value out of range anyway looks what happens here Code: module_page_count_complete = 3 repeat module_page_count_complete dw 0 dw % page%_has_fixup = 'n' match curpage,% { display 'Init page ', curpage+30h, 0dh, 0ah page#curpage#_has_fixup = page#curpage#_has_fixup + 1 display 'Init page ', page#curpage#_has_fixup, 0dh, 0ah; <-- error } end repeat You will see that clearly "%" has no effect and is always a plain "%" on the three iterations.[/edit] |
|||
29 Sep 2006, 13:16 |
|
afw2004 29 Sep 2006, 14:16
Thanks, locodelassembly
|
|||
29 Sep 2006, 14:16 |
|
afw2004 29 Sep 2006, 14:33
repeat module_page_count_complete
dw 0 dw % curpage = % page#curpage#_has_fixup = 'no' end repeat Is this code correct? If curpage = 1 (integer, not string), then what is page#curpage#_has_fixup ? Is it page1_has_fixup or something else? Is there some way to define symbols such as page1_has_fixup, page2_has_fixup ... page#module_page_count_complete#_has_fixup if module_page_count_complete depend on compiled file size? |
|||
29 Sep 2006, 14:33 |
|
LocoDelAssembly 29 Sep 2006, 16:23
afw2004, the "#" works only AT PREPROCESSOR TIME and the "=" at assembler time, you defenitivelty can't use the "%" to generate a symbol you must use the REPT trick that Tomasz point me out the past year. I don't know if there is another way but you can't generate new symbols at assembler time for sure.
|
|||
29 Sep 2006, 16:23 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.