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

C語言程式轉成組合語言的方法
http://forum.andestech.com/viewtopic.php?f=16&t=145
Page 1 of 1

Author:  cindy [ Mon Sep 19, 2011 2:52 pm ]
Post subject:  C語言程式轉成組合語言的方法

語法
nds32le-elf-gcc -S hello1.c

hell1.c
Code:
#include <stdio.h>
int empty(void);

int main(void)
{
   printf("!!This is program 1!!\n");
   empty();
   return 0;
}

int empty()
{
   printf("!!This is an empty function!!\n");    
   return 0;
}

      


hell1.s

Code:
   ! For N1033A-S N1033-S N903A-S N903-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 "hello1.c"
   .abi_2
   .section   .mdebug.abi_nds32
   .previous
   .section   .rodata
   .align   2
.LC0:
   .string   "!!This is program 1!!"
   .text
   .align   2
   .globl   main
   .type   main, @function
main:
   ! pretend args size: 0, auto vars size: 0, pushed regs size: 8, outgoing args size: 0
   ! frame pointer: $fp, needed: yes
   ! $fp $lp
   ! use $r8 as function entrypoint: no
   ! use v3 push/pop: no
   ! prologue frame size: 8
   smw.adm   $sp, [$sp], $sp, 10
   addi   $fp, $sp, 4
   ! end of prologue
   la   $r0, .LC0
   .hint_func_args 62
   bal   puts
   .hint_func_args 63
   bal   empty
   movi   $r0, 0
   ! epilogue - AABI
   addi   $sp, $fp, -4
   lmw.bim   $sp, [$sp], $sp, 10
   .hint_func_args 62
   ret
   .size   main, .-main
   .section   .rodata
   .align   2
.LC1:
   .string   "!!This is an empty function!!"
   .text
   .align   2
   .globl   empty
   .type   empty, @function
empty:
   ! pretend args size: 0, auto vars size: 0, pushed regs size: 8, outgoing args size: 0
   ! frame pointer: $fp, needed: yes
   ! $fp $lp
   ! use $r8 as function entrypoint: no
   ! use v3 push/pop: no
   ! prologue frame size: 8
   smw.adm   $sp, [$sp], $sp, 10
   addi   $fp, $sp, 4
   ! end of prologue
   la   $r0, .LC1
   .hint_func_args 62
   bal   puts
   movi   $r0, 0
   ! epilogue - AABI
   addi   $sp, $fp, -4
   lmw.bim   $sp, [$sp], $sp, 10
   .hint_func_args 62
   ret
   .size   empty, .-empty
   .ident   "GCC: (2011-07-29) 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/