Files
lt16lab/programs/segments_test.prog
2022-11-14 15:28:05 +01:00

99 lines
1.5 KiB
Plaintext

reset:
br always >main
nop
hardfault:
reti
nop
memfault:
reti
nop
.align
led_addr: .word 0x000F0000
number_array0:
.word 0x03020100
number_array1:
.word 0x07060504
number_array2:
.word 0x0B0A0908
number_array3:
.word 0x0F0E0D0C
segment_addr0: .word 0x000F00A0
segment_addr1: .word 0x000F00A4
random_value: .word 0xAA
w_cnt_top: .word 0xFFFFFF // for real board
// w_cnt_top: .word 0x100 //for simulation only
infamous_pattern0:
.word 0x0F0E0E0B
infamous_pattern1:
.word 0x0D0A0E0D
main:
ldr r8, >w_cnt_top
ldr r0, >led_addr
// Set LEDs to some value
ldr r4, >random_value
st08 r0, r4
number_loop:
// First 4
ldr r4, >number_array0
ldr r0, >segment_addr0
st32 r0, r4
// Second 4
ldr r4, >number_array1
ldr r0, >segment_addr1
st32 r0, r4
call >wait
nop
// First 4
ldr r4, >number_array2
ldr r0, >segment_addr0
st32 r0, r4
// Second 4
ldr r4, >number_array3
ldr r0, >segment_addr1
st32 r0, r4
call >wait
nop
// 0xDEADBEEF pattern:
// First 4
ldr r4, >infamous_pattern0
ldr r0, >segment_addr0
st32 r0, r4
// Second 4
ldr r4, >infamous_pattern1
ldr r0, >segment_addr1
st32 r0, r4
call >wait
nop
br always >number_loop
nop
//subroutine to iterate until counter overflow
wait:
clr r7 //inititalize inner counter
inc_i:
cmp neq r7,r8
br true >inc_i //if i=cnt_top
addi r7,1
ret //else
nop