test_dsp_r1_extpdp.c (1217B)
1#include<stdio.h> 2#include<assert.h> 3 4int main() 5{ 6 int rt, ach, acl, dsp, pos, efi; 7 int result; 8 9 ach = 0x05; 10 acl = 0xB4CB; 11 dsp = 0x07; 12 result = 0x000C; 13 14 __asm 15 ("wrdsp %1, 0x01\n\t" 16 "mthi %2, $ac1\n\t" 17 "mtlo %3, $ac1\n\t" 18 "extpdp %0, $ac1, 0x03\n\t" 19 "rddsp %1\n\t" 20 : "=r"(rt), "+r"(dsp) 21 : "r"(ach), "r"(acl) 22 ); 23 pos = dsp & 0x3F; 24 efi = (dsp >> 14) & 0x01; 25 assert(pos == 3); 26 assert(efi == 0); 27 assert(result == rt); 28 29 ach = 0x05; 30 acl = 0xB4CB; 31 dsp = 0x01; 32 33 __asm 34 ("wrdsp %1, 0x01\n\t" 35 "mthi %2, $ac1\n\t" 36 "mtlo %3, $ac1\n\t" 37 "extpdp %0, $ac1, 0x03\n\t" 38 "rddsp %1\n\t" 39 : "=r"(rt), "+r"(dsp) 40 : "r"(ach), "r"(acl) 41 ); 42 efi = (dsp >> 14) & 0x01; 43 assert(efi == 1); 44 45 46 ach = 0; 47 acl = 0; 48 dsp = 0; 49 result = 0; 50 51 __asm 52 ("wrdsp %1\n\t" 53 "mthi %2, $ac1\n\t" 54 "mtlo %3, $ac1\n\t" 55 "extpdp %0, $ac1, 0x00\n\t" 56 "rddsp %1\n\t" 57 : "=r"(rt), "+r"(dsp) 58 : "r"(ach), "r"(acl) 59 ); 60 assert(dsp == 0x3F); 61 assert(result == rt); 62 63 return 0; 64}