flat assembler
Message board for the users of flat assembler.
![]() |
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 |
|||
![]() |
|
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 |
|||
![]() |
|
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. |
|||
![]() |
|
terex 11 Jan 2004, 14:54
vid, it's really good idea. Privalov, isn't it?
![]() _________________ sorry for my english |
|||
![]() |
|
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. |
|||
![]() |
|
Tommy 11 Jan 2004, 15:36
I agree with John! If you need to define data without parent label, use macros instead!
![]() |
|||
![]() |
|
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.
|
|||
![]() |
|
terex 11 Jan 2004, 16:29
Hehe
![]() _________________ sorry for my english |
|||
![]() |
|
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). |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.