Writing mipsel assembly programs

Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions
Author Message
CrazyHorse
DD-WRT Novice


Joined: 10 Jul 2006
Posts: 23

PostPosted: Fri Apr 02, 2010 15:47    Post subject: Writing mipsel assembly programs Reply with quote
I've just built a cross binutils assembler for mipsel. I have this short program that I wrote:

.text
.globl main
main:
li $2, 4
la $4, greeting
syscall

li $4, 10
syscall

.data
greeting: .asciiz "Hello, world!"

% mipsel-linux-uclibc-as -mips32 hello.S -o hello.o
% mipsel-linux-uclibc-ld -e main hello.o -o hello
% scp hello XXxxXX@router:/tmp/

XXxxXX@router:/tmp# ./hello
Illegal instruction

Any ideas why it would be complaining about illegal instructions? I had a look at hello's elf header and compared it to hotplug's elf header (taken from router) and there are some differences but I'm unsure if these differences are important enough:

% mipsel-linux-uclibc-readelf -h ./hotplug
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x400630
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x50001007, noreorder, pic, cpic, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0

and

% mipsel-linux-uclibc-readelf -h ./hello ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x4000d0
Start of program headers: 52 (bytes into file)
Start of section headers: 320 (bytes into file)
Flags: 0x50001000, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 4
Size of section headers: 40 (bytes)
Number of section headers: 10
Section header string table index: 7

Any ideas?
Sponsor
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions All times are GMT

Navigation

 
Jump to:  
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 vote in polls in this forum
You can attach files in this forum
You can download files in this forum