{Mid Semester I} {Mid Semester II} {End Semester} {Assignment} [Teaching @ PUCSD] [Home]

Mid Semester Examination - I
(22 January 1996, 90 Minutes)


  1. Write "to the point" answers for the following.

    1. What are the advantages of segmented memory ?
    2. What are the conditions that will cause the BIU to suspend fetching instructions?
    3. What is the significance of the following assembler directives?
      1. ASSUME
      2. END
    4. The given program fragments achieve the same goal. Which one is better and why?
      1. MOV AX, [100h]
        MOV BX, AX
      2. MOV AX, [100h]
        MOV BX, [100h]
    5. Assume that the register AL contains ascii value of either a capital letter or a small letter. Write a small program fragment to convert the contents of AL to corresponding capital letter.
  2. This question carries negative marks. Negative marks will not be carried over to other questions.

    1. State whether true or false.
      1. Programs written for the 8086 can be run on the 8088 without any changes.
      2. An address within a segment is called an real address.
      3. In the case of 8086, BIU is programmed to fetch a new instruction whenever the instruction stream queue has room for one additional byte.
      4. You can't access the low or high bytes alone of the pointer and index group of registers.
      5. 8088 has 16 bit internal data bus but 8 bit external data bus.

    2. Which segment will be accessed for following instructions?
      1. MOV [BX], AH
      2. INC BYTE PTR [BP+SI]
      3. ADD CX, DX
      4. MOV AX, SS:[BX]

    3. State the addressing mode(s) used in each of the following instructions.
      1. DIV BL
      2. INC BYTE PTR [100h]
      3. ADD Table[BX][DI], 3fh ; Table is a byte label in the data segment

    4. Fill in the blanks.
      1. Any segment (64 Kbyte memory block) can begin at any address in the 1 Mb address space of 8086/8088, if ______________________________.
      2. To maximize 8086 processor's performance, a data word should be stored at an _______ memory address.
      3. The logic within ALU actually executes all additions as if they are ______ and CPU sets or clears the overflow flag as if ___ addition were performed.
      4. The physical address of the byte accessed by Table[DI] is ________ ; when Table is defined as a byte label at offset 30h in the data segment DS = 0010h and DI has the value 321.
      5. Specify the content of all conditional flags after the execution of the given program fragment --

        MOV AL, 0FFh
        ADD AL, 1

  3. Let the give program be stored at address "start_address" in the memory.

    instruction 1 --> 03 C3
    instruction 2 --> B9 00 3B ; none of these
    instruction 3 --> 90 ; instructions causes jump
    instruction 4 --> 01 11 ; in control flow


    What will be the status of instruction stream queues in the case of 8086 and 8088 cpus's after three fetches (for instruction), when

    1. start_address = 100
    2. start_address = 57
  4. Write a program fragment to add (-1) to a "W" word multiple precision signed number ("W" can take any value). Jump to location OK, if the result of addition fits in W words.

    OR


    Given, two digits in packed BCD format in register BL. Write a program fragment to unpack them to two ascii digits in registers BH and BL. For your help part of the program is given below. Fill in the missing (?) part and rewrite the program.
              MOV  ? , BL
              AND  ? , ?
              MOV  ? , ?
              SHR  ? , ?
               ?   ? , ?
      
  5. Write a program fragment to multiply two 8 bit unsigned numbers without using MUL/IMUL/DIV/IDIV instructions. Assume that the operands reside in BH and BL. Put the final result in AX. Continue program execution from location IT_FITS -if result fits in AX, else from location NOT_FITS.

    OR


    Write a program fragment to evaluate the given polynomial at x = 4 and put the result in register AX. If you think that carry/overflow will take place in this case, then take care of that also.

    f(X) = X^7 + X^5 + X^4 + X^3 + X

    OR


    You have to reverse a list of ascii characters in place. The size of list is "N" (N can be any number). Apart from the memory locations occupied by the list you are allowed to use a fixed no. (less than 100) of memory locations independent of value of "N".

    Write a program fragment for the above task, assuming that N is never greater than 128 K.



Mid Semester Examination - II
(01 March 1996, 90 Minutes)

