在官方的nuclei-board-labs中有对NICE指令集的一个例程,我们通过nuceil studio 对其进行了一个debug软件验证
![]()
我们先对程序进行编译,然后debug,通过disassembly的模块获取到NICE 的R型指令然后在对照嵌入汇编和E203v2的nice核里的相关模块的寄存器进行对照,我们先放出对驱动程序的注释
int nice_case(unsigned int array[ROW_LEN][COL_LEN]){ volatile unsigned char i, j; volatile unsigned int col_sum[COL_LEN]={0}; volatile unsigned int row_sum[ROW_LEN]={0}; volatile unsigned int init_buf[3]={0}; custom_lbuf((int)init_buf);// .insn r 0x7b, 2, 1, x0, %1, x0 0x207a07b/* opcode func3 func7 rd rs1 rs2 0x7b 2 1 x0 %1 x0 custom3 只读取rs1的数据 第一种操作 零寄存器 保存addr地址 零寄存器 1111011 010 0000001 00000 01010 00000 /* * func7 rs2 rs1 func3 rd opcode * 31---------24--------19------14------12----------------6----------0 * | 0000001 | 00000 | 01111 | 010 | 00000 | 1111011 | * |------------------------------------------------------|----------| */ ass_code 0x207a07b 0000001 00000 01111 010 00000 1111011 */ for (i = 0; i < ROW_LEN; i++) { row_sum = custom_rowsum((int)array);//0x7b, 6, 6, %0, %1, x0 /* opcode func3 func7 rd rs1 rs2 0x7b 6 6 %0 %1 x0 custom3 读取rs1、rd的数据 第六种操作 rowsum地址 保存addr地址 零寄存器 1111011 110 0000110 01011 01010 00000 /* * func7 rs2 rs1 func3 rd opcode * 31---------24--------19------14------12----------------6----------0 * | 0000110 | 00000 | 01111 | 110 | 01111 | 1111011 | * |------------------------------------------------------|----------| */ ass_code 0xc07e7fb 0000110 00000 01111 110 01111 1111011 */ //R型指令[[31:25]fun7,[24:20]rs2,[19:15]rs1,[14:12]func3,[11:7]rd,[6:0]opcode] } custom_sbuf((int)col_sum);// 0x7b, 2, 2, x0, %1, x0 0x407a07b /* opcode func3 func7 rd rs1 rs2 0x7b 2 2 x0 %1 x0 custom3 只读取rs1的数据 第二种操作 零寄存器 保存addr地址 零寄存器 1111011 010 0000010 00000 01010 00000 /* * func7 rs2 rs1 func3 rd opcode * 31---------24--------19------14------12----------------6----------0 * | 0000010 | 00000 | 01111 | 010 | 00000 | 1111011 | * |------------------------------------------------------|----------| */ */ ass_code 0x407a07b 0000010 00000 01111 010 00000 1111011#ifdef _DEBUG_INFO_ printf ("the element of array is :nt"); for (i = 0; i < ROW_LEN; i++) printf("%dt", array[0]); printf("nt"); for (i = 0; i < ROW_LEN; i++) printf("%dt", array[1]); printf("nt"); for (i = 0; i < ROW_LEN; i++) printf("%dt", array[2]); printf("nn"); printf ("the sum of each row is :ntt"); for (i = 0; i < ROW_LEN; i++) printf("%dt", row_sum); printf("n"); printf ("the sum of each col is :ntt"); for (j = 0; j < COL_LEN; j++) printf("%dt", col_sum[j]); printf("n");#endif return 0;}
|