Guru Prasad
Guru Prasad

Reputation: 4223

How to write a program for ARM using *only* assembly

I would like to write a small program in pure ARM assembly for my ARM-based phone (Nexus S). I know about inline assembly in C, but when i tried a simple program such as

int main() {
    asm("nop");
    return 0;
}

perf showed that thousands of instructions and cycles were consumed to run this program. I'm not sure why..but I believe this is because of loading the minimum C library so as to handle int main and return 0 among other things.
I would like to avoid that..

So, I was wondering if it is possible to write a small program in pure assembly and execute it on an ARM-based phone(Nexus S)

Upvotes: 2

Views: 2804

Answers (3)

XWiśniowiecki
XWiśniowiecki

Reputation: 1843

You can use duo gnu arm compiler + eclipse IDE. To have full environment you need also bootloader. Because I had to deal with LPC2148 uC, I used to use LPCUSB loader. It was also easy to integrate with eclipse... so loading and compiling did one-click.

More information you will find using: https://www.google.pl/search?num=20&newwindow=1&safe=off&espv=210&es_sm=93&q=gnu+arm+eclipse+plugin+installation

You have to choose proper bootloader that will be working with your uC.

Upvotes: 0

johnfound
johnfound

Reputation: 7051

At first you need some proper toolkit - most importantly assembler. I would suggest fasmarm.

It is crossassembler based on FASM - you should write your programs on x86 machine - Windows or Linux, compile the program and then upload it to the Arm machine for execution.

Fasmarm supports the full range of Arm processors and coprocessors.

Upvotes: 1

old_timer
old_timer

Reputation: 71506

.globl _start
_start:
   nop
   b .

Upvotes: 1

Related Questions