1 / 15

Laboratório de Organização e Arquitetura de Computadores

Laboratório de Organização e Arquitetura de Computadores. Interrupção – Conceitos Básicos. PROFESSORES: Elmar Uwe Kurt Melcher Joseana Macêdo Fechine. Boa.c. /* -------------------------------------------------------------------------------------------

inari
Download Presentation

Laboratório de Organização e Arquitetura de Computadores

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. Laboratório de Organização e Arquitetura de Computadores Interrupção – Conceitos Básicos PROFESSORES: Elmar Uwe Kurt Melcher Joseana Macêdo Fechine

  2. Boa.c /* ------------------------------------------------------------------------------------------- Fractal com captura da interrupcao do mouse ------------------------------------------------------------------------------------------*/ #include <stdio.h> /*** definicoes de macros ***/ // ler de uma porta de I/O #define inpb(p) asm { in al,p } // escrever para porta de I/O #define outb(p,v) asm { mov al,v; out p,al } // instrucao End of Interrupt para o PIC (Programmable Interrupt Controller) #define EOI1 outb(0x20,0x20) // PIC 1 #define EOI2 outb(0xA0,0x20) // PIC 2 /*** struct and type declarations ***/ typedef unsigned char byte; typedef unsigned short word; typedef unsigned int dword; Lab. Org. e Arq. de Computadores - DSC-UFCG

  3. Boa.c /**** variaveis globais ****/ struct dtr idtr; byte *tela = (byte *)0xE0000000; // endereco da RAM de video /*** declaracoes de referencias externas e internas ***/ extern void cadastrar(int matricula); extern void initializar(); // modo de video grafico #define NLINHAS 768 // numero de linhas na tela #define NCOLUNAS 1024 // numero de colunas na tela Lab. Org. e Arq. de Computadores - DSC-UFCG

  4. Boa.c void desenhar_fractal() { /* Calculation of Julia set ------------------------ Written by Kiselev Y. 1994 Definitions of complex numbers: z = x + i*y screen coordinates xini <= x < xini+1024*xstep u = s + i*t parameter \ yini <= y < yini+768*ystep Equation used: f(z) = z^2 - u Iteration: f(z), f(f(z)), f(f(f(z))), ... until |f(...)| > 2 or max_it iterations Result: pixel value at (x,y) is the number of iterations. */ Lab. Org. e Arq. de Computadores - DSC-UFCG

  5. Boa.c int main() { char c; cadastrar(9912345); // coloque aqui sua matricula initializar(5); desenhar_fractal(); c=getchar(); return(0); } Lab. Org. e Arq. de Computadores - DSC-UFCG

  6. Boa.c Exemplo: Trecho de código em Assembly em um programa escrito em C Digite o código abaixo int main() { asm { mov eax,0x1233 add eax,0x22 push eax }; } Lab. Org. e Arq. de Computadores - DSC-UFCG

  7. Boa.c Exemplo: Trecho de código em Assembly em um programa escrito em C Digite o código abaixo int main() { asm { mov byte [0xE0000000], 55 }; } Lab. Org. e Arq. de Computadores - DSC-UFCG

  8. Boa.c Observe os valores: yini=-1.15; xini=-1.55; xini+=0.003; yini+=0.003; // insere aqui a instrucao que escreve na tela Exemplo 1: // escreve pontos na tela tela[0] = 55; tela[100*NCOLUNAS+200]=155; Exemplo 2: //escreve o fractal tela[ypix + xpix] = pix; Lab. Org. e Arq. de Computadores - DSC-UFCG

  9. Boa.c /* descritor de interrupt gate, call gate ou task gate Cada sub-estrutura serve para preencher uma parte dos campos do descritor. Primeiro devem ser preenchidos a.offset e b.offset. */ union gate { struct { // O item n nao deve ser usado. dword offset; byte params; byte type; } a; struct { word n; word selector; dword offset; } b; }; Lab. Org. e Arq. de Computadores - DSC-UFCG

  10. Boa.c typedef union gate *gate_ptr; /* IDTR e GDTR */ struct dtr { word length; gate_ptr base; }; /**** variaveis globais ****/ struct dtr idtr; Lab. Org. e Arq. de Computadores - DSC-UFCG

  11. Boa.c – Novas Funcoes Interrupção – mouse Opção 1: void interrupt() { tela[200]=~tela[200]; } Opção 2 _interrupt void interrupt() { tela[200]=~tela[200]; } Lab. Org. e Arq. de Computadores - DSC-UFCG

  12. Boa.c – Novas Funções void setInterrupcao() { asm sidt[idtr]; idtr.base[116].a.offset = &interrupt; // ^ ^ ^ ^ // | | | endereço da rotina de atendimento // | | | // | | descritor da interrupção do mouse // | | // | endereço de inicio da IDT // | // conteudo do registrador IDTR da CPU idtr.base[116].b.offset = &interrupt; idtr.base[116].b.selector = 0x928; idtr.base[116].a.params = 0; idtr.base[116].a.type = 0xEE; } Lab. Org. e Arq. de Computadores - DSC-UFCG

  13. Boa.c int main() { char c; cadastrar(9912345); // coloque aqui sua matricula initializar(5); setInterrupcao(); //setar interrupcao desenhar_fractal(); c=getchar(); return(0); } Lab. Org. e Arq. de Computadores - DSC-UFCG

  14. Boa.c int mouse () { // retorna "true" se tem um byte para ser lido inpb(0x64); //porta de status return _EAX & 1; } void queijo() { // entrega queijo para mouse PS/2 (tambem chamado mouse IBM) while(mouse()) { inpb(0x60); // lˆ byte transmitido pelo dispositivo porta de dados EOI2; } EOI1; } Lab. Org. e Arq. de Computadores - DSC-UFCG

  15. Boa.c – Novas Funções _interrupt void interrupt() { queijo(); tela[200]=~tela[200]; } Lab. Org. e Arq. de Computadores - DSC-UFCG

More Related