Andes Workshop

It is currently Fri Mar 29, 2024 4:29 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: 如何使用乘加指令maddr32
PostPosted: Fri Feb 08, 2013 6:18 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
Andes compiler會自動產生乘加指令,gcc真是相當聰明呢

舉個例子,程式碼:
int a,b,c,d;
int x1,x2,x3;

int main(void) {
d=a*x1+b*x2+c*x3;
return 0;
}

經過最佳化編譯之後(-O1以上均可,下面是-Os產生的code)
500108: 3c 1c 00 02 lwi.gp $r1,[+#8]
50010c: 3c 0d ff fe lwi.gp $r0,[+#-8]
500110: 42 10 80 24 mul $r1,$r1,$r0
500114: 3c 2c 00 03 lwi.gp $r2,[+#12]
500118: 3c 0d ff ff lwi.gp $r0,[+#-4]
50011c: 42 11 00 73 maddr32 $r1,$r2,$r0
500120: 3c 2c 00 04 lwi.gp $r2,[+#16]
500124: 3c 0c 00 00 lwi.gp $r0,[+#0]
500128: 42 11 00 73 maddr32 $r1,$r2,$r0
50012c: 84 00 movi55 $r0,#0
50012e: 3c 1e 00 01 swi.gp $r1,[+#4]
500132: dd 9e ret5 $lp

第一次用乘,另外兩次用乘加。


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

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