View Single Post
Old 12 February 2015, 06:59   #47
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 41
Posts: 2,960
Quote:
Originally Posted by Nekoniaow View Post
However you are too harsh
Yes, that was too harsh, sorry about that.

Quote:
Originally Posted by Nekoniaow View Post
- data structure modifications: modifying a struct inside a struct inside a struct does not require any code to change, nor offsets to recompute, no indirections to update
Absolutely not a problem if you use the rs directive or OS include macros.

Example:
Code:
    incdir  "asminc:"
    include "exec/types.i"

 STRUCTURE struct1,0
 ULONG struct1.foo
 ULONG struct1.bar
 LABEL sizeOf_struct1

 STRUCTURE struct2,0
 ULONG struct2.foo
 STRUCT struct2.struct1,sizeOf_struct1
 ULONG struct2.bar
 LABEL sizeOf_struct2

 STRUCTURE struct3,0
 ULONG struct3.foo
 STRUCT struct3.struct2,sizeOf_struct2
 ULONG struct3.bar
 LABEL sizeOf_struct3

a
    lea     data,a0 ; points to structure 3
    lea     struct3.struct2(a0),a1 ; points to structure 2 inside structure 3
    lea     struct2.struct1(a1),a2 ; points to structure 1 inside structure 2

    move.l  #"foo3",struct3.foo(a0)
    move.l  #"bar3",struct3.bar(a0)

    move.l  #"foo2",struct2.foo(a1)
    move.l  #"bar2",struct2.bar(a1)

    move.l  #"foo1",struct1.foo(a2)
    move.l  #"bar1",struct1.bar(a2)

    rts

data
    dcb.b   1024
As you can see, the assembler does all the work and allows the programmer to change anything they want. Works in any sane assembler. Don't EVER make structures in assembly language by using numerical values instead of names.

Quote:
Originally Posted by Nekoniaow View Post
On a macro scale, they are terribly hard
Wouldn't call it hard, just more time consuming and a potential pain in the back side. I don't think assembly language is really any harder than C, it's just more work to get things done, and requires more thought in order to keep things from turning into a mess.

Last edited by Thorham; 12 February 2015 at 07:12.
Thorham is offline  
 
Page generated in 0.05255 seconds with 9 queries