add test for immediate offsets for lw instruction

This commit is contained in:
Brendan Haines 2020-11-14 23:48:08 -07:00
parent d58661e289
commit a2a85fd10b

View File

@ -146,16 +146,18 @@ test1:
addi x9, x8, 0 # x9 = 0xffffff00
bne x0, x0, fail # 0 == 0
bne x9, x8, fail # x9 == x8
bne x7, x8, test2 # x7 != x8
bne x7, x8, test1_done # x7 != x8
j fail
test1_done:
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
beq x8, x9, test2_done # x8 == x9
j fail
test2_done:
test3:
# blt
@ -163,50 +165,57 @@ test3:
blt x8, x9, fail # x8 == x9
blt x7, x8, fail # x7 > x8
blt x30, x8, fail # x30 > x8
blt x8, x7, test4 # x8 < x7
blt x8, x7, test3_done # x8 < x7
j fail
test3_done:
test4:
# bltu
addi x30, x0, 4 # x30 = 4
bltu x8, x9, fail # x8 == x9
bltu x7, x8, fail # x7 > x8
bltu x30, x8, test5 # x30 < x8 unsigned
bltu x30, x8, test4_done # x30 < x8 unsigned
j fail
test4_done:
test5:
addi x30, x0, 5 # x30 = 5
bltu x8, x7, test6 # x8 < x7
bltu x8, x7, test5_done # x8 < x7
j fail
test5_done:
test6:
# bne
addi x30, x0, 6 # x30 = 6
bne x0, x0, fail # 0 == 0
bne x8, x9, fail # 0 == 0
bne x8, x0, test7 # x8 != 0
bne x8, x0, test6_done # x8 != 0
j fail
test6_done:
test7:
# bge
addi x30, x0, 7 # x30 = 7
bge x8, x7, fail # x8 < x7
bge x7, x7, test8 # x7 == x7
bge x7, x7, test7_done # x7 == x7
j fail
test7_done:
test8:
addi x30, x0, 8 # x30 = 8
bge x8, x0, fail # x8 < 0
bge x7, x8, test9 # x7 > x8
bge x7, x8, test8_done # x7 > x8
j fail
test8_done:
test9:
# bgeu
addi x30, x0, 9 # x30 = 9
bgeu x8, x7, fail # x8 < x7
bgeu x0, x8, fail # 0 < x8 unsigned
bgeu x8, x0, test10 # x8 > 0 unsigned
bgeu x8, x0, test9_done # x8 > 0 unsigned
j fail
test9_done:
test10:
addi x30, x0, 10 # x30 = 10
@ -238,6 +247,8 @@ test10:
nop
nop
nop
bne x12, x10, fail
test10_done:
test11:
addi x30, x0, 11 # x30 = 11
@ -249,7 +260,7 @@ test11_loop:
nop
nop
nop
sw x10, 0(x9) # someint = 0x12345678
sw x10, 0(x9)
addi x10, x10, 1 # x10 = x10 + 1
addi x9, x9, 4 # x9 = x9 + 4
addi x5, x5, 1 # x5 = x5 + 1
@ -268,13 +279,39 @@ test12_loop:
nop
nop
nop
lw x11, 0(x9) # someint = 0x12345678
lw x11, 0(x9)
bne x11, x10, fail
bgt x5, x0, test12_loop
test12_done:
test13:
addi x30, x0, 13 # x30 = 13
addi x8, x9, 4
addi x12, x10, 1
lw x11, 4(x9)
bne x11, x12, fail
addi x8, x9, 8
addi x12, x10, 2
lw x11, 8(x9)
bne x11, x12, fail
addi x8, x9, 0xc
addi x12, x10, 3
lw x11, 0xc(x9)
bne x11, x12, fail
addi x8, x9, 0x10
addi x12, x10, 4
lw x11, 0x10(x9)
bne x11, x12, fail
addi x8, x9, 0x14
addi x12, x10, 5
lw x11, 0x14(x9)
bne x11, x12, fail
test13_done:
done:
lui x30, 0x10101 # x30 = 0x10101000
addi x30, x30, 0x010 # x30 = 0x10101010
# set registers to known values before loop
addi x2, x0, 1 # x1 = 1