Attention: Dear visitors If you find any answer or something wrong on allvirtuals.blogspot.com plz feel free to contact me ali.hse123@gmail.com or leave comments
Showing posts with label CS401 Subjective Questions. Show all posts
Showing posts with label CS401 Subjective Questions. Show all posts

Saturday, 19 November 2011

CS401 Subjective Questions


Q#: 28    ( Marks: 2 )
 Write instructions to do the following. Copy contents of memory location with offset 0025 in the current data segment into AX.

Ans:

Mov ax , [0025]

mov[0fff], ax

mov  ax , [0010]
   mov [002f] , ax

   
Q#: 29    ( Marks: 2 )

 Write types of Devices?

Ans:
There are two types devices used  in pc.
  1. Input devices(keyboard, mouse,)
  2. Output devices.(monitor, printer)


   
Q#: 30    ( Marks: 2 )

What dose descriptor 1st 16 bit tell?

Ans:
Each segment is describe by the descriptor like
  1. base,
  2. limit,
  3. and attributes,
it  basically define the actual base address.


   
Q#: 31    ( Marks: 3 )

List down any three common video services for INT 10 used in text mode.

Ans:
INT 10 - VIDEO - SET TEXT-MODE CURSOR SHAPE
AH = 01h
CH = cursor start and options
CL = bottom scan line containing cursor (bits 0-4)

Q#: 32    ( Marks: 3 )

How to create or Truncate File using INT 21 Service?

Ans:


INT 21 - TRUNCATE FILE
AH = 3Ch
CX = file attributes
DS:DX -> cs401 filename
Return: 
CF = error flag
AX = file handle or error code

   
Q#: 33    ( Marks: 3 )

How many Types of granularity also name them?
Ans:
There are three types of granuality :
  1. Data Granularity
  2. Business Value Granularity
  3. Functionality Granularity 
   
Q#: 34    ( Marks: 5 )

How to read disk sector into memory using INT 13 service?


Ans:
INT 13 - DISK - READ SECTOR(S) INTO MEMORY :
AH = 02h
AL = number of sectors to read (must be nonzero)
CH = low eight bits of cylinder number
CL =                sector number 1-63 (bits 0-5)
                          high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer


Return: 
CF = error flag
AH = error code
AL = number of sectors transferred
   
Q#: 35    ( Marks: 5 )

The program given below is written in assembly language. Write a program in C to call this assembly routine.
[section .text]
global        swap
swap:        mov  ecx,[esp+4]      ; copy parameter p1 to ecx
                  mov  edx,[esp+8]      ; copy parameter p2 to edx
                  mov  eax,[ecx]           ; copy *p1 into eax
                  xchg eax,[edx]           ; exchange eax with *p2
                  mov  [ecx],eax           ; copy eax into *p1
                  ret                               ; return from this function


Ans:
The above code will assemble in c through this command. Other aurwise error will occur.
Nasm-f win32 swap .asm

This command will generate swap.obj file.
The code for given program will be as follow.

#include <stdio.h>
Void swap(int* pl, int* p2);
Int main()
{
      Int a=10,
      Int b= 20;
Print f (“a=%d b=%d\n” , a ,b);

Swap (&a ,&b);

Print f (“a=%d b=%d\n” , a ,b);

System ( “pause”);


Return 0;


}



   
Q#: 36    ( Marks: 5 )

Write the code of “break point interrupt routine”.


