addled shift right logical (srl)
parent
97b12551e5
commit
53c69e77a9
34
assembler.rb
34
assembler.rb
|
@ -51,6 +51,16 @@ def lui(reg, val)
|
|||
word op
|
||||
end
|
||||
|
||||
# shift right logical
|
||||
def srl(src, amt, dest)
|
||||
# oooooo ----- sssss ddddd hhhhh oooooo
|
||||
op = 0b000000_00000_00000_00000_00000_000010
|
||||
op |= (src & 0b11111) << 16
|
||||
op |= (amt & 0b11111) << 6
|
||||
op |= (dest & 0b11111) << 11
|
||||
word op
|
||||
end
|
||||
|
||||
|
||||
# this is a terrible idea and im doing it
|
||||
#$labels = {}
|
||||
|
@ -59,7 +69,11 @@ end
|
|||
# super
|
||||
#end
|
||||
|
||||
|
||||
|
||||
# # # CONSTANTS # # #
|
||||
$base_addr = 0x80010000 # 0x10000 # 0x80010000
|
||||
$file_size = 0x800
|
||||
|
||||
|
||||
# # # EXE HEADER # # #
|
||||
|
@ -68,7 +82,7 @@ zero_fill 0x00f
|
|||
word $base_addr # initial pc
|
||||
word 0x00000000 # initial GP/R28
|
||||
word $base_addr # destintation address in RAM
|
||||
word 0x800 # file size excluding header (must be N * 0x800)
|
||||
word $file_size # file size excluding header (must be N * 0x800)
|
||||
word 0x00000000 # Unknown/Unused
|
||||
word 0x00000000 # Unknown/Unused
|
||||
word 0x00000000 # Memfill start address
|
||||
|
@ -87,16 +101,28 @@ $bytes = []
|
|||
# # # PROGRAM CODE # # #
|
||||
nop
|
||||
nop
|
||||
|
||||
lui 2, 0
|
||||
lui 3, 0
|
||||
|
||||
|
||||
lui 2, 1
|
||||
nop
|
||||
|
||||
srl 2, 14, 3
|
||||
srl 2, 1, 6
|
||||
nop
|
||||
|
||||
nop
|
||||
nop
|
||||
jmp $base_addr
|
||||
nop
|
||||
|
||||
lui 2, 1
|
||||
|
||||
|
||||
# int 0b101011_00010_00001_01111111_11111111
|
||||
|
||||
|
||||
|
||||
|
||||
string "this is a test lol"
|
||||
word 0xFFAAFFAA
|
||||
|
@ -112,7 +138,7 @@ word 0b001000_00101_00101_11111111_11111111
|
|||
|
||||
|
||||
|
||||
zero_fill 0xfff
|
||||
zero_fill $file_size - 1
|
||||
|
||||
f = File.new "LOADTHIS.EXE", "wb"
|
||||
f.write $exe_header.pack("C*")
|
||||
|
|
Loading…
Reference in New Issue