Psudo code for interrupt handler , C/C++ Programming

The rPeANUt simulator provides buffering of the characters that are typed into the terminal. However, this would generally not be the case so if the program did not consume a character before the next one is typed then a character may be lost. So in this next part of the lab you are required to write an interrupt handler for the IO terminal that will capture characters as they are typed and place them in a buffer. The read system call would then read them out of this buffer rather than directly from the device. The psudo code for interrupt handler with a single character buffer:

void iohandler () {

   if (buffcount == 0) {

      buff = getchar();  // no need to poll on the status register

      buffcount = 1;

   } else {

      getchar(); // no room in the buffer so we lost a character!!!

   }

   enableInterrupts();

}

void traphandler ()  {

   enableInterruptes();

   if (R0 == 0) { // read system call

      while (buffcount == 0) ;

      R1 = buff;

      buffcount = 0;

   } else if (R0 == 1) { // write system call

      putchar(R1); // just store R1 to memory location 0xfff0

   }

}

char buff;

int buffcount;

void main() {

   buffcount = 0;

   enableIOterminalInterrupts();  // involves writing to the control register of the IO terminal device.

   char c;

   while (1) {

      c = read();

      write(c);

   }

}

 

Posted Date: 3/8/2013 6:28:15 AM | Location : United States







Related Discussions:- Psudo code for interrupt handler , Assignment Help, Ask Question on Psudo code for interrupt handler , Get Answer, Expert's Help, Psudo code for interrupt handler Discussions

Write discussion on Psudo code for interrupt handler
Your posts are moderated
Related Questions
Create a user-defined data structure (struct) called Node that represents a node within a linked list where the "data" stored in each node is a pointer to a Car object.    a) Wr

Explain each of the algorithms in a way that would be understandable to an intelligent person who is not familiar with programming. You should not use any code (or even pseudo code

I need to create a connection to FIFA Ultimate Team 14, I want to utilize C++ specifically for the reason that that is the language I have the most experience in. There are a co

Polymorphism C++ supports this idea - that different objects do "the right thing "- by function polymorphism and class polymorphism. Poly means many, while morph means form.

This problem familiarizes you with using random numbers in C++. The program is to compute a good approximation of π using a simulation method called "Monte Carlo". The following fi

Objective:  Construct a C program that controls the LCD display, and is capable of displaying strings.  Add functions to the C program that allows more control over the display.


Program to store family members details in C++: #include #include #include struct record {   char name[30];   int age;   char state[40]; }x; //cal

Purpose This assignment is an exercise in implementing the queue ADT using a singly-linked list. This assignment also introduces the concept of templates. Assignment Th

Function Overloading Function overloading is a form of polymorphism. Function overloading facilitates explaining one function having many forms. In other words it facilitates e