loading...

CS609 System Programming Assignment 1 Solution Spring 2013

Question 1:                                                                                                                               Marks 10     

 

Answer the following questions precisely. Do not include irrelevant data in your answers. Any answer with more than three lines will neglect your marks. (2 marks for each)

Q1. Where are the interrupt vectors located in the microprocessors memory?

        The interrupt vectors are located in the interrupt vector table which is further located at the address 0000:0000h

Q2. Which interrupt vectors are reserved by Intel?

The first 32 vector 0-31 are reserved by intel for processor generated exception

Q3. Explain the operation of IRET instruction.

In Real Address Mode, iret pops CS, the flags register, and the instruction pointer from the stack and resumes the routine that was interrupted. In Protected Mode, the setting of the nested task flag (NT) determines the action of iret. The IOPL flag register bits are changed when CPL equals 0 and the new flag image is popped from the stack.

iret returns from an interrupt procedure without a task switch if NT equals 0. Returned code must be equally or less privileged than the interrupt routine as indicated CS selector RPL bits popped from the stack. If the returned code is less privileged, iret pops SS and the stack pointer from the stack.

iret reverses the operation of an INT or CALL that caused the task switch if NT equals 1. The task executing iret is updated and saved in its task segment. The code that follows iret is executed if the task is re-entered.

Q4. List the events that occur when an interrupt becomes active.

Event that can generate interrupt include a timer overflow or research  an assign value, a serial input device has receive a new character, a serial output device is ready to send a new character,an input pin has change state,the system voltage has dropped below a safe level,ADC has finished a new conversion

Q5. Explain the purpose of the trap flag (TF).

A trap flag permit operation of a processor in a single step mode.if such a flag is available debugger can use it to step through the execution of a computer program

Question 2:                                                                                                                               Marks 10     

Write a C program that should write the value of ‘k’ in the keyboard buffer whenever the letter ‘z’ is pressed from keyboard.

 

 

#include<dos.h>

void interrupt (*old)();

void interrupt newfunc();

char far *scr = (char far*) 0xb8000000;

int j;

void main()

{

old = getvect(0x09);

setvect(0x09,newfunc);

keep(0,1000);

}

void interrupt newfunc()

{

for(j=0;j<4000;j+=2)

{

if(*(scr+j)==’1’)

*(scr+j) = ‘9’;

}

(*old)();

}

DOWNLOAD SOLUTION HERE
loading...