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

Convert C code to assembly
http://forum.andestech.com/viewtopic.php?f=16&t=597
Page 1 of 1

Author:  cindy [ Tue Jul 24, 2012 5:34 pm ]
Post subject:  Convert C code to assembly

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"

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