mirror of
https://gitlab.com/brendanhaines/cpu.git
synced 2024-11-09 21:14:57 -07:00
93 lines
2.0 KiB
ArmAsm
93 lines
2.0 KiB
ArmAsm
|
.global _start
|
||
|
|
||
|
.global addathing
|
||
|
|
||
|
.text
|
||
|
_start:
|
||
|
|
||
|
addi a0, zero, 0x134
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
call addathing
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
addi a1, zero, 0x163 # a1 = a0 + 0x29
|
||
|
|
||
|
|
||
|
done:
|
||
|
la x31, failcode # x30 =
|
||
|
addi x30, x0, 0xff # x31 = 0x000000ff
|
||
|
slli x30, x30, 8 # x31 = 0x0000ff00
|
||
|
addi x30, x30, 0xff # x31 = 0x0000ffff
|
||
|
slli x30, x30, 8 # x31 = 0x00ffff00
|
||
|
addi x30, x30, 0xff # x31 = 0x00ffffff
|
||
|
slli x30, x30, 8 # x31 = 0xffffff00
|
||
|
addi x30, x30, 0xff # x31 = 0xffffffff
|
||
|
# slli x30, x30, 1 # x31 = 0xfffffffe // this should cause a fail
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
sw x30, 0(x31) # failcode = 0xffffffff
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
|
||
|
lui x30, 0x10101 # x30 = 0x10101000
|
||
|
addi x30, x30, 0x010 # x30 = 0x10101010
|
||
|
|
||
|
# set registers to known values before loop
|
||
|
addi x2, x0, 1 # x2 = 1
|
||
|
addi x3, x0, 1 # x3 = 1
|
||
|
addi x4, x0, 1 # x4 = 1
|
||
|
addi x5, x0, 1 # x5 = 1
|
||
|
addi x6, x0, 1 # x6 = 1
|
||
|
|
||
|
|
||
|
fail:
|
||
|
la x31, failcode # x31 =
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
sw x30, 0(x31) # failcode = test number
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
# set some registers to make it blatantly obvious an error occurred
|
||
|
addi x1, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x2, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x3, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x4, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x5, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x6, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x7, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x8, x0, 0x7ff # x1 = 0x1111
|
||
|
addi x9, x0, 0x7ff # x1 = 0x1111
|
||
|
j fail # loop forever
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
nop
|
||
|
|
||
|
|
||
|
.data
|
||
|
failcode:
|
||
|
.word 0x00000000
|
||
|
|
||
|
.bss
|