CS609 - Midterm Solved Subjective With References by Moaaz PDF
CS609 - Midterm Solved Subjective With References by Moaaz PDF
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
Q. A function that will send com port. com port number will be accessed as parameter (5 Marks)
Answer:- (Page 126)
The sendchar() function sends a character to the COM port using BIOS service whose number is passed as
parameter. And the getcomstatus() function retrieves the status of the COM port whose number has been
specified and returns the modem and line status in an unsigned int.
void main()
{
while(1) {
i = getcomstatus (0);
if (((*(((char*)(&i)) + 1)&0x20) == 0x20) && (kbhit()))
{
ch1 = getche();
sendchar (ch1, 0);
}i
f ((*(((char*)(&i)) +1) & 0x01) == 0x01) {
ch2 = receivechar (0);
putch (ch2);
}i
f ((ch1 == 27) || (ch2 ==27))
break;
}
}
1
Q. Step to access battery powered ram. (5 Marks)
Answer:- (Page 144)
Battery Powered RAM is accessed in two steps
• Specify the Byte no. in 70H port.
• Read/write port 71H to get/set the value of specified byte.
Following slide shown a fragment of code that can be used to read or write onto any byte within the 64 byte
battery powered RAM.
outport (0x70, 0); outport (0x70, 4);
sec = inport (0x71); outport (0x71,hrs);
Q. What will be binary value of led status byte if scroll lock n num lock r on? (3)
Answer:- (Page 29)
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
2
2 )programe BCD to ASCII
Answer:- (Page 147)
void main ()
{
unsigned int hours, months, seconds;
_AH =2;
geninterrupt(0x1a);
hours = _CH;
minutes = _CL;
seconds = _DH;
hours = hours <<4;
*((unsigned char *)(& hours)) =
(*((unsigned char *) (& hours))) >>4;
hours = hours + 0x3030;
seconds = seconds <<4;
*((unsigned char *)(& seconds)) =
(*((unsigned char *)(& seconds))) >>4;
seconds = seconds + 0x3030;
minutes = minutes <<4;
*((unsigned char *)(& minutes)) =
(*((unsigned char *)(& minutes))) >>4;
minutes = minutes + 0x3030;
clrscr();
printf("%c%c-%c%c-%c%c%c%c",
*(((unsigned char*)(&hours))+1),
*((unsigned char*)(&hours)),
*(((unsigned char*)(&minutes))+1),
*((unsigned char*)(&minutes)),
*(((unsigned char*)(&seconds))+1),
*((unsigned char*)(&seconds)),
getch();
}
The above program uses the service int 1Ah/02H to read the time from the real time clock. It reads the time and
converts the packed BCD values into unpacked BCD values. These values are then converted into ASCII and
displayed using the printf() statement.
3
5) int 14h explain service#2,service#3
Answer:- (Page 119)
Service #02 = Read in characters
Service #03 = Get port status
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
1: A function that will send com port. com port number will be accessed as parameter
Answer:- Rep
4
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
5
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
What do you understand by Self test mode of UART what happens in this situation?
Answer:- (Page 117)
If a single computer is available to a developer the UART contains a self test mode which can be used by the
programmer to self test the software. In self test mode the output of the UART is routed to its input. So you
receive what you send.
MIDTERM EXAMINATION
Fall 2012
CS609- System Programming
6
2. in RS232 flow control which line used to send and receive data (2 Marks)
Answer:- (Page 111)
Data is received through the RxD line. Data is send through the TxD line.
what is the meaning of this code at receiver end in parallel communication unsigned int far * lpt =
(unsigned int far *)0x00400008;
if ((( inport((*lpt) +1)) & 0x80) == 0x80) (3 Marks)
How can we enable the 0x0f to perform interrupt driven I/O? and how PIC will handle this interrupt?
(5 Marks)
Answer:- (Page 96)
To enable the interrupt 0x0f three things are required to be done. The interrupt should be enabled in the printer
control register; secondly it should also be unmasked in the IMR in PIC. The program can then intercept or set the
vector of interrupt 0x0f by placing the address of its function newint();
The newint() will now be called whenever the printer can perform output. This newint() function writes the next
byte in buffer to the data registers and then send a pulse on the strobe signal to tell the printer that data has been sent
to it. When whole of the buffer has been sent the int 0x0f vector is restored, interrupt is masked and the memory for
the program is de-allocated.