I would imagine that struct = struct would be a bit more efficient.

MemMove has to handle overlapping memory addresses, so there is going to
be a little bit of overhead for that. Also, MemMove is a system trap and calling OS functions consists of setting up the environment (for the stack frame, return address, giving control to the OS, etc...).


That is why I think it would be more efficient just copying your structure in a loop (i.e. struct = struct ).

Brad

Regis St-Gelais wrote:
This is a repost from March 10, I did not get any answer, maybe this time I
will be lucky.


With CW 9.3 in C,


Let say I have a typedef of a struct (fooStruct)

I declare 2 structs:
fooStruct udsStructA;
fooStruct udsStructB;

I can copy the struct content with this:
udsStructA=udsStructB;

the assembly looks like:
00000068: 41ED 0000          lea       udsStructB,a0
0000006C: 43ED 0000          lea       udsStructA,a1
00000070: 303C 0359          move.w    #857,d0
00000074: 22D8               move.l    (a0)+,(a1)+
00000076: 51C8 FFFC          dbra      d0,*-2         ; 0x00000074


and with that: MemMove(&udsStructA,&udsStructB,sizeof(fooStruct));

the assembly looks like:
0000007A: 4878 0D68          pea       0x00000d68
0000007E: 486D 0000          pea       udsStructB
00000082: 486D 0000          pea       udsStructA
00000086: 4E4F               trap      #15
00000088: A026               sysTrapMemMove

My assembly knowleage date from the 8080, 6802 days so I am a bit out of
date on 68K assembly ;-)

Which way is the best way to do this?

Thanks


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to