1 / 16

MIPS Interrupts

MIPS Interrupts. MIPS interrupts. The materials of this lecture can be found in A7-A8. Also, the slides are developed with the help of http://jjc.hydrus.net/cs61c/handouts/interrupts1.pdf. The MIPS memory . Actually, everything above 0x7fffffff is used by the system. What is in there?.

eulalie
Download Presentation

MIPS Interrupts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MIPS Interrupts

  2. MIPS interrupts • The materials of this lecture can be found in A7-A8. • Also, the slides are developed with the help of http://jjc.hydrus.net/cs61c/handouts/interrupts1.pdf

  3. The MIPS memory • Actually, everything above 0x7fffffff is used by the system.

  4. What is in there? • Special operating system functions • I/O registers mapped to memory addresses • …

  5. SPIM Simulator • SPIM allows you to read from key board (which is similar to reading something from the true I/O register)

  6. trykeyboard.asm .text .globl main main: addu $s7, $ra, $zero, # Save the ra addi $s0, $0, 113 #q addi $t0, $0, 0 lui $t0, 0xFFFF # $t0 = 0xFFFF0000; waitloop: lw $t1, 0($t0) andi $t1, $t1, 0x0001 # $t1 &= 0x00000001; beq $t1, $zero, waitloop lw $a0, 4($t0) beq $a0, $s0, done li $v0,1 syscall li $v0,4 la $a0, new_line syscall j waitloop done: jr $ra add $zero, $zero, $zero #nop add $zero, $zero, $zero #nop .data new_line: .asciiz " " Remember to call SPIM with -mapped_io option

  7. question • Is this the most efficient way to do it? • Remember that the processor usually has a lot of things to do simultaneously

  8. Interrupt • The key problem is that the time when the input occurs cannot be predicted by your program • Wouldn’t it be nice if you could “focus on what you are doing” while be “interrupted” if some inputs come?

  9. MIPS Interrupt

  10. MIPS Interrupt • $k0 and $k1 are both used as temporary variables in interrupt servicing routines. • Coprocessor 0 is also used with interrupts. In Coprocessor 0, registers $8, $12, $13, and $14 are all important in servicing interrupts. • These registers can be read and modified using the instructions mfc0 (move from coprocessor 0) and mtc0 (move to coprocessor 0).

  11. MIPS Interrupt

  12. EPC Register • The EPC register contains the value of the program counter, $pc, at the time of the interrupt. This is where the program will return after handling the interrupt.

  13. .text • .globl main • main: • addu $s7, $ra, $zero, # Save the ra • mfc0 $t0, $12 • ori $t0, 0xff01 • mtc0 $t0, $12 • here: • j here • jr $ra • add $zero, $zero, $zero #nop • add $zero, $zero, $zero #nop • .text 0x80000080 • mfc0 $k0, $13 # $k0 = $Cause; • mfc0 $k1, $14 # $k1 = $EPC; • andi $k0, $k0, 0x003c # $k0 &= 0x003c; // Only keep Exception Code. • bne $k0, $zero, done # if ($k == 0) { // Exception Code 0 is I/O. • addi $t0, $0, 0 • lui $t0, 0xFFFF # $t0 = 0xFFFF0000; • lw $a0, 4($t0) • li $v0,1 • syscall • li $v0,4 • la $a0, new_line • syscall • done: • jr $k1 # return; • .data • new_line: • .asciiz " "

More Related