test_dsp_r1_addwc.c (971B)
1#include<stdio.h> 2#include<assert.h> 3 4int main() 5{ 6 int rd, rs, rt; 7 int dspi, dspo; 8 int result; 9 10 rs = 0x10FF01FF; 11 rt = 0x10010001; 12 dspi = 0x00002000; 13 result = 0x21000201; 14 __asm 15 ("wrdsp %3\n" 16 "addwc %0, %1, %2\n\t" 17 : "=r"(rd) 18 : "r"(rs), "r"(rt), "r"(dspi) 19 ); 20 assert(rd == result); 21 22 rs = 0xFFFF1111; 23 rt = 0x00020001; 24 dspi = 0x00; 25 result = 0x00011112; 26 __asm 27 ("wrdsp %3\n" 28 "addwc %0, %1, %2\n\t" 29 : "=r"(rd) 30 : "r"(rs), "r"(rt), "r"(dspi) 31 ); 32 assert(rd == result); 33 34 rs = 0x8FFF1111; 35 rt = 0x80020001; 36 dspi = 0x00; 37 result = 0x10011112; 38 __asm 39 ("wrdsp %4\n" 40 "addwc %0, %2, %3\n\t" 41 "rddsp %1\n\t" 42 : "=r"(rd), "=r"(dspo) 43 : "r"(rs), "r"(rt), "r"(dspi) 44 ); 45 assert(rd == result); 46 assert(((dspo >> 20) & 0x01) == 1); 47 48 return 0; 49}