--- /dev/null
+obj = test.o
+elf = test.elf
+bin = test.ecoff
+
+TC = mips-none-elf-
+CC = $(TC)gcc
+AS = $(TC)as
+LD = $(TC)ld
+
+ASFLAGS = -mips3 -mabi=32 -mno-abicalls -G 0 -fno-pic
+LDFLAGS = -T o2.ld
+
+$(bin): $(elf)
+ wreckoff $< $@
+
+$(elf): $(obj)
+ $(LD) -o $@ $(obj) $(LDFLAGS)
+
+.PHONY: clean
+clean:
+ rm -f $(obj) $(elf) $(bin)
+
+.PHONY: install
+install: $(elf)
+ cp $(elf) $(bin) /srv/tftp/
+
+#disasm: $(bin)
+# mips-ecoff-objdump -D $< >$@
+#
+disasm: $(elf)
+ $(TC)objdump -D $< >$@
--- /dev/null
+#include "regdefs.h"
+
+ .set noreorder
+ .text
+
+ .equ SPB_FWVEC_ADDR, 0x80001020
+
+ .equ FW_HALT_OFFS, 0x0c
+ .equ FW_RST_INTERACT_OFFS, 0x1c
+ .equ FW_WRITE_OFFS, 0x6c
+
+ .globl _start
+_start:
+ jal print_pc
+ nop
+
+ li a0, 0xbaadf00d
+ jal print_hex
+ nop
+ la t0, buffer
+ li t1, '\n'
+ sb t1, 0(t0)
+ sb zero, 1(t0)
+ la a0, buffer
+ jal printstr
+ nop
+
+
+ la a0, hellostr
+ jal printstr
+ nop
+ la a0, foobar
+ jal printstr
+ nop
+0: b 0b
+ nop
+
+print_pc:
+ addiu sp, sp, -20
+ sw ra, 16(sp)
+
+ la a0, buffer
+ li t1, 'P'
+ sb t1, 0(a0)
+ li t1, 'C'
+ sb t1, 1(a0)
+ li t1, ':'
+ sb t1, 2(a0)
+ sb zero, 3(a0)
+ jal printstr
+ nop
+
+ lw a0, 16(sp)
+ jal print_hex
+ addiu a0, a0, -8 # bd: address of the jal instruction to arg0
+
+ la t0, buffer
+ li t1, '\n'
+ sb t1, 0(t0)
+ sb zero, 1(t0)
+ la a0, buffer
+ jal printstr
+ nop
+
+ lw ra, 16(sp)
+ jr ra
+ addiu sp, sp, 20 # bd
+
+
+print_hex:
+ addiu sp, sp, -20
+ sw ra, 16(sp)
+
+ la t0, buffer
+ li t3, 8 # 8 nibbles to format
+.Ltop:
+ addiu t3, t3, -1
+ sll t1, t3, 2
+ srl t1, a0, t1 # shift to low nibble
+ andi t1, t1, 0xf # and mask off everything above
+ li t2, 9
+ bgt t1, t2, .Lover9
+ nop
+ b .Lstore
+ addiu t1, t1, '0' # bd
+.Lover9:
+ addiu t1, t1, 'A'-10
+
+.Lstore:
+ sb t1, (t0)
+ bne t3, zero, .Ltop
+ addiu t0, t0, 1 # bd
+
+ sb zero, (t0) # zero-terminate
+ la a0, buffer
+ jal printstr
+ nop
+
+ lw ra, 16(sp)
+ jr ra
+ addiu sp, sp, 20 # bd
+
+buffer: .space 64
+
+printstr:
+ addiu sp, sp, -20
+ sw ra, 16(sp)
+
+ # compute string length -> a2
+ move t0, a0
+0: lb t1, (t0)
+ bne t1, zero, 0b
+ addiu t0, t0, 1
+ addiu t0, t0, -1
+ subu a2, t0, a0
+
+ move a1, a0 # buffer pointer
+ li a0, 1 # fd
+ move a3, sp # count pointer
+
+ lw t0, SPB_FWVEC_ADDR
+ addiu t0, t0, FW_WRITE_OFFS
+ lw t0, (t0) # grab the write entry point in t0
+ jal t0
+ nop
+
+ lw ra, 16(sp)
+ jr ra
+ addiu sp, sp, 20 # bd
+
+halt:
+ addiu sp, sp, -20
+ sw ra, 16(sp)
+
+ lw t0, SPB_FWVEC_ADDR
+ addiu t0, t0, FW_HALT_OFFS
+ lw t0, (t0)
+ jal t0
+ nop
+
+ lw ra, 16(sp)
+ jr ra
+ addiu sp, sp, 20
+
+ .data
+hellostr: .asciiz "Hello SGI!\n"
+foobar: .asciiz "This is a test!\n"