EASy68K  
It is currently Sun Jul 22, 2018 8:11 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: C array of struct
PostPosted: Mon May 07, 2018 5:45 pm 
Offline

Joined: Mon May 07, 2018 5:28 pm
Posts: 1
Hi! I am searching how to create an array of simple structures

C code:
Code:
typedef struct t{
   char a;
   int b;
} test;

test x[10];

I don't know where to start, i read the help manual and i think that OFFSET directive can help me but i don't understand how it works

Thank you in advance


Top
 Profile  
 
 Post subject: Re: C array of struct
PostPosted: Tue May 08, 2018 11:17 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1072
Here is an example:

Code:
*-----------------------------------------------------------
* Program Number:
* Written by    :
* Date Created  :
* Description   : Creating C style structs.
*
*-----------------------------------------------------------
   ORG   $1000
START:            ; first instruction of program

    offset 0
* Structure 1
test_name   ds.l    1
test_data   ds.l    1
test_foo    ds.l    1
test_bar    ds.l    1
test_struct
    org *

* code may be here
    nop
    nop
    nop

* use the structures with address registers
    lea     struct1,a1
    lea     struct2,a2
   
    move.l  #$1111,(test_name,a1)   ; store some stuff
    move.l  #$2222,(test_data,a1)
    move.l  #$3333,(test_foo,a1)
   
* use the structures directly
    move.l  #$1234,struct2+test_bar

    SIMHALT

* create some structure variables
struct1 ds.b    test_struct
struct2 ds.b    test_struct

   END   START      ; last line of source

_________________
Prof. Kelly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group