Please send questions to mspgcc-users@lists.sourceforge.net and not to me
directly.

An instruction sequence like you show would occur if the compiler had to
treat r15 as a pointer to a byte rather than an int (viz., a packed
structure) and therefore needed to fetch the bytes independently and
reconstruct the 16-bit length and pointer values.  Presumably the reason it
did so would be revealed by the C code for the function body or compiler
flags.



On Fri, Nov 16, 2012 at 5:27 AM, scalpel4k <scalpe...@gmail.com> wrote:

> Hallo Peter,
>
> I am using the latest git snapshot of your mspgcc. Right now I comb through
> the assembly the compiler is producing for my code. At one point I am a bit
> confused.
>
> I have declared this array structure:
>
> typedef struct {
>         uint16_t        size;
>         uint8_t         * data;
> } uint8Array_t;
>
>
> When I use that struct in the following way:
>
> void someMethod(uint8Array_t * dataArray) {....}
>
> using the 2 struct members (size and data) in that method translates into
> this
> assembly code:
>
>   14:   5d 4f 02 00     mov.b   2(r15), r13     ;0x0002(r15)
>   18:   5e 4f 03 00     mov.b   3(r15), r14     ;0x0003(r15)
>   1c:   8e 10           swpb    r14
>   1e:   0e dd           bis     r13,    r14
>   20:   6d 4f           mov.b   @r15,   r13
>   22:   5f 4f 01 00     mov.b   1(r15), r15     ;0x0001(r15)
>   26:   8f 10           swpb    r15
>   28:   0f dd           bis     r13,    r15
>
> Am I missing something important here? I thought it was a lot simpler .....
>
> As far as I understand, r15 should contain the address to the struct that
> can
> be anywhere in RAM, right? So, I would have thought something like the
> following would have been a proper translation:
>
> mov.w   @r15+, r14
> mov.w @r15, r13
>
> Or does r15 point to the parameter list on the stack? Even in that case I
> don't quite understand the use of byte operations.
>
> Alternatively, when I provide dataArray directly (not as pointer) to a
> method
> the assembly code looks ok to me. The generated assembly code uses the
> stackpointer to access the struct, just as I would have expected.
>
> What do you think, am I really missing something? Btw. I don't use CPUX
> right
> now, just in case that makes some difference.
>
> bye Michi
>
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to