Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 2017 Vincent Åström, William Åkerman
- .macro PUSH reg
- addi $sp, $sp, -4
- sw \reg, 0($sp)
- .endm
- .macro POP reg
- lw \reg, 0($sp)
- addi $sp, $sp, 4
- .endm
- .data
- .global main
- .global user_isr
- .globl loop
- .text
- init:
- PUSH $t0
- li $t0, 0x0
- li $s0, 0x0 # lines = 0
- li $s4, 0xc0 # pixel data
- sb $t0, 0xbf886100 # TRISE = 0x0
- sb $t0, 0xbf886110 # PORTE = 0x0
- sw $t0, 0xbf800800 # T2CON = 0x0
- sw $t0, 0xbf800810 # TMR2 = 0x0
- li $t0, 1820
- sw $t0, 0xbf800820 # PR2 = 1820
- li $t0, 0x8000
- sw $t0, 0xbf800808 # T2CONSET = 0x8000
- li $t0, 0x100
- sw $t0, 0xbf881060 # IEC0 = 0x100
- li $t0, 0x4
- sw $t0, 0xbf8810b0 # IPC2 = 0x4
- ei # enable interrupts globally
- POP $t0
- jr $ra
- nop
- # ----- ----- ----- ----- -----
- main:
- jal init
- nop
- li $t1, 0x0
- loop:
- addi $t1, $t1, 1
- blt $s0, 300, cyan
- nop
- j stuck
- nop
- cyan:
- blt $t1, 40, red
- nop
- li $s4, 0xfc
- j loop
- nop
- red:
- li $s4, 0xc3
- j stuck
- nop
- stuck:
- j stuck
- nop
- #starto: bne $s4, 0xff, incr
- # nop
- # li $t8, 0x0
- # loop2:
- # addi $t8, $t8, 0x1
- # bne $t8, 0x10000, loop2
- # nop
- # li $s4, 0xc0
- # j starto
- # nop
- #incr:
- # li $t8, 0x0
- #loop1:
- # addi $t8, $t8, 0x1
- # bne $t8, 0x10000, loop1
- # nop
- # addi $s4, $s4, 0x1
- # j starto
- # nop
- # ----- ----- ----- ----- -----
- user_isr:
- PUSH $t0
- blt $s0, 480, r0
- nop
- blt $s0, 491, r1
- nop
- blt $s0, 493, r2
- nop
- blt $s0, 524, r1
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- ls40:
- addi $t0, 0x1
- bne $t0, 40, ls40
- nop
- li $t0, 0x80
- sb $t0, 0xbf886110 # PORTE = 0x80
- li $t0, 0x0
- ls41:
- addi $t0, 0x1
- bne $t0, 80, ls41
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- ls42:
- addi $t0, 0x1
- bne $t0, 40, ls42
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $s0, 0 # lines = 0
- j endif
- nop
- # ----- ----- ----- ----- -----
- r0:
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- l00:
- addi $t0, 0x1
- bne $t0, 40, l00
- nop
- li $t0, 0x80
- sb $t0, 0xbf886110 # PORTE = 0x80
- li $t0, 0x0
- l01:
- addi $t0, 0x1
- bne $t0, 80, l01
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- l02:
- addi $t0, 0x1
- bne $t0, 40, l02
- nop
- li $t0, 0xf0 # 5
- sb $s4, 0xbf886110 # PORTE = 0xc3
- j endif
- nop
- # ----- ----- ----- ----- -----
- r1:
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- l10:
- addi $t0, 0x1
- bne $t0, 40, l10
- nop
- li $t0, 0x80
- sb $t0, 0xbf886110 # PORTE = 0x80
- li $t0, 0x0
- l11:
- addi $t0, 0x1
- bne $t0, 80, l11
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- li $t0, 0x0
- l12:
- addi $t0, 0x1
- bne $t0, 40, l12
- nop
- li $t0, 0xc0
- sb $t0, 0xbf886110 # PORTE = 0xc0
- j endif
- nop
- # ----- ----- ----- ----- -----
- r2:
- li $t0, 0x40
- sb $t0, 0xbf886110 # PORTE = 0x0
- li $t0, 0x0
- l20:
- addi $t0, 0x1
- bne $t0, 40, l20
- nop
- li $t0, 0x0
- sb $t0, 0xbf886110 # PORTE = 0x0
- li $t0, 0x0
- l21:
- addi $t0, 0x1
- bne $t0, 80, l21
- nop
- li $t0, 0x40
- sb $t0, 0xbf886110 # PORTE 0x40
- li $t0, 0x0
- l22:
- addi $t0, 0x1
- bne $t0, 40, l22
- nop
- li $t0, 0x40
- sb $t0, 0xbf886110 # PORTE = 0x40
- j endif
- nop
- # ----- ----- ----- ----- -----
- endif:
- addi $s0, $s0, 1 # lines++
- li $t0, 0x0
- sw $t0, 0xbf800810 # clear TMR2
- sw $t0, 0xbf881030 # clear IFS0
- POP $t0
- jr $ra
- nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement