Andes Workshop

It is currently Fri Mar 29, 2024 2:04 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Compile only; do not assemble or link command
PostPosted: Wed Jan 29, 2014 4:40 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
If you want to compile a code, and don't assemble or link.
Command: nds32le-elf-gcc -S
Example:
Code:
nds32le-elf-gcc -S -O2 main.c

Attachment:
gcc_s.gif
gcc_s.gif [ 4.85 KiB | Viewed 6919 times ]

-O2 is optimization level

main.c
Code:
#include <stdio.h>

struct student {
  int id;
  char *name;
  int pid;
  float percentage;
} student1, student2, student3;
int main() {
  struct student st;
  student1.id=1;
  student1.name = "Angelina";
  student1.percentage = 90.5;
  printf(" Id is: %d \n", student1.id);
  printf(" Name is: %s \n", student1.name);
  printf(" Percentage is: %f \n", student1.percentage);
  printf(" address is: 0x%x \n", &student1.id);
  printf(" address is: 0x%x \n", &student1.name);
  printf(" address is: 0x%x \n", &student1.pid);
  printf(" address is: 0x%x \n", &student1.percentage);
  return 0;
}


main.s
Code:
   ! For N705-S SN801-S N801-S N1337-S N968-S N1068-S N968A-S N1068A-S N1337-FPU N1068-FPU N1068A-FPU
   ! Use little-endian byte order
   ! Generate baseline V3M instructions
   ! Generate 16/32-bit mixed instructions
   ! Use 16 registers to generate code
   ! Internally expand vector and jump table sections of ISR attribute
   ! Align functions to 4-bytes boundary
   ! Remove redundant branches in the pattern of branch-jump-label
   ! Enable post optimization
   ! Generate instructions for ABI: 2
   .file   1 "main.c"
   .abi_2
   .section   .mdebug.abi_nds32
   .previous
   .section   .note.nds32, "", @progbits
   .string      "'-mlib=mculib' '-static' '-S' '-O2'"
   .previous
   .section   .rodata.str1.4,"aMS",@progbits,1
   .align   2
.LC0:
   .string   "Angelina"
   .align   2
.LC1:
   .string   " Id is: %d \n"
   .align   2
.LC2:
   .string   " Name is: %s \n"
   .align   2
.LC3:
   .string   " Percentage is: %f \n"
   .globl   __extendsfdf2
   .align   2
.LC4:
   .string   " address is: 0x%x \n"
   .text
   .align   2
   .globl   main
   .type   main, @function
main:
   ! pretend args size: 0, auto vars size: 0, pushed regs size: 32, outgoing args size: 0
   ! max argument reg: $r1
   ! frame pointer: $fp, needed: no
   ! $r6 $r7 $r8 $r9 $r10 $fp $gp $lp
   ! use $r8 as function entrypoint: yes
   ! use v3 push/pop: yes
   ! prologue frame size: 32
   v3push   $r10, 0
   ! end of prologue
   la   $r8, student1
   move   $r7, $r8
   movi   $r1, 1
   swi.p   $r1, [$r7], 4
   sethi   $r2, hi20(1119158272)
   la   $r3, .LC0
   addi   $r9, $r8, 12
   swi   $r3, [$r7+(0)]
   swi   $r2, [$r9+(0)]
   la   $r6, printf
   la   $r0, .LC1
   .hint_func_args 60
   bral   $r6
   lwi   $r1, [$r7+(0)]
   la   $r0, .LC2
   .hint_func_args 60
   bral   $r6
   lwi   $r0, [$r9+(0)]
   .hint_func_args 62
   bal   __extendsfdf2
   movd   $r2, $r0
   la   $r0, .LC3
   .hint_func_args 48
   bral   $r6
   move   $r1, $r8
   la   $r0, .LC4
   .hint_func_args 60
   bral   $r6
   move   $r1, $r7
   la   $r0, .LC4
   .hint_func_args 60
   bral   $r6
   addi   $r1, $r8, 8
   la   $r0, .LC4
   .hint_func_args 60
   bral   $r6
   move   $r1, $r9
   la   $r0, .LC4
   .hint_func_args 60
   bral   $r6
   movi   $r0, 0
   ! epilogue - AABI
   .hint_func_args 62
   v3pop   $r10, 0
   .size   main, .-main
   .comm   student1,16,4
   .comm   student2,16,4
   .comm   student3,16,4
   .ident   "GCC: (2013-09-24) 4.4.4"



Attachments:
struct_example.zip [27.47 KiB]
Downloaded 780 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 12 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