Andes Workshop

It is currently Tue Sep 26, 2017 11:49 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Check to instruction 16/32 bit format
PostPosted: Thu Apr 03, 2014 4:33 pm 
Offline

Joined: Thu Apr 03, 2014 10:09 am
Posts: 42
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


Top
 Profile Send private message E-mail  
 
 Post subject: Re: Check to instruction 16/32 bit format
PostPosted: Wed Nov 12, 2014 5:51 pm 
Offline

Joined: Wed Apr 13, 2011 7:44 pm
Posts: 23
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


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group