OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [tags/] [eco32-0.23/] [binutils/] [tests-2/] [intrpt/] [intrpt.s] - Diff between revs 7 and 157

Only display areas with differences | Details | Blame | View Log

Rev 7 Rev 157
;
;
; intrpt.s -- a first attempt to utilize interrupts
; intrpt.s -- a first attempt to utilize interrupts
;
;
 
 
        .set    stack,0xC0010000        ; stack
        .set    stack,0xC0010000        ; stack
        .set    timerbase,0xF0000000    ; timer base address
        .set    timerbase,0xF0000000    ; timer base address
        .set    termbase,0xF0300000     ; terminal base address
        .set    termbase,0xF0300000     ; terminal base address
 
 
reset:
reset:
        j       start           ; reset arrives here
        j       start           ; reset arrives here
 
 
intrpt:
intrpt:
        j       isr             ; interrupts arrive here
        j       isr             ; interrupts arrive here
 
 
userMiss:
userMiss:
        j       userMiss        ; user TLB miss exceptions arrive here
        j       userMiss        ; user TLB miss exceptions arrive here
 
 
isr:
isr:
        mvfs    $26,0            ; determine cause
        mvfs    $26,0            ; determine cause
        slr     $26,$26,14      ; $26 = 4 * IRQ number
        slr     $26,$26,14      ; $26 = 4 * IRQ number
        and     $26,$26,0x1F << 2
        and     $26,$26,0x1F << 2
        ldw     $26,$26,irqsrv  ; get addr of service routine
        ldw     $26,$26,irqsrv  ; get addr of service routine
        jr      $26             ; jump to service routine
        jr      $26             ; jump to service routine
 
 
start:
start:
        add     $29,$0,stack     ; set sp
        add     $29,$0,stack     ; set sp
        add     $4,$0,runmsg     ; pointer to string
        add     $4,$0,runmsg     ; pointer to string
        jal     msg             ; show string
        jal     msg             ; show string
        add     $8,$0,timerbase  ; program timer
        add     $8,$0,timerbase  ; program timer
        add     $9,$0,1000       ; divisor = 1000
        add     $9,$0,1000       ; divisor = 1000
        stw     $9,$8,4
        stw     $9,$8,4
        add     $9,$0,2          ; enable timer interrupts
        add     $9,$0,2          ; enable timer interrupts
        stw     $9,$8,0
        stw     $9,$8,0
        mvfs    $8,0
        mvfs    $8,0
        or      $8,$8,1 << 14   ; open timer IRQ mask bit
        or      $8,$8,1 << 14   ; open timer IRQ mask bit
        or      $8,$8,1 << 23   ; enable processor interrupts
        or      $8,$8,1 << 23   ; enable processor interrupts
        or      $8,$8,1 << 27   ; let vector point to RAM
        or      $8,$8,1 << 27   ; let vector point to RAM
        mvts    $8,0
        mvts    $8,0
start1:
start1:
        j       start1          ; loop
        j       start1          ; loop
 
 
tmrisr:
tmrisr:
        add     $8,$0,0x02       ; ien = 1, int = 0
        add     $8,$0,0x02       ; ien = 1, int = 0
        stw     $8,$0,timerbase
        stw     $8,$0,timerbase
        j       shmsg
        j       shmsg
 
 
shmsg:
shmsg:
        mvfs    $8,0
        mvfs    $8,0
        slr     $8,$8,14        ; $8 = 4 * IRQ number
        slr     $8,$8,14        ; $8 = 4 * IRQ number
        and     $8,$8,0x1F << 2
        and     $8,$8,0x1F << 2
        ldw     $4,$8,msgtbl    ; get addr of message
        ldw     $4,$8,msgtbl    ; get addr of message
        jal     msg             ; show message
        jal     msg             ; show message
        rfx                     ; return from exception
        rfx                     ; return from exception
 
 
msg:
msg:
        sub     $29,$29,8       ; save registers
        sub     $29,$29,8       ; save registers
        stw     $31,$29,4
        stw     $31,$29,4
        stw     $16,$29,0
        stw     $16,$29,0
        add     $16,$4,$0        ; get pointer
        add     $16,$4,$0        ; get pointer
msg1:
msg1:
        ldbu    $4,$16,0 ; get char
        ldbu    $4,$16,0 ; get char
        beq     $4,$0,msg2       ; null - finished
        beq     $4,$0,msg2       ; null - finished
        jal     out             ; output char
        jal     out             ; output char
        add     $16,$16,1       ; bump pointer
        add     $16,$16,1       ; bump pointer
        j       msg1            ; next char
        j       msg1            ; next char
msg2:
msg2:
        ldw     $16,$29,0        ; restore registers
        ldw     $16,$29,0        ; restore registers
        ldw     $31,$29,4
        ldw     $31,$29,4
        add     $29,$29,8
        add     $29,$29,8
        jr      $31             ; return
        jr      $31             ; return
 
 
