Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] A simple program to cross compile from C to ASSEMBLY

Status
Not open for further replies.

sai685

Junior Member level 2
Joined
Sep 4, 2015
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
292
Code:
#include<stdio.h>
#define GPIO_PORTA_DIR_R (*((volatile unsigned long *)0x40004400))
int main()
{
GPIO_PORTA_DIR_R = 0x80;
printf("GPIO_PORTA=%x",GPIO_PORTA_DIR_R);
}

This code is converted into assembly after this command in linux

$ gcc -S try.c

which is like

Code:
	.file	"try.c"
	.text
.globl main
	.type	main, @function
main:
.LFB2:
	pushq	%rbp
.LCFI0:
	movq	%rsp, %rbp
.LCFI1:
	movl	$1073759232, %eax
	movq	$128, (%rax)
	leave
	ret
.LFE2:
	.size	main, .-main
	.section	.eh_frame,"a",@progbits
.Lframe1:
	.long	.LECIE1-.LSCIE1
.LSCIE1:
	.long	0x0
	.byte	0x1
	.string	"zR"
	.uleb128 0x1
	.sleb128 -8
	.byte	0x10
	.uleb128 0x1
	.byte	0x3
	.byte	0xc
	.uleb128 0x7
	.uleb128 0x8
	.byte	0x90
	.uleb128 0x1
	.align 8
.LECIE1:
.LSFDE1:
	.long	.LEFDE1-.LASFDE1
.LASFDE1:
	.long	.LASFDE1-.Lframe1
	.long	.LFB2
	.long	.LFE2-.LFB2
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI0-.LFB2
	.byte	0xe
	.uleb128 0x10
	.byte	0x86
	.uleb128 0x2
	.byte	0x4
	.long	.LCFI1-.LCFI0
	.byte	0xd
	.uleb128 0x6
	.align 8
.LEFDE1:
	.ident	"GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-44)"
	.section	.note.GNU-stack,"",@progbits

but after this i have enter the command to link the files
which is

$ as -o try.s

after executing this command i am getting only empty lines that means it is not asking to me write any other command just it is showing a blank space.

let me know what is the solution for this and at the same time if you have any best material for this cross compiler please include link
 

I suspect that this is an example of the "XY Problem" (https://xyproblem.info/) where you are telling us the problem you are having with some solution you have come up with to your real problem.
"gcc" is quite happy to go directly from C to the object file in one command. You can certainly ask it to save the assembly data that it generates from the C code if you really want that as well.
Also you mention "cross-compile" in the title but the commands don't seem to tell the compiler to do that and the code looks like X86, even through the C code looks more like microcontroller code.
Perhaps you would be better of telling us exactly what you are trying to do (rather than how you are going about it).
Susan
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top