EASy68K
http://www.easy68k.com/EASy68Kforum/

Structures with the rs directive.
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=5&t=647
Page 1 of 1

Author:  Thorham [ Sat May 09, 2009 6:43 pm ]
Post subject:  Structures with the rs directive.

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

Author:  profkelly [ Wed May 27, 2009 4:22 pm ]
Post subject: 

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

Author:  Thorham [ Thu May 28, 2009 11:09 am ]
Post subject: 

Thanks, I didn't know that :) I guess Amiga assemblers don't confirm to the Motorola Assembler standard all the time.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/