LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices



Reply
 
Search this Thread
Old 12-29-2009, 12:13 PM   #1
wmnelis
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
Post GNU assembly programming directly on an ARM920T running Debian (not cross-compiling)


I am trying to write some very simple assembly code directly on an Excito Bubba Server (https://www.excito.com/bubba/products/overview.html). The server has an ARM920T processor and runs Debian. I am writing the code directly on the device by ssh-ing into it (as-in I am not cross-compiling). So far I have been unable to get anything to work. I always get a segfault. I am a novice at Assembly programming, I have done some in college and some on my own on an x86 machine with no trouble.


Here is an example of some code I have written:

Code:
.section .text

.global	_start

_start:
	ADD	r0, r0, r1
	MOV	pc, lr

Here is the makefile I am using to assemble and link this code:

Code:
##
## Macros
##

# Environment macros
AS=as
LD=ld
RM=rm -f

# Project macros
EXE_NAME=hello #Put the name you want the executable to have here
ASFLAGS=-mcpu=arm920t --gdwarf2 #gdwarf2 creates a debug info file
LDFLAGS=

##
## File List
##

# Project file list (leave off the suffixes)
SOURCE_FILES=		\
	hello

# 3rd party file list
LIBRARIES=			\
	#Put any required 3rd party libraries here

##
## Suffix rules (do not change)
##

##
## Commands (do not change)
##

# Build the executable only
exe:				\
	compile			\
	all

# Compile all files
compile: ${SOURCE_FILES:=.s}
	${AS} ${ASFLAGS} -o ${SOURCE_FILES:=.o} ${SOURCE_FILES:=.s} ${LIBRARIES}

# Link object files into executable
all: ${SOURCE_FILES:=.o}
	${LD} ${LDFLAGS} -o ${EXE_NAME} ${SOURCE_FILES:=.o} ${LIBRARIES}

# Get rid of all non-source files
clean:
	${RM} ${EXE_NAME} ${SOURCE_FILES:=.o}

This example will create an executable, but it will segfault immediately. Anyone out there know what I am doing wrong?

Thanks for any help you can offer.
 
Old 12-29-2009, 03:49 PM   #2
wmnelis
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Post More information

Just to add, the following C code with inline assembly works just fine on the same machine:


Source code:
Code:
#include <stdio.h>

main()
{
  // Declare a variable that will contain a calculated value
  int i = 0;

  // Set the values to add
  int a = 2;
  int b = 4;

  // Add the values and store the result in the "i" C variable
  asm volatile
    ("add %0, %1, %2" // <-- Assembly code
     : "=r"(i)        // <-- Outputs
     : "r"(a), "r"(b) // <-- Inputs
     : "r0", "r1"     // <-- Clobber list
    );

  // Output the calculated value
  printf("The value: %d\n", i);
}

Makefile:
Code:
CC = /usr/bin/gcc


all:
	${CC} -c add.c
	$(CC) -o add add.o

clean:
	rm add *.o
 
  


Reply

Tags
assembler, gnu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross compiling Mono for ARM device running on Linux 2.4 kartiknatarajan Linux - Embedded & Single-board computer 5 12-16-2009 11:59 PM
Cross-compiling using x86 linux, for UltraSPARC III Cu running SunOS 5.8 Oxagast Solaris / OpenSolaris 1 03-28-2008 02:31 PM
LXer: Running Debian GNU/Linux from an encrypted USB drive LXer Syndicated Linux News 0 02-19-2008 12:11 PM
Cross compiling GNU toolchain. pwrichards Linux - Newbie 0 11-30-2007 08:41 AM
Can gcc cross-compile C code to M68K Assembly? lowpro2k3 Programming 1 03-25-2005 08:50 AM


All times are GMT -5. The time now is 05:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration