flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Problem using dup to define an array of structures |
Author |
|
LocoDelAssembly 30 Jan 2006, 14:32
You can do:
Code: molecular ATOM rb 127 * sizeof.ATOM But maybe there is a more elegant solution [edit]This apparently works: Code: include 'win32ax.inc' macro struct name { struc name#.dup count\{ . name rb sizeof.#name * (count - 1) \} struct name } struct ATOM proton dd ? electron dd ? neutron dd ? ends atom ATOM ; correct molecular ATOM.dup 128 ; correct now string db 128 dup (?) ; correct |
|||
30 Jan 2006, 14:32 |
|
chris 05 Feb 2006, 08:46
I defined the following struc macro which works outside the struct macro. I am still trying to integrate it into struct macro but it seems rather complicated. Anyone has a better idea?
Code: struc ATOM2 Param { if 1 match num dup (?),Param \{ rept num count \\{ struc MakeItem \\\{ \.proton dd ? \.electron dd ? \.neutron dd ? \\\} .@\\#count MakeItem \\} else \} .proton dd ? .electron dd ? .neutron dd ? end if } atom ATOM2 molecular ATOM2 5 dup (?) include 'macro\struct.inc' struct MOLECULAR quantity dd ? atoms ATOM2 5 dup (?) ends foo MOLECULAR Actually, this definition of ATOM2 works within the struct macro, but there is a problem, that is after preprocess, above code(only the definition of foo) becomes: Code: label foo ;match,{foo.number dd ?} foo.number dd ? ;match any,{foo.number dd ; if~foo.number eq foo ; rb sizeof.MOLECULAR.number-($-foo.number) ; end if} ;match,{foo.atoms.@1.proton dd ?} foo.atoms.@1.proton dd ? ;match any,{foo.atoms.@1.proton dd ; if~foo.atoms.@1.proton eq foo ; rb sizeof.MOLECULAR.atoms.@1.proton-($-foo.atoms.@1.proton) ; end if} ;match,{foo.atoms.@1.electron dd ?} foo.atoms.@1.electron dd ? ;match any,{foo.atoms.@1.electron dd ; if~foo.atoms.@1.electron eq foo ; rb sizeof.MOLECULAR.atoms.@1.electron-($-foo.atoms.@1.electron) ; end if} ;match,{foo.atoms.@1.neutron dd ?} foo.atoms.@1.neutron dd ? ;match any,{foo.atoms.@1.neutron dd ; if~foo.atoms.@1.neutron eq foo ; rb sizeof.MOLECULAR.atoms.@1.neutron-($-foo.atoms.@1.neutron) ; end if} ;match,{foo.atoms.@2.proton dd ?} foo.atoms.@2.proton dd ? ;match any,{foo.atoms.@2.proton dd ; if~foo.atoms.@2.proton eq foo ; rb sizeof.MOLECULAR.atoms.@2.proton-($-foo.atoms.@2.proton) ; end if} ;match,{foo.atoms.@2.electron dd ?} foo.atoms.@2.electron dd ? ;match any,{foo.atoms.@2.electron dd ; if~foo.atoms.@2.electron eq foo ; rb sizeof.MOLECULAR.atoms.@2.electron-($-foo.atoms.@2.electron) ; end if} ;match,{foo.atoms.@2.neutron dd ?} foo.atoms.@2.neutron dd ? ;match any,{foo.atoms.@2.neutron dd ; if~foo.atoms.@2.neutron eq foo ; rb sizeof.MOLECULAR.atoms.@2.neutron-($-foo.atoms.@2.neutron) ; end if} ;match,{foo.atoms.@3.proton dd ?} foo.atoms.@3.proton dd ? ;match any,{foo.atoms.@3.proton dd ; if~foo.atoms.@3.proton eq foo ; rb sizeof.MOLECULAR.atoms.@3.proton-($-foo.atoms.@3.proton) ; end if} ;match,{foo.atoms.@3.electron dd ?} foo.atoms.@3.electron dd ? ;match any,{foo.atoms.@3.electron dd ; if~foo.atoms.@3.electron eq foo ; rb sizeof.MOLECULAR.atoms.@3.electron-($-foo.atoms.@3.electron) ; end if} ;match,{foo.atoms.@3.neutron dd ?} foo.atoms.@3.neutron dd ? ;match any,{foo.atoms.@3.neutron dd ; if~foo.atoms.@3.neutron eq foo ; rb sizeof.MOLECULAR.atoms.@3.neutron-($-foo.atoms.@3.neutron) ; end if} ;match,{foo.atoms.@4.proton dd ?} foo.atoms.@4.proton dd ? ;match any,{foo.atoms.@4.proton dd ; if~foo.atoms.@4.proton eq foo ; rb sizeof.MOLECULAR.atoms.@4.proton-($-foo.atoms.@4.proton) ; end if} ;match,{foo.atoms.@4.electron dd ?} foo.atoms.@4.electron dd ? ;match any,{foo.atoms.@4.electron dd ; if~foo.atoms.@4.electron eq foo ; rb sizeof.MOLECULAR.atoms.@4.electron-($-foo.atoms.@4.electron) ; end if} ;match,{foo.atoms.@4.neutron dd ?} foo.atoms.@4.neutron dd ? ;match any,{foo.atoms.@4.neutron dd ; if~foo.atoms.@4.neutron eq foo ; rb sizeof.MOLECULAR.atoms.@4.neutron-($-foo.atoms.@4.neutron) ; end if} ;match,{foo.atoms.@5.proton dd ?} foo.atoms.@5.proton dd ? ;match any,{foo.atoms.@5.proton dd ; if~foo.atoms.@5.proton eq foo ; rb sizeof.MOLECULAR.atoms.@5.proton-($-foo.atoms.@5.proton) ; end if} ;match,{foo.atoms.@5.electron dd ?} foo.atoms.@5.electron dd ? ;match any,{foo.atoms.@5.electron dd ; if~foo.atoms.@5.electron eq foo ; rb sizeof.MOLECULAR.atoms.@5.electron-($-foo.atoms.@5.electron) ; end if} ;match,{foo.atoms.@5.neutron dd ?} foo.atoms.@5.neutron dd ? ;match any,{foo.atoms.@5.neutron dd ; if~foo.atoms.@5.neutron eq foo ; rb sizeof.MOLECULAR.atoms.@5.neutron-($-foo.atoms.@5.neutron) ; end if} ;--------------------- not expected below -------------------------------- ;match,{foo.atoms.proton dd ?} foo.atoms.proton dd ? ;match any,{foo.atoms.proton dd ; if~foo.atoms.proton eq foo ; rb sizeof.MOLECULAR.atoms.proton-($-foo.atoms.proton) ; end if} ;match,{foo.atoms.electron dd ?} foo.atoms.electron dd ? ;match any,{foo.atoms.electron dd ; if~foo.atoms.electron eq foo ; rb sizeof.MOLECULAR.atoms.electron-($-foo.atoms.electron) ; end if} ;match,{foo.atoms.neutron dd ?} foo.atoms.neutron dd ? ;match any,{foo.atoms.neutron dd ; if~foo.atoms.neutron eq foo ; rb sizeof.MOLECULAR.atoms.neutron-($-foo.atoms.neutron) ; end if} that is, one more set of ATOM2 members are generated. |
|||
05 Feb 2006, 08:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.