Andes Workshop

It is currently Thu Mar 28, 2024 8:36 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Get PC (v3m)
PostPosted: Wed Aug 28, 2013 3:26 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
In programming guide, it describe how to get PC. (as following)

9.2. Get PC
While instruction “MFUSR rt5,PC” allows moving PC to the specified general purpose register rt5, it is not implemented in N1213 hardcore of CPU version 0x0C010003. Thus, a general way to get PC is “JAL 4”, which stored the address of next instruction into $lp. While this works fine, it does cause penalty on hardware branch prediction since it simply throws the whole prediction off balance.

but V3m doesn't support MFUSR instruction.
Please change to JAL 4, get $PC through $lp value.
note: If you want to preserve current $lp, please push $lp into stack.


Top
 Profile Send private message E-mail  
 
 Post subject: Re: Get PC (v3m)
PostPosted: Mon Apr 28, 2014 7:30 pm 
Offline

Joined: Wed Apr 13, 2011 7:44 pm
Posts: 23
Sample code:
For V3 toolchain:
Code:
   unsigned int ui_val;

   __asm__ ("MFUSR\t%0,$pc" : "=r" (ui_val) :);

For V3M toolchain:
$lp will be used, and it must be backuped and restored.
Code:
   unsigned int ui_val;

   __asm__ ("addi\t$r0,$lp,0\n\t" \
         "JAL 4\n\t" \
         "addi\t%0,$lp,0\n\t" \
         "addi\t$lp,$r0,0" : "=r" (ui_val) ::"$r0","$lp");


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 10 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