Some generic bug fixes

This commit is contained in:
2022-11-14 15:28:05 +01:00
parent 15f51c1793
commit acd1679ef9
8 changed files with 191 additions and 49 deletions

120
programs/assignment2isr_.prog Executable file
View File

@@ -0,0 +1,120 @@
reset:
br always >main
nop
hardfault:
reti
nop
memfault:
reti
nop
irq3:
br always >irq3_handler
nop
.align
addr:
.word 0x000F0000
addrsw:
.word 0x000F0006
//w_cnt_top: .word 0x1FC000
w_cnt_top: .word 0x1 //for simulation only
// Constant Declaration
.align
sp_init: .word 0x400 // Stackpointer Initial Value
main:
ldr r12, >sp_init
clr r14
ldr r0,>addr //LED addr
ldr r2,>addrsw //sw addr
addi r6,8 //outer counter top
clr r7 //wait counter
here:
nop
nop
nop
br always >here
nop
out_loop:
ldr r8,>w_cnt_top
clr r1
st08 r0,r1
call >wait
nop
fill:
lsh r1,r1,1
addi r1,1
st08 r0,r1
call >wait
nop
addi r5,1
cmp neq r5,r6
br true >fill
nop
clr r5
flush:
lsh r1,r1,1
st08 r0,r1
call >wait
nop
addi r5,1
cmp neq r5,r6
br true >flush
nop
clr r5
br always >out_loop
nop
//subroutine to iterate until counter overflow
wait:
clr r3
ld16 r3,r2 //loading switches content to r3 from r2 address
clr r9
clr r10
clr r11
br always >nfound
nop
found: rsh r8,r8,1 //one found
nfound: clr r4
addi r4,1
addi r10,1 //loop counter max 16
and r9,r3,r4
cmp eq r9,r4
br true >found
rsh r3,r3,1
clr r4
addi r4,16
cmp le r10,r4
br true >nfound
nop
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
irq3_handler:
br always >out_loop
nop
reti

View File

@@ -10,8 +10,9 @@ nop
.align
segment_addr: .word 0x000F00A0
// w_cnt_top: .word 0xFFC000
w_cnt_top: .word 0x100 //for simulation only
w_cnt_top: .word 0xFFC000
// w_cnt_top: .word 0x100 //for simulation only
write_and_shift:
.word 0x01000100
@@ -112,7 +113,7 @@ number_loop:
// 0xDEADBEEF pattern:
clr r4
addi r4, 0xD
addi r4, 0xF
or r4, r4, r1
st32 r0, r4
@@ -122,12 +123,7 @@ number_loop:
st32 r0, r4
clr r4
addi r4, 0xA
or r4, r4, r1
st32 r0, r4
clr r4
addi r4, 0xD
addi r4, 0xE
or r4, r4, r1
st32 r0, r4
@@ -137,7 +133,12 @@ number_loop:
st32 r0, r4
clr r4
addi r4, 0xE
addi r4, 0xD
or r4, r4, r1
st32 r0, r4
clr r4
addi r4, 0xA
or r4, r4, r1
st32 r0, r4
@@ -147,7 +148,7 @@ number_loop:
st32 r0, r4
clr r4
addi r4, 0xF
addi r4, 0xD
or r4, r4, r1
st32 r0, r4

View File

@@ -9,6 +9,8 @@ reti
nop
.align
led_addr: .word 0x000F0000
number_array0:
.word 0x03020100
number_array1:
@@ -20,17 +22,24 @@ number_array3:
segment_addr0: .word 0x000F00A0
segment_addr1: .word 0x000F00A4
// w_cnt_top: .word 0xFFC000
w_cnt_top: .word 0x100 //for simulation only
random_value: .word 0xAA
w_cnt_top: .word 0xFFFFFF // for real board
// w_cnt_top: .word 0x100 //for simulation only
infamous_pattern0:
.word 0x0D0E0A0D
.word 0x0F0E0E0B
infamous_pattern1:
.word 0x0B0E0E0F
.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

View File

@@ -22,7 +22,9 @@ dmem_start_addr: .word 0x00000400
dmem_end_addr: .word 0x000004FC
priority_mask: .word 0xFFFFFF03
// timer_target_value: .word 127 // for simulation
timer_target_value: .word 65536 // for real board
timer_target_value: .word 0xF10000 // for real board
random_value: .word 0xFF
random_value2: .word 0xAA
main:
// Initialize stack pointer to the end of the data memory
@@ -51,11 +53,19 @@ main:
addi r2, 0x3 // enable and repeat bit set
st32 r1, r2
// Set LEDs to some value
ldr r4, >random_value
st08 r0, r4
loop:
br >loop
nop
timer_interrupt_handler:
// Set LEDs to some value too see if handler is triggered
ldr r4, >random_value2
st08 r0, r4
clr r10
addi r10, 1
cmp eq r9, r10