Quote (irimi @ 28 Nov 2012 22:21)
On the LHS, it basically treats your shifts as no-ops: loading the value of bufr[0] into r24 and putting it in the high bits of temp at 0x0103, and storing a bunch of zeros in the low bits of temp at 0x0102, and when you assign bufs[0] to the right shift of temp, it says "oh, but that's just the high bits of temp, which we just got from r24".
i agree with that
Quote (irimi @ 28 Nov 2012 22:21)
1) Are you correctly reading the output? Maybe the above code works fine, but there's a bug in the code that looks at this stuff.
may be, but i've tried a lot of different methods to check if that is actually the problem. when i simplify the surrounding code (as example, if i set "buf[0]=1;") then the compiler compiles different (then he is more lucky to do it correctly)
Quote (irimi @ 28 Nov 2012 22:21)
2) Assuming that there IS a bug, it might possibly be from the ***-enclosed sentence. According to the Atmega32u4 spec, r14 and r15 are not segmented registers, so I'm actually a little confused as to how the movw from r28 to r14 actually works. It could be possible that the mov doesn't actually do the right thing, and you're storing the garbage from r15 into the lower bits of bufs[0] -- in this case, it happens to be 0x01.
hmm, i haven't found that in the datasheet i looked at before. it just said those are "general registers"... i guess that this isn't the problem

Quote (irimi @ 28 Nov 2012 22:21)
Also, isn't your comment on the temp = statement wrong? Assuming bufr[0] is 0x02, shouldn't temp be 0x20 after the shift?
yep, you're right, actually it should be 0x0200
i guess the problem is already earlier... here my thoughts:
1) r15 must have a wrong value, else there is no way the output could be wrong
2) the value of r15 is the value of r29 (the "movw r28 r14" does this... or should do it

)
3) the line where r29 is changed right before that is the "movw r28 r24"-command. so r29 is just the copy of r25
4) r25 is never set... the "ldi r24, 0x00" is just a one-byte clearing...
it's possible that i'm wrong, but right now i'm quite convinced ^^... what do you think? does my theory make sense?