Andes Workshop

It is currently Fri Mar 29, 2024 5:58 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Convert C code to assembly
PostPosted: Tue Jul 24, 2012 5:34 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
Using the following command line:

Code:
nds32le-elf-gcc -S func.c -o func.S


func.c
Code:
int add(int,int);

int add(int a, int b) {
   int c;
   c=a+b;
   return c;
}



func.S
Code:
   ! For N903-S N903A-S N1033-S N1033A-S N1213-S N1233-S
   ! Use little-endian byte order
   ! Generate baseline V2 instructions
   ! Generate 16/32-bit mixed instructions
   ! Generate multiply with accumulation instructions using register $d0/$d1
   ! Generate integer div instructions using register $d0/$d1
   ! Generate performance extension instructions
   ! Generate instructions for ABI: 2
   .file   1 "func.c"
   .abi_2
   .section   .mdebug.abi_nds32
   .previous
   .text
   .align   2
   .globl   add
   .type   add, @function
add:
   ! pretend args size: 0, auto vars size: 16, pushed regs size: 4, outgoing args size: 0
   ! max argument reg: $r1
   ! frame pointer: $fp, needed: yes
   ! $fp
   ! use $r8 as function entrypoint: no
   ! use v3 push/pop: no
   ! prologue frame size: 24
   smw.adm   $sp, [$sp], $sp, 8
   addi   $fp, $sp, 0
   addi   $sp, $sp, -20
   ! end of prologue
   swi   $r0, [$fp+(-16)]
   swi   $r1, [$fp+(-20)]
   lwi   $r1, [$fp+(-16)]
   lwi   $r0, [$fp+(-20)]
   add   $r0, $r1, $r0
   swi   $r0, [$fp+(-8)]
   lwi   $r0, [$fp+(-8)]
   ! epilogue - AABI
   addi   $sp, $fp, 0
   lmw.bim   $sp, [$sp], $sp, 8
   .hint_func_args 62
   ret
   .size   add, .-add
   .ident   "GCC: (2012-03-16) 4.4.4"


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