mirror of
https://gitlab.com/brendanhaines/cpu.git
synced 2024-12-25 18:46:53 -07:00
remove lots of nop
This commit is contained in:
parent
82cbaba7e5
commit
f6c0fb7da1
135
test/test.S
135
test/test.S
|
@ -9,106 +9,65 @@ _start:
|
|||
|
||||
# lui
|
||||
lui x1, 0xfedcb # x1 = 0xfedcb000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# addi
|
||||
addi x1, x1, 0x789 # x1 = 0xfedcb789
|
||||
addi x2, x0, -1 # x2 = 0xffffffff
|
||||
nop
|
||||
nop
|
||||
addi x3, x1, -0x777 # x3 = 0xfedcb012
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# add
|
||||
add x4, x1, x2 # x4 = 0xfedcb788
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# sub
|
||||
sub x5, x1, x3 # x5 = 0x00000777
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# and
|
||||
and x6, x1, x2 # x6 = 0xfedcb789
|
||||
and x7, x1, x0 # x7 = 0x00000000
|
||||
and x8, x4, x3 # x8 = 0xfedcb000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# or
|
||||
or x9, x1, x2 # x9 = 0xffffffff
|
||||
or x10, x1, x0 # x10 = 0xfedcb789
|
||||
or x11, x4, x3 # x11 = 0x0xfedcb79a
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# xor
|
||||
xor x12, x1, x2 # x12 = 0x01234876
|
||||
xor x13, x1, x1 # x13 = 0x00000000
|
||||
xor x14, x0, x2 # x14 = 0xffffffff
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# andi
|
||||
andi x15, x2, -1348 # x15 = 0xfffffabc -1348 = 0xfffffabc
|
||||
andi x16, x2, 0x123 # x16 = 0x00000123
|
||||
andi x17, x1, -1645 # x17 = 0xfedcb181 -1645 = 0xfffff993
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# ori
|
||||
ori x18, x2, 0x000 # x18 = 0xffffffff
|
||||
ori x19, x0, 0x768 # x19 = 0x768
|
||||
ori x20, x1, 0x7ff # x20 = 0xfedcb7ff
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# xori
|
||||
xori x21, x2, 0x123 # x21 = 0xfffffedc
|
||||
xori x22, x1, 0x788 # x22 = 0xfedcb001
|
||||
xori x23, x0, 0x788 # x23 = 0x00000788
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# slli
|
||||
slli x24, x23, 4 # x24 = 0x00007880
|
||||
slli x25, x2, 1 # x25 = 0xfffffffe
|
||||
slli x26, x2, 63 # x26 = 0x80000000 # NOTE: gcc should not allow this since shamt is only 5 bits. discarding high bit so 63 = 31
|
||||
slli x27, x2, 31 # x27 = 0x80000000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
slli x27, x2, 31 # x27 = 0x80000000
|
||||
|
||||
# srli
|
||||
srli x28, x23, 4 # x28 = 0x00000078
|
||||
srli x29, x2, 1 # x29 = 0x7fffffff
|
||||
srli x30, x2, 63 # x30 = 0x00000001 # NOTE: gcc should not allow this since shamt is only 5 bits. discarding high bit so 63 = 31
|
||||
srli x3, x2, 31 # x3 = 0x00000001
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
srli x3, x2, 31 # x3 = 0x00000001
|
||||
|
||||
# srai
|
||||
srai x4, x23, 4 # x4 = 0x00000078
|
||||
srai x5, x2, 1 # x5 = 0xffffffff
|
||||
srai x6, x2, 63 # x6 = 0xffffffff # NOTE: gcc should not allow this since shamt is only 5 bits. discarding high bit so 63 = 31
|
||||
srai x7, x2, 31 # x7 = 0xffffffff
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
srai x7, x2, 31 # x7 = 0xffffffff
|
||||
|
||||
# sll
|
||||
addi x8, x0, 4 # x8 = 0x00000004
|
||||
|
@ -121,9 +80,6 @@ _start:
|
|||
sll x15, x2, x11 # x15 = 0x80000000 # 31
|
||||
sll x16, x1, x0 # x16 = 0xfedcb789 # 0
|
||||
sll x17, x1, x2 # x17 = 0x80000000 # -1=31
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# srl
|
||||
srl x18, x23, x8 # x18 = 0x00000078 # 4
|
||||
|
@ -132,9 +88,6 @@ _start:
|
|||
srl x21, x2, x11 # x21 = 0x00000001 # 31
|
||||
srl x22, x1, x0 # x22 = 0xfedcb789 # 0
|
||||
srl x24, x1, x2 # x24 = 0x00000001 # -1=31
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# sra
|
||||
sra x25, x23, x8 # x25 = 0x00000078 # 4
|
||||
|
@ -143,28 +96,20 @@ _start:
|
|||
sra x28, x2, x11 # x28 = 0xffffffff # 31
|
||||
sra x29, x1, x0 # x29 = 0xfedcb789 # 0
|
||||
sra x30, x1, x2 # x30 = 0xffffffff # -1=31
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# slti
|
||||
addi x3, x0, 1 # x3 = 0x00000001
|
||||
addi x4, x0, 0x010 # x4 = 0x00000010
|
||||
addi x5, x0, 0x100 # x5 = 0x00000100
|
||||
nop
|
||||
sub x6, x0, x3 # x6 = 0xffffffff
|
||||
sub x7, x0, x4 # x7 = 0xfffffff0
|
||||
sub x8, x0, x5 # x8 = 0xffffff00
|
||||
nop
|
||||
slti x9, x3, 0 # x9 = 0x00000000
|
||||
slti x10, x3, 1 # x10 = 0x00000000
|
||||
slti x11, x3, 2 # x11 = 0x00000001
|
||||
slti x12, x3, -1 # x12 = 0x00000000
|
||||
slti x13, x7, 0 # x13 = 0x00000001
|
||||
slti x14, x7, -17 # x14 = 0x00000000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# sltiu
|
||||
sltiu x15, x3, 0 # x15 = 0x00000000
|
||||
|
@ -173,9 +118,6 @@ _start:
|
|||
sltiu x18, x3, -1 # x18 = 0x00000001 # -1=0xffffffff
|
||||
sltiu x19, x7, 0 # x19 = 0x00000000
|
||||
sltiu x20, x7, -15 # x20 = 0x00000001 # -15=0xfffffff1
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# slt
|
||||
slt x21, x0, x3 # x21 = 0x00000001
|
||||
|
@ -183,9 +125,6 @@ _start:
|
|||
slt x23, x3, x3 # x23 = 0x00000000
|
||||
slt x24, x3, x6 # x24 = 0x00000000
|
||||
slt x25, x6, x3 # x25 = 0x00000001
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# sltu
|
||||
sltu x26, x0, x3 # x26 = 0x00000001
|
||||
|
@ -193,73 +132,42 @@ _start:
|
|||
sltu x28, x3, x3 # x28 = 0x00000000
|
||||
sltu x29, x3, x6 # x29 = 0x00000001
|
||||
sltu x30, x6, x3 # x30 = 0x00000000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# auipc
|
||||
auipc x3, 0 # x3 = pc + 0
|
||||
auipc x4, 3 # x4 = pc + 0x3000
|
||||
auipc x5, 0xfffff # x5 = pc + 0xfffff000
|
||||
# TODO: verify auipc adds and does not concatenate (must have PC>0xfff for this)
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# jal
|
||||
jal x1, test_jalr
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# can I remove nops now?
|
||||
addi x6, x0, 0 # x6 = 0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi x6, x0, 1 # x6 = 1
|
||||
addi x7, x6, 1 # x7 = 2
|
||||
addi x8, x6, 1 # x8 = 2
|
||||
addi x9, x6, 1 # x9 = 2
|
||||
# test1:
|
||||
# # TODO: redo these tests because my nop test messed it up
|
||||
# # beq
|
||||
# addi x30, x0, 1 # x30 = 1
|
||||
# addi x9, x8, 0 # x9 == x8
|
||||
# bne x0, x0, fail # 0 == 0
|
||||
# bne x9, x8, fail # x9 == x8
|
||||
# bne x7, x8, test2 # x7 != x8
|
||||
# j fail
|
||||
|
||||
test1:
|
||||
# TODO: redo these tests because my nop test messed it up
|
||||
# beq
|
||||
addi x30, x0, 1 # x30 = 1
|
||||
addi x9, x8, 0 # x9 == x8
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
bne x0, x0, fail # 0 == 0
|
||||
bne x9, x8, fail # x9 == x8
|
||||
bne x7, x8, test2 # x7 != x8
|
||||
j fail
|
||||
# test2:
|
||||
# # beq
|
||||
# addi x30, x0, 2 # x30 = 2
|
||||
# beq x0, x8, fail # 0 != x8
|
||||
# beq x7, x8, fail # x7 != x8
|
||||
# beq x8, x9, test3 # x8 == x9
|
||||
# j fail
|
||||
|
||||
test2:
|
||||
# beq
|
||||
addi x30, x0, 2 # x30 = 2
|
||||
beq x0, x8, fail # 0 != x8
|
||||
beq x7, x8, fail # x7 != x8
|
||||
beq x8, x9, test3 # x8 == x9
|
||||
j fail
|
||||
|
||||
test3:
|
||||
# test3:
|
||||
|
||||
|
||||
# counter and infinite loop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi x31, x0, 1 # x1 = 1
|
||||
|
||||
loop:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi x31, x31, 1 # increment x1
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jal x1, loop # loop forever
|
||||
addi x2, x0, 0 # NOTE: this should never be executed
|
||||
addi x3, x0, 0 # NOTE: this should never be executed
|
||||
|
@ -279,9 +187,6 @@ test_jalr:
|
|||
jalr x0, x1, 0 # return
|
||||
|
||||
fail:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jal x0, fail # loop forever
|
||||
nop
|
||||
nop
|
||||
|
|
Loading…
Reference in New Issue
Block a user