Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
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.


  Search this Thread
Old 12-29-2009, 12:13 PM   #1
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 ( 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:

.section .text

.global	_start

	ADD	r0, r0, r1
	MOV	pc, lr

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

## Macros

# Environment macros
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

## File List

# Project file list (leave off the suffixes)

# 3rd party file list
	#Put any required 3rd party libraries here

## Suffix rules (do not change)

## Commands (do not change)

# Build the executable only
exe:				\
	compile			\

# Compile all files
compile: ${SOURCE_FILES:=.s}

# Link object files into executable
all: ${SOURCE_FILES:=.o}

# Get rid of all non-source files

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
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:
#include <stdio.h>

  // 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);

CC = /usr/bin/gcc

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

	rm add *.o


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 11:39 PM.

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