I'm using the instruction STD (STDI, actually) to store two registers at once. The architecture manual says:
Mnemonic and operands:
Code: Select all
STDI d,e,b,i
Code: Select all
mem[b + i * Bpw * 2] <- d
mem[b + i * Bpw * 2 + Bpw] <- e
Code: Select all
std r0, r6, r3[0]
The actual behaviour, however, seems to be the opposite, that is: r0 gets into r3[0] and r6 into r3[4]. Please see the programs below.
Code: Select all
#include <platform.h>
#include <stdio.h>
int foo = 5, bar = 6;
int [[aligned(8)]] baz[2];
int main(void)
{
baz[0] = foo; // 5
baz[1] = bar; // 6
printf("%d, %d\n", baz[0], baz[1]); // prints "5, 6"
asm volatile ("std %0, %1, %2[0]" : : "r"(foo), "r"(bar), "r"(baz) : "memory");
printf("%d, %d\n", baz[0], baz[1]); // prints "6, 5"
return 0;
}
Code: Select all
ldw r0, dp[foo] //
stw r0, dp[baz] // baz[0] = foo;
ldaw r0, dp[baz] // r0 contains the base address of the array
ldw r1, dp[bar] //
stw r1, dp[baz+4] // baz[1] = bar;
ldw r1, dp[foo] // r1 <= foo
ldw r2, dp[bar] // r2 <= bar
#APP
std r1, r2, r0[0] // should be r0[0] <= r1, r0[4] <= r2
#NO_APP