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

how to use madds64 instruction
http://forum.andestech.com/viewtopic.php?f=25&t=957
Page 1 of 1

Author:  maolj [ Thu Jun 30, 2016 7:29 pm ]
Post subject:  how to use madds64 instruction

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

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