added load upper immediate (lui) op code
parent
be640f2540
commit
229a7b73fa
51
assembler.rb
51
assembler.rb
|
@ -7,6 +7,7 @@ def zero_fill(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: RENAME TO WORD
|
||||||
def int(i)
|
def int(i)
|
||||||
$bytes.push((i & 0x000000ff),
|
$bytes.push((i & 0x000000ff),
|
||||||
(i & 0x0000ff00) >> 8,
|
(i & 0x0000ff00) >> 8,
|
||||||
|
@ -42,8 +43,27 @@ def nop
|
||||||
int 0x00000000
|
int 0x00000000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# load upper immediate
|
||||||
|
def lui(reg, val)
|
||||||
|
# oooooo ----- ttttt iiiiiiiiiiiiiiii
|
||||||
|
op = 0b001111_00000_00000_0000000000000000
|
||||||
|
op |= (0b11111 & reg) << 16
|
||||||
|
op |= 0xffff & val
|
||||||
|
int op
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# this is a terrible idea and im doing it
|
||||||
|
#$labels = {}
|
||||||
|
#def method_missing(m, *args)
|
||||||
|
# puts m.to_s
|
||||||
|
# super
|
||||||
|
#end
|
||||||
|
|
||||||
$base_addr = 0x80010000 # 0x10000 # 0x80010000
|
$base_addr = 0x80010000 # 0x10000 # 0x80010000
|
||||||
|
|
||||||
|
|
||||||
|
# # # EXE HEADER # # #
|
||||||
string "PS-X EXE"
|
string "PS-X EXE"
|
||||||
zero_fill 0x00f
|
zero_fill 0x00f
|
||||||
int $base_addr # initial pc
|
int $base_addr # initial pc
|
||||||
|
@ -59,19 +79,44 @@ int 0x00000000 # Initial SP/R29 & FP/R30 Offs
|
||||||
zero_fill 0x4b # Reserved for A(43h) Function
|
zero_fill 0x4b # Reserved for A(43h) Function
|
||||||
# Ascii marker would go here
|
# Ascii marker would go here
|
||||||
zero_fill 0x7ff
|
zero_fill 0x7ff
|
||||||
|
$exe_header = $bytes[0..]
|
||||||
|
$bytes = []
|
||||||
|
|
||||||
# code
|
|
||||||
|
|
||||||
|
|
||||||
|
# # # PROGRAM CODE # # #
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
jal $base_addr
|
nop
|
||||||
nop # nop (is always exec'd bc mips)
|
nop
|
||||||
|
nop
|
||||||
|
jmp $base_addr
|
||||||
|
nop
|
||||||
|
|
||||||
|
lui 2, 1
|
||||||
|
|
||||||
|
|
||||||
|
# int 0b101011_00010_00001_01111111_11111111
|
||||||
|
|
||||||
string "this is a test lol"
|
string "this is a test lol"
|
||||||
int 0xFFAAFFAA
|
int 0xFFAAFFAA
|
||||||
|
int 0b001001_11101_11101_11111111_11111111
|
||||||
|
int 0b001000_11101_11101_11111111_11111111
|
||||||
|
|
||||||
|
int 0xAAFFAAFF
|
||||||
|
int 0b001001_00101_00101_11111111_11111111
|
||||||
|
int 0b001000_00101_00101_11111111_11111111
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
zero_fill 0xfff
|
zero_fill 0xfff
|
||||||
|
|
||||||
f = File.new "LOADTHIS.EXE", "wb"
|
f = File.new "LOADTHIS.EXE", "wb"
|
||||||
|
f.write $exe_header.pack("C*")
|
||||||
f.write $bytes.pack("C*")
|
f.write $bytes.pack("C*")
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue