/*
* 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"
Tu je i makefile
#
# 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
ranije dok sam koristio Debian 6 uspio sam da uradim cross-compile ovog programa i sve je bilo ok sad na ubuntu isti taj program ne ispisuje ništa u konzoli. Na slici lijevo je program koji radi koji sam kompajlirao na debianu a desno je novi program koji ne radi i ne znam u čemu je kvaka. Za pokretanje ovog programa koristim ./qemu-mips-static a takođe sam ga prebacio i na moj MIPS box (ruter) i ista stvara jedan program radi ok dok drugi neće. Kao što možete da vidite na slici jedina je razlika u .data segmentu, stvarno ne znam