out:
out:
        add     $8,$0,termbase   ; set I/O base address
        add     $8,$0,termbase   ; set I/O base address
out1:
out1:
        ldw     $9,$8,8         ; get status
        ldw     $9,$8,8         ; get status
        and     $9,$9,1         ; xmtr ready?
        and     $9,$9,1         ; xmtr ready?
        beq     $9,$0,out1       ; no - wait
        beq     $9,$0,out1       ; no - wait
        stw     $4,$8,12        ; send char
        stw     $4,$8,12        ; send char
        jr      $31             ; return
        jr      $31             ; return
 
 
; service routine table
; service routine table
 
 
irqsrv:
irqsrv:
        .word   shmsg           ; 00: terminal 0 transmitter interrupt
        .word   shmsg           ; 00: terminal 0 transmitter interrupt
        .word   shmsg           ; 01: terminal 0 receiver interrupt
        .word   shmsg           ; 01: terminal 0 receiver interrupt
        .word   shmsg           ; 02: terminal 1 transmitter interrupt
        .word   shmsg           ; 02: terminal 1 transmitter interrupt
        .word   shmsg           ; 03: terminal 1 receiver interrupt
        .word   shmsg           ; 03: terminal 1 receiver interrupt
        .word   shmsg           ; 04: keyboard interrupt
        .word   shmsg           ; 04: keyboard interrupt
        .word   shmsg           ; 05: unused
        .word   shmsg           ; 05: unused
        .word   shmsg           ; 06: unused
        .word   shmsg           ; 06: unused
        .word   shmsg           ; 07: unused
        .word   shmsg           ; 07: unused
        .word   shmsg           ; 08: disk interrupt
        .word   shmsg           ; 08: disk interrupt
        .word   shmsg           ; 09: unused
        .word   shmsg           ; 09: unused
        .word   shmsg           ; 10: unused
        .word   shmsg           ; 10: unused
        .word   shmsg           ; 11: unused
        .word   shmsg           ; 11: unused
        .word   shmsg           ; 12: unused
        .word   shmsg           ; 12: unused
        .word   shmsg           ; 13: unused
        .word   shmsg           ; 13: unused
        .word   tmrisr          ; 14: timer interrupt
        .word   tmrisr          ; 14: timer interrupt
        .word   shmsg           ; 15: unused
        .word   shmsg           ; 15: unused
        .word   shmsg           ; 16: bus timeout exception
        .word   shmsg           ; 16: bus timeout exception
        .word   shmsg           ; 17: illegal instruction exception
        .word   shmsg           ; 17: illegal instruction exception
        .word   shmsg           ; 18: privileged instruction exception
        .word   shmsg           ; 18: privileged instruction exception
        .word   shmsg           ; 19: divide instruction exception
        .word   shmsg           ; 19: divide instruction exception
        .word   shmsg           ; 20: trap instruction exception
        .word   shmsg           ; 20: trap instruction exception
        .word   shmsg           ; 21: TLB miss exception
        .word   shmsg           ; 21: TLB miss exception
        .word   shmsg           ; 22: TLB write exception
        .word   shmsg           ; 22: TLB write exception
        .word   shmsg           ; 23: TLB invalid exception
        .word   shmsg           ; 23: TLB invalid exception
        .word   shmsg           ; 24: illegal address exception
        .word   shmsg           ; 24: illegal address exception
        .word   shmsg           ; 25: privileged address exception
        .word   shmsg           ; 25: privileged address exception
        .word   shmsg           ; 26: unused
        .word   shmsg           ; 26: unused
        .word   shmsg           ; 27: unused
        .word   shmsg           ; 27: unused
        .word   shmsg           ; 28: unused
        .word   shmsg           ; 28: unused
        .word   shmsg           ; 29: unused
        .word   shmsg           ; 29: unused
        .word   shmsg           ; 30: unused
        .word   shmsg           ; 30: unused
        .word   shmsg           ; 31: unused
        .word   shmsg           ; 31: unused
 
 
