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