Note :


  1. Write "to the point" answers for the following --

    1. What is "WRONG" with instruction "REP LODSB" ?
    2. Give two ways of making a program reentrant.
    3. Do we need to declare stack in a program when we don't have a single push/pop instruction, neither we have instructions to access some memory location in stack segment, but few interrupt call instructions have been used in the program? Justify your answer.
    4. Define a record "PSW" to access 8086 flags conveniently.
    5. 8086 assembler will not recognize the instruction for the 8087 Numeric Data Processor. Use a macro to create a new 8086 instruction FDECSTP to decrement the 8087 stack pointer -- which has the hex coding "D9 F6".
    6. What is the need of providing type attributes with EXTRN declarations?
    7. Differentiate between short and near jumps.
  2. Give macros as asked below -

    1. 8086/8088 don't provide any instruction to set or clear trap flag. Write a macro SETTF which can be used like an instruction.
    2. Write a macro "TABLE" with single parameter "num", which will allocate 10 words and initialise them with the multiplication table of num. Do not use DW directive more than once in the macro.
  3. Fill in the blanks --

    1. "JMP DWORD PTR CS:[BP]" is an example of a ____ jump.
    2. As data is pushed onto the stack, the stack grows ________ in memory.
    3. Interrupt ____ should be used to transfer control to the address stored in the ________ beginning at an address 00084h.
    4. Regardless of the type of interrupt the actions that result from an interrupt are same and known as ________.
    5. The single 8086/8088 instruction that is equivalent to given sequence of four instructions is _________.
                      Push  AX
                      Push  BX
                      Pop   AX
                      Pop   BX
                      Push  AX
         
    6. The object code for the instruction "MOV WORD PTR [BP+SI+10h], 3724h" on 8086 is ______.
    7. The _____ combine type allows each program module to add only as many bytes to the stack as module requires.
  4. Assuming that all the instructions are available in instruction queue, when needed, calculate the time that the following code fragment will take to execute, if the clock speed is 5 Mhz.
                    mov cx, 8000h
              CNT : mov [si], cx
                    inc si
                    loop CNT
      
  5. An assembly language program consists of two segments as shown below -
                 code segment   __
                 ...........      | size = 0023h
                 code ends      __|
                 data segment  COMBINE_TYPE   __
                    table dw 10 dup(?)          |  size = 0008h
                 data ends                    __|
      
    In the .EXE file generated by linker, code segment is placed before the data segment. The program is loaded into memory at 009E3h. What will be the value of "SEG table" and "OFFSET table", when

    1. COMBINE_TYPE is BYTE.
    2. COMBINE_TYPE is PAGE.
  6. Write a recursive procedure for printing all the moves for "TOWER of HANOI" problem. Moves should be printed as ..

    Move disk < disk_number > from < source_peg > to < destination_peg >


    Make the following assumptions --

    Procedure should be defined as far procedure and it should clear the stack before returning. Write macros/related procedures if needed.

    If there is no restriction of time and cpu runs your program continuously. What will be the maximum no. of disks your program can handle ?
  7. Consider the problem of counting no. of pepsi cans produced per day (assuming maximum production capacity as 9,200 cans per day) in the factory. For the purpose a switch is placed below the conveyer belt, which gets pressed when the can passes over it. The other end of switch is connected to an interface to 8086 microprocessor. If the bit no. 7 of the byte received from port 0D6h is set, it indicates that the switch is pressed and vice versa.

    Write a program fragment that will COUNT THE NO. OF CANS PASSED OVER THE SWITCH and display the current count on a four digit LCD display connected to the port 0D4h.

    The mapping between digits to be displayed on LCD and the bits of the word sent to corresponding port are as follows ..
              bit no. 15-12 -- thousand's place
                       11-8 -- hundred's place
                        7-4 -- ten's place
                        3-0 -- unity's place
      



End Semester Examination
(17 April 1996, 180 Minutes)

