Andes Workshop
http://forum.andestech.com/

Check to instruction 16/32 bit format
http://forum.andestech.com/viewtopic.php?f=16&t=815
Page 1 of 1

Author:  jerry [ Thu Apr 03, 2014 4:33 pm ]
Post subject:  Check to instruction 16/32 bit format

Example code 10.3.1.1 at programming guide

void NDS32ATTR_EXCEPT("id=7;save_all_regs ready_nested;") ge_hdlr(int vid, NDS32_CONTEXT *ptr)
{
unsigned char inst;
/* User’s exception handling code here. */
/* About to return now, and we want to skip the instruction. */
inst = *((unsigned char*) ptr->ipc);
if (inst>>7)
{
/* Bit[7]: 1 represent 16-bit instruction. */
ptr->ipc += 2;

}
else
{
/* Bit[7]: 0 represent 32-bit instruction. */
ptr->ipc += 4;

}
return;
}

Why the "inst " equal 1 than the instruction is 16 bit format ?

The Andes ISA is Big-Endian , the instruction format MSB is 16/32-bit signature .

"inst" will be char(inst = *((unsigned char*) ptr->ipc)).

"if(inst>>7)" --> isnt[7] is the bit31 at 32-bits.

ex: 32-bits instruction is 3e 2f ff fc , 0xfcff2f2e at memory , inst=0x3e , inst[7]=0b
ex: 16-bits instruction is 98 02 , 0x????0298 at memory , inst=0x98 , inst[7]=1b

Author:  ianfeng [ Wed Nov 12, 2014 5:51 pm ]
Post subject:  Re: Check to instruction 16/32 bit format

With assembly code.
for example in demo-int project.

.macro SAVE_ALL
pushm $r0, $r5
pushm $r15,$r30
push_d0d1
push_ifc_lp
mfsr $r0, $IPC

lbi $r1,[$r0+#0x0]
andi $r1,$r1,#0xff
srli $r1,$r1,#7
beqz $r1,#6
addi $r0, $r0, 2
j8 #4
addi $r0, $r0, 4


mfsr $r1, $IPSW
pushm $r0, $r1

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/