; message table
; message table
 
 
msgtbl:
msgtbl:
        .word   xmtmsg          ; 00: terminal 0 transmitter interrupt
        .word   xmtmsg          ; 00: terminal 0 transmitter interrupt
        .word   rcvmsg          ; 01: terminal 0 receiver interrupt
        .word   rcvmsg          ; 01: terminal 0 receiver interrupt
        .word   xmtmsg          ; 02: terminal 1 transmitter interrupt
        .word   xmtmsg          ; 02: terminal 1 transmitter interrupt
        .word   rcvmsg          ; 03: terminal 1 receiver interrupt
        .word   rcvmsg          ; 03: terminal 1 receiver interrupt
        .word   kbdmsg          ; 04: keyboard interrupt
        .word   kbdmsg          ; 04: keyboard interrupt
        .word   uimsg           ; 05: unused
        .word   uimsg           ; 05: unused
        .word   uimsg           ; 06: unused
        .word   uimsg           ; 06: unused
        .word   uimsg           ; 07: unused
        .word   uimsg           ; 07: unused
        .word   dskmsg          ; 08: disk interrupt
        .word   dskmsg          ; 08: disk interrupt
        .word   uimsg           ; 09: unused
        .word   uimsg           ; 09: unused
        .word   uimsg           ; 10: unused
        .word   uimsg           ; 10: unused
        .word   uimsg           ; 11: unused
        .word   uimsg           ; 11: unused
        .word   uimsg           ; 12: unused
        .word   uimsg           ; 12: unused
        .word   uimsg           ; 13: unused
        .word   uimsg           ; 13: unused
        .word   tmrmsg          ; 14: timer interrupt
        .word   tmrmsg          ; 14: timer interrupt
        .word   uimsg           ; 15: unused
        .word   uimsg           ; 15: unused
        .word   btmsg           ; 16: bus timeout exception
        .word   btmsg           ; 16: bus timeout exception
        .word   iimsg           ; 17: illegal instruction exception
        .word   iimsg           ; 17: illegal instruction exception
        .word   pimsg           ; 18: privileged instruction exception
        .word   pimsg           ; 18: privileged instruction exception
        .word   dimsg           ; 19: divide instruction exception
        .word   dimsg           ; 19: divide instruction exception
        .word   timsg           ; 20: trap instruction exception
        .word   timsg           ; 20: trap instruction exception
        .word   msmsg           ; 21: TLB miss exception
        .word   msmsg           ; 21: TLB miss exception
        .word   wrmsg           ; 22: TLB write exception
        .word   wrmsg           ; 22: TLB write exception
        .word   ivmsg           ; 23: TLB invalid exception
        .word   ivmsg           ; 23: TLB invalid exception
        .word   iamsg           ; 24: illegal address exception
        .word   iamsg           ; 24: illegal address exception
        .word   pamsg           ; 25: privileged address exception
        .word   pamsg           ; 25: privileged address exception
        .word   uemsg           ; 26: unused
        .word   uemsg           ; 26: unused
        .word   uemsg           ; 27: unused
        .word   uemsg           ; 27: unused
        .word   uemsg           ; 28: unused
        .word   uemsg           ; 28: unused
        .word   uemsg           ; 29: unused
        .word   uemsg           ; 29: unused
        .word   uemsg           ; 30: unused
        .word   uemsg           ; 30: unused
        .word   uemsg           ; 31: unused
        .word   uemsg           ; 31: unused
 
 
; sign-on message
; sign-on message
 
 
runmsg:
runmsg:
        .byte   "system running..."
        .byte   "system running..."
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
; interrupt messages
; interrupt messages
 
 
uimsg:
uimsg:
        .byte   "unknown interrupt"
        .byte   "unknown interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
xmtmsg:
xmtmsg:
        .byte   "terminal transmitter interrupt"
        .byte   "terminal transmitter interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
rcvmsg:
rcvmsg:
        .byte   "terminal receiver interrupt"
        .byte   "terminal receiver interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
kbdmsg:
kbdmsg:
        .byte   "keyboard interrupt"
        .byte   "keyboard interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
dskmsg:
dskmsg:
        .byte   "disk interrupt"
        .byte   "disk interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
tmrmsg:
tmrmsg:
        .byte   "timer interrupt"
        .byte   "timer interrupt"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
; exception messages
; exception messages
 
 
uemsg:
uemsg:
        .byte   "unknown exception"
        .byte   "unknown exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
btmsg:
btmsg:
        .byte   "bus timeout exception"
        .byte   "bus timeout exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
iimsg:
iimsg:
        .byte   "illegal instruction exception"
        .byte   "illegal instruction exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
pimsg:
pimsg:
        .byte   "privileged instruction exception"
        .byte   "privileged instruction exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
dimsg:
dimsg:
        .byte   "divide instruction exception"
        .byte   "divide instruction exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
timsg:
timsg:
        .byte   "trap instruction exception"
        .byte   "trap instruction exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
msmsg:
msmsg:
        .byte   "TLB miss exception"
        .byte   "TLB miss exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
wrmsg:
wrmsg:
        .byte   "TLB write exception"
        .byte   "TLB write exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
ivmsg:
ivmsg:
        .byte   "TLB invalid exception"
        .byte   "TLB invalid exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
iamsg:
iamsg:
        .byte   "illegal address exception"
        .byte   "illegal address exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
pamsg:
pamsg:
        .byte   "privileged address exception"
        .byte   "privileged address exception"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.