flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How can i define data right? |
Author |
|
JohnFound 09 Jan 2004, 23:14
Well you can't define labels inside <repeat> structure.
The reason for this is that on the stage where repeat is executed (assembling) all labels are already created (in preprocessing/parsing stage), you simply can't create new. The simplest solution, if you want to create repeated static data, is to use macroses instead of structs: Code: ; Note that there are no labels. macro MyStruc fld1, fld2, fld3 { dd fld1 db fld2 db fld3 } repeat 10000 MyStruc 3424, 32, 27 end repeat BTW: IMHO in 99.9% of the cases, creating of this kind of data is not very good style of programming. Better create not initialized data and then fill it on run-time. Regards |
|||
09 Jan 2004, 23:14 |
|
terex 10 Jan 2004, 01:10
Thanks, but i have allready suspected for this way too
JohnFound wrote: Well you can't define labels inside <repeat> structure. It's exactly that 1 percent! I write a simple code for get understanding of pmode interrupts handle. I define selectors for code, data & stack segments so that base = address of place where dos loads my .com app, and size = 64k. I do it spesial for cansel need for calculate addresses of interrupts handlers on run-time. Ofcause, in a real code it is not very good. _________________ sorry for my english |
|||
10 Jan 2004, 01:10 |
|
vid 11 Jan 2004, 11:07
privalov: couldn't you slightly modify 'struc' so it can be used without label preceding it? strutures defined with 'struc' should beheave in my opinion like all other data defines. You can use 'db 5' and 'name db 5' both, but you cant define data with structure without preceding it with label.
Nice workaround for structures without preceding name is just to append all symbol starting with dot to some dummy (local) label. |
|||
11 Jan 2004, 11:07 |
|
terex 11 Jan 2004, 14:54
vid, it's really good idea. Privalov, isn't it?
_________________ sorry for my english |
|||
11 Jan 2004, 14:54 |
|
JohnFound 11 Jan 2004, 15:32
terex wrote: vid, it's really good idea. Privalov, isn't it? Well I am not Privalov, but IMHO it is not good idea. Every structure have local labels inside. These labels needs parent label. If you define structure without main label, the local labels inside will be attached to the last global label, that is not very correct. Regards. |
|||
11 Jan 2004, 15:32 |
|
Tommy 11 Jan 2004, 15:36
I agree with John! If you need to define data without parent label, use macros instead!
|
|||
11 Jan 2004, 15:36 |
|
vid 11 Jan 2004, 16:25
john, tommy: i think i explained it badly. I meant, that 'struc' when used withuot label should set current global label to some dummy (local) name, and reset it on the end of struc. Defining both macro and struc for one structure is not very good method.
|
|||
11 Jan 2004, 16:25 |
|
terex 11 Jan 2004, 16:29
Hehe I push 'new post' button to write that it may be easy to attach child labels of structures defined without labels to nothing. But later i thinked that i this way we have no prefers defing data as structures without labels. So, we can use macros with no decrase of comfortable. Like Tommy said.
_________________ sorry for my english |
|||
11 Jan 2004, 16:29 |
|
Tomasz Grysztar 12 Jan 2004, 19:00
The idea behind the current mechanism is that you can define both struc and macro of the same name, with whatever contents (and even syntax) you want in both cases, for example:
Code: struc RECT left,top,right,bottom { .left dd left+0 .top dd top+0 .right dd right+0 .bottom dd bottom+0 } macro RECT left,top,right,bottom { .left dd left .top dd top .right dd right .bottom dd bottom } First one to use with label, second without it (and in second case its defined the way that forces you to initialize it with some values - just as an example). Changing it would hurt the whole logic of current fasm's macro system and even make some of the current macro solutions not working (when it started to treat unlabelled RECT at a struc instead of a macro, for instance). |
|||
12 Jan 2004, 19:00 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.