This is the mail archive of the
mailing list for the GCC project.
Re: structures in assembly code
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: mccoards at netscape dot net
- Cc: gcc-help at gcc dot gnu dot org
- Date: 28 Dec 2003 06:15:03 -0500
- Subject: Re: structures in assembly code
- References: <2D44ADB3.328EA458.009F8F08@netscape.net>
Questions about the assembler should not be sent to gcc-help. They
should be sent to firstname.lastname@example.org or email@example.com.
See http://sourceware.org/binutils/. Or just type as --help.
> Im trying to port code from on old BSO 68K assembler to the gcc
> assembler. I have run into a problem converting the structures. In
> BSO you can make as many structures as you want by starting with a
> BSO directive of OFFSET len, and by ending it with SECTION.
> OFFSET 0
> item_start equ *
> item1 DS.B 20
> item2 DS.W 1
> item3 DS.L 2
> item_end equ *
> item_length equ item_end-item_start
> item1 would equate to 0, and item2 would equate to 20 and item3
> would equate to 22. So in a real section you could define a data
> structure and then easily referance the items in the structure
> SECTION .bss
> item DS.B item_length
> SECTION .text
> LEA item,A0
> MOVE.W #5,item2(A0)
> I have looked at the gas manual and have found .offset and .struct,
> but I still cant figure out how (if its even possible) to create
> this type of structure without the assembler or linker
> complainning. Any help would be greatly appreciated.
There is an example of the use of .struct in the gas manual.
Here is how to do your example with gas (I used x86 instructions since
I don't happen to have an m68k assembler built):
.struct item1 + 20
.struct item2 + 2
.struct item3 + 8
item_length = item_end - item_start