added or immediate (ori) instruction

master
bx 2021-08-31 10:11:25 +01:00
parent 53c69e77a9
commit 5221fe45d9
1 changed files with 37 additions and 29 deletions

View File

@ -21,6 +21,10 @@ def string(s)
end
end
# # # INSTRUCTIONS # # #
def jmp(addr)
# TODO: this probs wont show up since we have < 3mb of ram but
# we can't jump to an address with a different 4 most significant bits
@ -38,16 +42,13 @@ def jal(addr)
word op
end
def nop
word 0x00000000
end
# load upper immediate
def lui(reg, val)
# NOTE: val will be shifted left by 16
def lui(val, dest)
# oooooo ----- ttttt iiiiiiiiiiiiiiii
op = 0b001111_00000_00000_0000000000000000
op |= (0b11111 & reg) << 16
op |= 0xffff & val
op |= (0b11111 & dest) << 16
word op
end
@ -61,6 +62,26 @@ def srl(src, amt, dest)
word op
end
# or immediate
def ori(src, bits, dest)
# oooooo sssss ddddd iiiiiiii iiiiiiii
op = 0b001101_00000_00000_00000000_00000000
op |= (src & 0b11111) << 21
op |= (bits & 0xffff)
op |= (dest & 0x11111) << 16
word op
end
# # # PSEUDO-INSTRUCTIONS # # #
def nop
word 0x00000000
end
# this is a terrible idea and im doing it
#$labels = {}
@ -70,11 +91,10 @@ end
#end
# # # CONSTANTS # # #
$base_addr = 0x80010000 # 0x10000 # 0x80010000
$file_size = 0x800
$gp0 = 0x1F801810
# # # EXE HEADER # # #
string "PS-X EXE"
@ -99,22 +119,19 @@ $bytes = []
# # # PROGRAM CODE # # #
nop
nop
nop ; jmp $base_addr + 16 ; nop ; word 0xdeadbeef
lui 2, 0
lui 3, 0
# ops should always be in format of
# src [args] -> dest
lui $gp0 >> 16, 1
ori 1, $gp0, 1
lui 2, 1
nop
nop ; nop ; nop ; nop
nop ; nop ; nop ; nop
nop ; nop ; nop ; nop
nop ; nop ; nop ; nop
srl 2, 14, 3
srl 2, 1, 6
nop
nop
nop
jmp $base_addr
nop
@ -125,15 +142,6 @@ nop
string "this is a test lol"
word 0xFFAAFFAA
word 0b001001_11101_11101_11111111_11111111
word 0b001000_11101_11101_11111111_11111111
word 0xAAFFAAFF
word 0b001001_00101_00101_11111111_11111111
word 0b001000_00101_00101_11111111_11111111