p1es/main.asm.rb

82 lines
1.3 KiB
Ruby
Raw Permalink Normal View History

# main.asm.rb
$gp0 = 0x1F801810
$gp1 = 0x1F801814
# TODO:
# FIND OUT WHAT WE HAVE TO DO TO REGISTER A VSYNC INTERRUPT
jmp l_start
nop
label :hello_world
string "ello wrld!\n"
label :printf
addiu r0, 0xa0, at # address of bios func
jr at
addiu r0, 0x3f, t1 # printf number
label :draw_line
# todo: draw line function, take args in a0 - a3
# tood: implement shift left so we can use that to combine x and y co-ords
li t0, $gp0
li t1, 0x40_ffffff # monochrome line, color ffffff
sw t1, 0, t0
# lwi st, t1 # line vert 1
sw t1, 0, t0
# lwi en, t1 # line vert 2
sw t1, 0, t0
label :start
nop ; nop ; nop ; nop
# THIS IS NEEDED
li t0, $gp1
li t1, 0x03_00_00_00 # display enable
sw t1, 0, t0
li t0, $gp0
li t1, 0xe1_000000 + 0b0_0_0_1_0_01_00_0_0000
sw t1, 0, t0
# THIS IS NEEDED
li t1, 0xe4_000000 + (640) + (480 << 10) # Drawing Area bottom right
sw t1, 0, t0
def line(st, en)
li t1, 0x40_ffffff # monochrome line, color ffffff
sw t1, 0, t0
li t1, st # line vert 1
sw t1, 0, t0
li t1, en # line vert 2
sw t1, 0, t0
end
line 0x0010_0010, 0x0030_0030
line 0x0030_0030, 0x0060_0000
line 0x0060_000a, 0x00f0_0060
li a0, l_hello_world
jal l_printf
addiu sp, -16, sp # delay slot
addiu sp, 16, sp
label :end_loop
li t9, l_end_loop
jr t9
nop