EASy68K  
It is currently Fri Nov 15, 2019 6:23 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat May 09, 2009 6:43 pm 
Offline

Joined: Fri Dec 19, 2008 1:12 pm
Posts: 37
This is not so much a request, but a sugestion.

It might be a good idea to implement the rs and rsreset directives to help with structures. It would make this:
Code:
;
; Structure
;
test.name   =0
test.data   =4
test.foo    =8
test.bar    =12
test_struct =16

become this:
Code:
;
; Structure
;
            rsreset 0
test.name   rs.l    1
test.data   rs.l    1
test.foo    rs.l    1
test.bar    rs.l    1
test_struct rs.l    1

Much easier to add/remove/rearrange fields. It also allowes a structure to inherit existing structures, which can help with object orientation:
Code:
;
; Structure1
;
            rsreset 0
test.name   rs.l    1
test.data   rs.l    1
test.foo    rs.l    1
test.bar    rs.l    1
test_struct rs.l    1

;
; Structure2
;
            rsreset test_struct
blah.abc    rs.l    1
blah.xyz    rs.l    1
blah.123    rs.l    1
blah_struct rs.l    1


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 27, 2009 4:22 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1103
I believe the OFFSET directive will do what you want:

Code:
   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

    offset  test_struct
* Structure 2
blah_abc    ds.l    1
blah_xyz    ds.l    1
blah_123    ds.l    1
blah_struct
    org *

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

   MOVE.B   #9,D0
   TRAP   #15      ; halt simulator

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

   END   START      ; last line of source

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 28, 2009 11:09 am 
Offline

Joined: Fri Dec 19, 2008 1:12 pm
Posts: 37
Thanks, I didn't know that :) I guess Amiga assemblers don't confirm to the Motorola Assembler standard all the time.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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