Im trying to crosscompile simple helloworld.s written in assembly on MIPS platform, I found simple example
here and here is mine simple program
Quote:
/*
* hello-1.2/Makefile
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1995, 1997 by Ralf Baechle
*/
#include <regdef.h>
#include <sys/asm.h>
#include <sys/syscall.h>
#define O_RDWR 02
EXPORT(__start)
.set noreorder
LEAF(main)
# fd = open("/dev/tty1", O_RDWR, 0);
la a0,tty
li a1,O_RDWR
li a2,0
li v0,SYS_open
syscall
bnez a3,quit
move s0,v0 # delay slot
# write(fd, "hello, world.\n", 14);
move a0,s0
la a1,hello
li a2,14
li v0,SYS_write
syscall
# close(fd);
move a0,s0
li v0,SYS_close
syscall
quit:
li a0,0
li v0,SYS_exit
syscall
j quit
nop
END(main)
.data
tty: .asciz "/dev/tty1"
hello: .ascii "Hello, world.\n"
|
and here is mine make file
Code:
#
# hello-1.2/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file COPYING in the main directory of this archive for more
# details.
tool-prefix = mips-linux-gnu-
CC = $(tool-prefix)gcc -I /home/slobodan/rtl819x-toolchain/toolchain/rsdk-1.5.5-5281-EB-2.6.30-0.9.30.3-110714/include/sys/
LD = $(tool-prefix)ld
STRIP = $(tool-prefix)strip
CFLAGS = -G0 -mno-abicalls -fno-pic
LDFLAGS = -N -s
all: hello
hello: hello.o
$(LD) $(LDFLAGS) -o hello hello.o
hello.o: hello.S
$(CC) $(CFLAGS) -c hello.S
clean:
rm -f core a.out *.o *.s
distclean: clean
rm -f hello
program does compile but when I run it I get nothing as output. I did tried
mips-linux-gnu-gcc and
from
Realtek SDK but its same deal does not print hello world to console.
I also tried changing
to
and
to
but again its same deal I dont get anything printed to console. As emulator I used qemu-mips-static and my mips box (its actually MIPS router)