Lab Exercises ‐ Investigate and Explore
Por: balanar • 7/7/2015 • Trabalho acadêmico • 1.033 Palavras (5 Páginas) • 650 Visualizações
Lab Exercises ‐ Investigate and Explore
The lab investigations are a series of exercises that are designed to demonstrate the various aspects of IO interrupt handling.
Exercise 1
Describe what interrupt vectors are and explain how they are used in the compiler window, check only the boxes Generate code, Enable optimizer and Redundant Code. Enter the following source code and compile it:
Resposta:
O vetor de interrupções é uma tabela de endereços de memória que apontam para as rotinas de tratamento de interrupção. Quando uma interrupção é gerada, o processador salva o seu estado atual e começa a executar o tratamento de interrupção apontado pelo vetor. Sendo que os vetores de interrupção da janela do simulador representam a parte do hardware do CPU que armazenam os diversos endereços de rotina da interrupção.
In the compiler window, check only the boxes Generate code, Enable optimizer and Redundant Code. Enter the following source code and compile it:
[pic 1]
In the compiled code window locate the subroutines IntVect1, IntVect2 and IntVect5. Make a note of the starting addresses of these subroutines below:
Subroutine | Starting address |
IntVect1 | 0 |
IntVect2 | 20 |
IntVect5 | 40 |
Conforme ilustra a Figura 1.
[pic 2]
Figura 1 – Starting Addres de IntVect1, IntVect2 e IntVect3.
Next, do the following:
1. Load the code generated in CPU memory.
2. Click on the INTERRUPTS… button to view the INTERRUPT VECTORS window.
3. Make a note of the numbers displayed in text boxes next to INT1, INT2 and INT5.
Note: The INTERRUPT VECTORS window in the simulator represents that part of the CPU hardware that stores the various interrupt routine addresses.
Interrupt | Valor |
INT1 | 0 |
INT2 | 20 |
INT5 | 40 |
Conforme ilustra a Figura 2.
[pic 3]
Compare the two tables above and enter a brief comment on your observation in the space below:
Resposta:
Observando as duas tabelas notamos que o resultado é o mesmo. Já que o vetor de interrupção é uma tabela de endereços que aponta para as rotinas de tratamento de interrupção. No caso as sub-rotinas IntVect1, IntVect2 e IntVect5.
Now, follow the instructions below:
1. Click on the INPUT OUTPUT… button to view the console window.
2. Select Stay on top boxes both in the console and the interrupt vectors windows.
3. Reset the Vectors program and run it at the fastest speed.
4. While the program is running, click TRIGGER buttons in the interrupts window against INT1, INT2 and INT5 one after the other.
5. Observe the messages displayed on the console. Comment on your observations:
Tip: If you run the program at a slow pace (speed slider down), you should be able to see the effects of clicking on the TRIGGER buttons.
Comment on your observations in the space below:
Resposta:
Quando o trigger do int1 é ativado a subrotina IntVect1 intr 1 é executada, o mesmo acontece para IntVect2 e IntVect5. Ou seja, cada vez que usamos o trigger ativamos uma interrupção. Como os triggers foram ativados na ordem Int1, Int2 e Int5, temos o seguinte resultado:
[pic 4]
Exercise 2
Describe two main methods of interrupt handling
Enter the following source code in a new source editor and compile it.
[pic 5]
Notes:
- The nowait keyword in the read statement makes sure the program is not suspended while waiting for an input.
- If there is no input, the value of the variable v will remain unchanged.
- The break * statement takes the program out of the outermost loop which in this case is the while loop.
So, now, briefly explain what the above program is doing (note where the read statement is in this case)
Resposta:
O programa aguarda uma entrada de dados, enquanto ela não ocorre ele escreve “Program Starting....”. Quando finalmente o usuário digita algum valor ocorre uma interrupção e o programa exibe a mensagem “Program Ending”.
Next, follow the instructions below:
1. Load the code generated in CPU memory.
2. Set the speed of simulation to maximum.
3. Bring the console window up (use the INPUT OUTPUT… button).
4. Check the Stay on top check box on the Console
5. Click in the INPUT box on the Console.
...