Note :

  1. Photostat copies of 8088/86 and MS-DOS/BIOS reference allowed.
  2. A program fragment means: you need not write the full program, but you must still give all necessary declarations. Make the fragment as efficient as possible.


  1. Answer briefly to following WHYs??? (in less than 3 lines).

    1. Why must the symbolic addresses within macros be defined with a LOCAL statement ?
    2. DOS service calls are not reentrant. If you need to use some dos call in your TSR program, how will you ensure that everything runs smoothly.
    3. Why is the 8086 signal BHE(bar) not provided on 8088 ?
    4. Why should RET not be used to terminate an ISR ?
    5. Why is polling an inefficient way of controlling a slow peripheral ?
    6. Why do the CS, IP and flag registers not have to be saved during a DMA cycle ?
    7. Why can't an .EXE or .COM program have more than 20 files open at a time (including stdin/stdout/stderr/aux/prn) ?
    8. When the assembler begins the assembly process, how does it know which program segment to use for the code, data, stack and extra segments ?
    9. Why does execution starts at ffff:0000 when 8086 m/c is switched on or reset ?
      [Hint :- think what happens to different registers and instruction queue]

    10. What will happen when you execute the following program.

      code segment
      org 100h
      assume cs:code ; this program is assembled and linked as
      test1 proc near ; a .COM program
      MOV AX, 0h
      PUSH AX
      RET
      test1 endp
      code ends
      end


    11. Given below is a code fragment to set the frequency of speaker on 8086. Find out the value of Freq_Cnt for producing a frequency of 10,000 Hz. Take the frequency for 8053 timer as 1.193180 MHz.

      MOV AL, 0B6h
      OUT 43h, AL
      MOV AX, Freq_Cnt
      OUT 42h, AL
      MOV AL, AH
      OUT 42h, AL


    12. Match the following -
      1. 8251, 8259A, 8237, 8256, 8254, 8255
      2. PIC, multifunction UART, PPI, programmable interrupt timer, programmable communications interface, programmable DMA controller

    13. When installable device drivers are being installed, MSDOS inserts character device drivers after the NUL device in the linked list of device drivers and inserts block device drivers at the end of same list. What is the advantage of this?

    14. Can the sequence of instructions

      MOV AH, 4Ch
      INT 21h


      always be replaced by the single instruction "INT 20h" to terminate a program and return to DOS? Justify your answer.
  2. Write one line answers for following.

    1. Where on the disk is the format information stored ?
    2. Name three types of port I/O.
    3. List three means of giving priority to the interrupt system.
    4. Give an example of an 8086 instruction which has no operands.
    5. What are the first two characters in .EXE file ?
    6. What are the two types of device drivers ?
    7. Name two memory mapped display modes.
    8. Give the expansion of VIRUS and USART.
    9. Arrange the following types of interrupts as per decreasing priority :
      internal via CPU, internal via S/W (INT num/ INTO), external on NMI pin, external on INTR pin
  3. Fill in the blanks.

    1. ______ are connections through which devices or other computers can be connected to your computer.
    2. Dos reserves minimum _________ space for environment entries.
    3. The process of monitoring an external status bit and repeating the loop if not ready is called as _________.
    4. Purpose of _________ in 8086 microprocessor system is to initialise the computer and then load the Operating System from the boot disk.
    5. It is necessary to enable EVEN and ODD banks of RAM separately when 8086 is performing a memory _______ cycle ?
    6. Memory mapped I/O is most useful when the I/O devices require a block of _____________ I/O ports.
    7. Following program fragment transfers a character serially through bit 0 of data port DPORT. For asynchronous communication 1 start bit (0), 8 data bits and 2 stop bits (1's) are used. The character to be sent is in AL. Fill in the missing part.
                        MOV  CX, ??
                        ???
                        RCL  AL
             bit_send : OUT  DPORT, AL
                        CALL DELAY     ; to cause appropriate data transfer rate
                        ???  AL, 1
                        ???
                        LOOP bit_send
         
    8. The ______ is a microprocessor compatible peripheral interface chip used to convert parallel data into serial and vice versa.
    9. The ___________ statement allows a label to be associated with a specific memory location.
    10. The activity involved in transferring a byte/word over the system bus is called a ___________.
    11. Size of EXE file header is always _________________________.
  4. Distinguish between the following pairs.

    1. serial and parallel data communication
    2. bit testing and bit masking
    3. Static RAM and Dynamic RAM
    4. .COM and .EXE files (compare wrt max pgm size; CS,IP,DS & ES at entry; file size)
  5. State whether the following statements are true or false.

    1. The assume statement loads the CS and DS registers when the program is loaded and run.
    2. Some fast peripherals can not be controlled using interrupt based I/O.
    3. DMA requests take precedence over all other bus activities including interrupts. No interrupt (maskable/non-maskable) will be recognised during a DMA cycle.
    4. Another name for Master Boot Record is partition table.
  6. Write brief answers for the following.

    1. Suppose you have to write a program which will undelete the files in the current directory. Give the sequence of steps for it in brief, but do not give any code.
    2. Describe the sequence of actions that take place within a PC when an external interrupt arrives on INTR pin.
    3. Give a diagramatic representation of NULL MODEM for connecting two RS232C data terminal type devices.
    4. You have written a TSR program to trap Control-C interrupt handler (interrupt 23h) which modifies Interrupt vector table for this interrupt by overwriting with the address of your interrupt handling routine (IHR). Inside your IHR you are printing the message "Ctrl_C detected" and returning the control back to the interrupted program w/o terminating it.

      After you have installed your TSR program, a batch file containing atleast three-four commands is run. The user presses Control-C during the execution of batch file. Will the execution of batch file be terminated ? If yes, then how will you make sure that the control goes to your TSR routine when user presses Control-C. Justify your answer.
  7. Given below is a part of a C program. Write an assembly program fragment to accomplish the same without performing any comparison on the value of j to call different functions. Note that -

               switch (j)
               {
                   case 1 : func1 (); break;
                   case 2 : func2 (); break;
                   case 3 : func3 (); break;
                   case 5 : func5 (); break;
                   case 6 : func6 (); break;
               }
          after_switch :
                        ....... some other C code ....
      
    Comment on your approach as compared to one where we can implement the same thing using a no. of explicit jump and comparison instructions.
  8. Write an assembly program for counting the no. of arguments passed to it on the command line. Specify whether it will be linked as .EXE or as .COM file.
  9. 8086 provides us with a byte table lookup instruction "XLAT", which works for tables of size upto 256 bytes. Write a macro "XLATW" which will be similar in function except that it will provide table lookup facility on word tables. Before calling this macro the BX register has the address of the start of the word table and AX contains the index value "i" of the word to be accessed. After execution of this macro, AX will contain the ith word in the word table.



Assignment #2

Write an assembly language program to implement recursive/non-recursive version of Quicksort.


Created on May 04, 2006