Menu

#406 Structures with local fields

open-wont-fix
nobody
Assembler (85)
1
2008-09-29
2008-09-29
Anonymous
No

; This doesn't work... It might be that I'm doing it wrong, but the documentation doesn't specify how to do this...

struc foo
.bar: resb 1
endstruc

foobar:
istruc foo
at .bar, db 00h
iend

Discussion

  • nasm64developer

    nasm64developer - 2008-09-29

    As shown in your example, the structure
    definition defines foo.bar whereas the
    structure instantiation then references
    foobar.bar, which (of course) fails.

    Write "at foo.bar, db 00h" instead.

    The first sentence of the last paragraph
    in section 4.11.9 of the manual describes
    this, though it could do a better job.

     
  • nasm64developer

    nasm64developer - 2008-09-29
    • priority: 5 --> 1
    • status: open --> open-wont-fix
     
  • H. Peter Anvin

    H. Peter Anvin - 2008-10-02

    It's not clear to me that this shouldn't be fixed. It's a pretty serious violation of user expectation, one would think.

    The tricky part is that it's not very clear *how* to fix it -- in particular, what is the user expectation of expressions on the right-hand side?

     
  • Nobody/Anonymous

    If the standard 'at' macro is changed to something like the following then the structure name is optional.

    %imacro at 1-2+.nolist

    ; Find the first character of the member label...
    %defstr %$memberstring %1
    %substr %$char %$memberstring 1

    ; ...if it is a dot, then prepend the structure name.
    %ifidn %$char,'.'
    %xdefine %$member_label %[%$strucname]%1
    %else
    %define %$member_label %1
    %endif

    times (%$member_label-%$strucname)-($-%$strucstart) db 0
    %2
    %endmacro

    - Anonymous Coward

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.