2011/7/20 Sébastien Doutreligne <sebastien.doutreli...@gmail.com>: > I am involved in programming computer without any operating system on top. I > practised intel assembly in qemu and try to run an assembly program on the > yeeloong laptop. I use a gnu toolchain mipsel build from embedian. > > Here is the code: >> >> .text >> .globl __start >> __start: >> li $8, 5 >> li $9, 5 > > I use a linker script as such: >> >> SECTIONS >> { >> . = 0xffffffff80000000; >> .text : { * (.text); } >> } > > The makefile is as simple: > >> CROSS=mipsel-linux-gnu- >> CC=${CROSS}gcc >> OBJCOPY=${CROSS}objcopy >> LDFLAGS=-mips3 -T test.lds -Wall -nostdlib >> >> test.elf: test.s test.c >> ${CC} $(LDFLAGS) $^ -o $@ > > Once compiled, I copy it in a tftp server directory. In the pmon's prompt, I > set an IP address then load the program from the server. > > Using pmon's r command, I can't see any change in registers (t0 to t7 set to > 00000000). So is my program really executed? Do I need any kind of > initialization?
In order to learn MIPS Assembly, why not try it in Linux system directly? In Linux, you can use gdb to check what you want easily. Try the following simply example: # File: hello.s -- Say Hello to MIPS Assembly Language Programmer # Author: falcon <wuzhang...@gmail.com>, 2009/01/17 # Ref: # [*] http://www.tldp.org/HOWTO/Assembly-HOWTO/mips.html # [*] MIPS Assembly Language Programmer's Guide # [*] See MIPS Run Linux(second version) # Compile: # $ gcc -o hello hello.s # or # $ as -o hello.o hello.s # $ ld -e main -o hello hello.o .text .globl main main: .set noreorder .cpload $gp # setup the pointer to global data .set reorder # print sth. via sys_write li $a0, 1 # print to standard ouput la $a1, stradr # set the string address lw $a2, strlen # set the string length li $v0, 4004 # index of sys_write: # __NR_write in /usr/include/asm/unistd.h syscall # causes a system call trap. # exit via sys_exit move $a0, $0 # exit status as 0 li $v0, 4001 # index of sys_exit # __NR_exit in /usr/include/asm/unistd.h syscall .rdata stradr: .asciiz "hello, world!\n" strlen: .word . - stradr # current address - the string address # end Regards, Wu Zhangjin -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en.