Andes Workshop

It is currently Thu Mar 28, 2024 7:12 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: how to use madds64 instruction
PostPosted: Thu Jun 30, 2016 7:29 pm 
Offline

Joined: Wed Aug 27, 2014 1:00 pm
Posts: 12
Andes madds64 instruction: [ madds64 Dt, ra, rb ] that multiply the signed integer contents of two 32-bit registers and add the multiplication result to the content of a 64-bit data register(Dx register). Write the final result back to the 64-bit data register.

you can check the NOD field of Misc. Configuration Register : cr4 (MSC_CFG) if the Dx registers exist or not.

if Dx registers exist, as the compiler can't generate the Dx related instruction automatically, you can use inline assembly to use the madds64 instruction

Code:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   int a = 0x12345;
   int b = 0x24680;
   long long c = 0;


        __asm__ volatile ("move \t $r6, %1 \n\t"
                              "move \t $r7, %2 \n\t"
                              "madds64 D0, $r6, $r7"
                              : "=r"(c)
                              : "r"(a),"r"(b)
                              : "$r6","$r7");

   return 0;
}

you can use madd64 instruction in the same way.

attached is the project.


Attachments:
hello-madds64.zip [39.01 KiB]
Downloaded 1024 times
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 16 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