Ans:
[org 0x0100]
jmp start
flag: db 0 ; ………………flag whether a key pressed
oldisr: dd 0 ; ……………..space for saving old ISR
names: db 'FL =CS =IP =BP =AX =BX =CX =DX =SI =DI =DS =ES ='
Breakpoint interrupts service routine :
debugISR:       push bp
              mov  bp, sp             ; …………….to read cs, ip and flags
              push ax
              push bx
              push cx
              push dx
              push si
              push di
              push ds
              push es

              sti                     ;…………………….. waiting for keyboard interrupt
              push cs
              pop  ds                 ;…………………… initialize ds to data segment

              mov  ax, [bp+4]         
              mov  es, ax             ; ………………….load interrupted segment in es
              dec  word [bp+2]        ; ……………….decrement the return address
              mov  di, [bp+2]         ;………………… read the return address in di
              mov  word [opcodepos], di ;…………. remember the return position
              mov  al, [opcode]       ; …………..load the original opcode
              mov  [es:di], al        ;………….. restore original opcode there

              mov  byte [flag], 0     ; …………set flag to wait for key
              call clrscr             ;……………. clear the screen

              mov  si, 6              ; …………..first register is at bp+6
              mov  cx, 12             ;………… total 12 registers to print
              mov  ax, 0              ; …………..start from row 0
              mov  bx, 5              ; ………….print at column 5

          push ax                 ; ………………..row number
              push bx                 ;………………. column number 
              mov  dx, [bp+si]
              push dx                 ;………………. number to be printed
              call printnum           ;…………….. print the number
              sub  si, 2              ; ……………….point to next register 
              inc  ax                 ; ………………..next row number 
              loop l3                 ; ……………….repeat for the 12 registers

              mov  ax, 0              ; ………………..start from row 0
              mov  bx, 0              ; ………………..start from column 0
              mov  cx, 12             ; …………………..total 12 register names
              mov  si, 4              ;……………………. each name length is 4 chars
              mov  dx, names          ; …………………..offset of first name in dx

              push ax                 ;………………………. row number 
              push bx                 ; ………………………column number 
              push dx                 ; ……………………….offset of string
              push si                 ; ………………………….length of string
              call printstr           ; ………………………….print the string
              add  dx, 4              ;………………………….. point to start of next string 
              inc  ax                 ; ……………………………new row number
              loop l1                 ;…………………………….. repeat for 12 register names

              or word [bp+6], 0x0100  ; ……………………set TF in flags image on stack

keywait:      cmp  byte [flag], 0     ;……………………. has a key been pressed
              je   keywait            ;            ………………….. no, check again

              pop es

              pop ds
              pop di
              pop si
              pop dx
              pop cx
              pop bx
              pop ax
              pop bp
              iret

start:        xor  ax, ax
              mov  es, ax             ;            ……………………point es to IVT base
              mov  word [es:1*4], trapisr ;…………………. store offset at n*4
              mov  [es:1*4+2], cs     ;      …………………...store segment at n*4+2
              mov  word [es:3*4],            …………………..debugisr ; store offset at n*4
              mov  [es:3*4+2], cs     ;      …………………..store segment at n*4+2
              cli                     ;                  ………………….disable interrupts
              mov  word [es:9*4], kbisr ; ………………….store offset at n*4
              mov  [es:9*4+2], cs     ; ……………………...store segment at n*4+2
              sti                     ;             ………………………enable interrupts



Q#: 1    ( Marks: 1 )    :-

SP is associated with…………. By default
       ► SS
       ► DS
       ► CS
       ► ES
   
Q#: 2    ( Marks: 1 )    :-

Which bit of the attributes byte represents the red component of foreground color
       ► 5
       ► 4
       ► 3
       ► 2
   
Q#: 3    ( Marks: 1 )    :-

 An 8 x 16 font is stored in ______________ bytes.
       ► 2
       ► 4
       ► 8
       ► 16
   
Q#: 4    ( Marks: 1 )    :-

In DOS input buffer, the number of characters actually read on return is stored in ___________ byte.
       ► third
       ► fourth  
       ► first 
       ► second      
   
Q#: 5    ( Marks: 1 )    :-

Which of the following gives the more logical view of the storage medium
       ► BIOS
       ► DOS
       ► Both
       ► None
   
Q#: 6    ( Marks: 1 )    :-

In STOSW instruction, when DF is clear, SI is

       ► Incremented by 1

       ► Incremented by 2

       ► Decremented by 1

       ► Decremented by 2

   
Q#: 7    ( Marks: 1 )    :-

Which of the following interrupts is Non maskable  interrupt

       ► INT 2
       ► INT 3
       ► INT 0
       ► INT 1
   
Q#: 8    ( Marks: 1 )    :-

Which of the following IRQs is connected to serial port COM 2?

       ► IRQ 0
       ► IRQ 1
       ► IRQ 2
       ► IRQ 3
   
Q#: 9    ( Marks: 1 )    :-

The time interval between two timer ticks is ?

       ► 40ms
       ► 45ms
       ► 50ms
       ► 55ms

By HSE with No comments