Monday, October 21, 2013

Microprocessor - Question Bank

QUESTION-BANK

Q1. Differentiate between microprocessor and microcontroller?
Ans.      1. Microprocessor is a general purpose devise
  2. Microcontroller is indented for a specific purpose
  3. Memory ,I/O devices etc need to be interfaced with microprocessor
  4. Microcontroller is having its own memory , I/O  etc integrated with it
  5. We can say that microprocessor is a cpu on a chip
  6.  Microcontroller is a system on a chip

Q2. What is an instruction queue? Explain?
Ans.  This is introduced in 8086 processor.This queue is in the BIU and is used for storing the predecoded instructions.This will overlap the fetching and execution cycle.
The E U will take the instructions from the queue for decoding and execution.

Q3. What is REP prefix? How it functions for string instructions?
Ans.  This REP prefix is used for repeating. The instruction with REP prefix will execute repeatedly till the count in the cx register will be zero. This can be used in with some of the string handling instructions.

Q4. Explain the instructions (i) LDS (ii) PUSHF (iii) TEST (iv) CLD
Ans.
i)                     LDS   : load pointer to DS
                         Move a 32 bit content from the memory given as source to 16
                         bit destination register specified and to DS register.

ii)                     PUSHF  : push the flag
                                After the execution the content of the flag register will be
                                pushed to the stack.The higher byte to sp-1 and lower to
                                sp-2

iii)                  TEST   : logical comparison
                            This will compare the source and the destination specified.
                            The result will be reflected only in the flag registers.
     
 iv)         CLD  : this will clear the direction flag.

Q5. What is stack? Explain the use and operation of stack and stack pointer?
Ans. A stack is a portion of the memory used for the temporary storage. A stack is a last
         In first Out memory. A stack grows in the decreasing order. A stack will hold the
         temporary information’s push and pop are the instructions used for storing and
         accessing data from the stack. Contents can be moved as 16 bit only using push and
         pop instructions.




Q6. What are the flags in 8086?
Ans. In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag,
         Trap flag, Interrupt flag, Direction flag, and Sign flag.

Q7. What are the various interrupts in 8086? Explain.
Ans. Maskable interrupts, Non-Maskable interrupts.
i)  An interrupt that can be turned off by the programmer is known as Maskable
   interrupt.
ii)  An interrupt which can be never be turned off (ie.disabled) by the programmer
      is known as Non-Maskable interrupt.

Q8. Which interrupts are generally used for critical events?
Ans. Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency, Shut off etc.

Q9. What is the effect of executing the instruction?
                                MOV CX, [SOURCE_MEM]
  Where SOURCE_MEM equal to 2016 is a memory location offset   relative to the current data segment starting at address 1A00016
Ans. Execution of this instruction results in the following:
                                                          ((DS) 0 + 2016) à (CL)
                                                          ((DS) 0 + 2016 + 116) à (CH)
In other words, CL is loaded with the contents held at memory address
                                                     1A00016 +2016 +116 =1A02116

Q10. The original contents of AX, BL, word-sized memory location SUM, and carry flag
         CF are 1234H, ABH, 00CDH, and 0H, respectively. Describe the results of
          executing the following sequence of instructions:
                                                   ADD AX, [SUM]
                                                   ADC BL, 05H
                                                   INC WORD PTR [SUM]
Ans. Executing the first instruction adds the word in the accumulator and the word in the
         memory location pointed to by address SUM. The result is placed in the
         accumulator. That is,
                           (AX) ← (AX) + (SUM) = 1234H + 00CDH = 1301H
         The carry flag remains reset.
The second instruction adds to the lower byte of the base register (BL) the immediate operand 5H and the carry flag, which is 0H. This gives
                           (BL) ← (BL) + imm8 + (CF) = ABH + 5H+ 0H = B0H
Since no carry is generated CF remains reset.
The last instruction increments the contents of memory location SUM by one. That is,
                           (SUM) ← (SUM) + 1H = 00CDH + 1H =00CEH



Q11. The 2’s complement signed data contents of AL equal -1 and the contents of CL are
         -2. What result is produced in AX by executing the following instructions:
           i) MUL CL  ii) IMUL CL

Ans. As binary data, the contents of AL and CL are
                        (AL) = -1 (as 2’s complement) = 111111112 = FFH
                        (CL) = -2 (as 2’s complement) = 111111102 = FEH
        Executing the MUL instruction gives
                        (AX) = 111111112 * 111111102 = 11111101000000102
                                 = FD02H
        The second instruction multiplies the two numbers as signed numbers to generate
        the signed result. That is,
                        (AX) = -1H * -2H
                                 = 2H = 0002H

Q12. Explain different types of registers in 8086 microprocessor arch.
Ans. Most of the registers contain data/instruction offsets within 64 KB memory segment. There are four different 64 KB segments for instructions, stack, data and extra data. To specify where in 1 MB of processor memory these 4 segments are located the processor uses four segment registers:
Code segment (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP) register. CS register cannot be changed directly. The CS register is automatically updated during far jump, far call and far return instructions.
Stack segment (SS) is a 16-bit register containing address of 64KB segment with program stack. By default, the processor assumes that all data referenced by the stack pointer (SP) and base pointer (BP) registers is located in the stack segment. SS register can be changed directly using POP instruction.
Data segment (DS) is a 16-bit register containing address of 64KB segment with program data. By default, the processor assumes that all data referenced by general registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment. DS register can be changed directly using POP and LDS instructions.
Extra segment (ES) is a 16-bit register containing address of 64KB segment, usually with program data. By default, the processor assumes that the DI register references the ES segment in string manipulation instructions. ES register can be changed directly using POP and LES instructions.
It is possible to change default segments used by general and index registers by prefixing instructions with a CS, SS, DS or ES prefix.
All general registers of the 8086 microprocessor can be used for arithmetic and logic operations. The general registers are:
Accumulator register consists of 2 8-bit registers AL and AH, which can be combined together and used as a 16-bit register AX. AL in this case contains the low-order byte of the word, and AH contains the high-order byte. Accumulator can be used for I/O operations and string manipulation.
Base register consists of 2 8-bit registers BL and BH, which can be combined together and used as a 16-bit register BX. BL in this case contains the low-order byte of the word, and BH contains the high-order byte. BX register usually contains a data pointer used for based, based indexed or register indirect addressing.
Count register consists of 2 8-bit registers CL and CH, which can be combined together and used as a 16-bit register CX. When combined, CL register contains the low-order byte of the word, and CH contains the high-order byte. Count register can be used as a counter in string manipulation and shift/rotate instructions.
Data register consists of 2 8-bit registers DL and DH, which can be combined together and used as a 16-bit register DX. When combined, DL register contains the low-order byte of the word, and DH contains the high-order byte. Data register can be used as a port number in I/O operations. In integer 32-bit multiply and divide instruction the DX register contains high-order word of the initial or resulting number.
The following registers are both general and index registers:
Stack Pointer (SP) is a 16-bit register pointing to program stack.
Base Pointer (BP) is a 16-bit register pointing to data in stack segment. BP register is usually used for based, based indexed or register indirect addressing.
Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and register indirect addressing, as well as a source data address in string manipulation instructions.
Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and register indirect addressing, as well as a destination data address in string manipulation instructions.