Questions and problems

QUESTIONS AND PROBLEMS

9.1 What is the basic difference between the 8086, 8086-1, 8086-2, and 8086-4?

9.2 Assume (DS)=1000H, (SS)=2000H, (CS)=3000H, (BP)=OOOFH, (BX)=000AH before execution of the following 8086 instructions:

(a) MOV CX,[BX]                    (b) MOV DX,[BP]

Which instruction will be executed faster by the 8086, and why ?

9.3 What is the purpose of the 8086 MN/MX pin?

9.4 If (DS) = 205FH and OFFSET = 0052H, what is the 8086 physical address?

Does the EU or BIU compute this physical address?

9.5 In an 8086 system, SEGMENT 1 contains addresses 00100H-00200H and SEGMENT 2 also contains addresses 001OOH-00200H. What are these segments called?

9.6 Determine the addressing modes for the following 8086 instructions:

image

9.7 Find the overflow, direction, interrupt, trap, sign, zero, parity, and carry flags after execution of the following 8086 instruction sequence:

MOV AH, 0FH

SAHF

9.8 What is the content of AL after execution of the following 8086 instruction sequence?

MOV BH, 33H

MOV AL, 32H

ADD AL, BH

AAA

9.9 What happens after execution of the following 8086 instruction sequence?

Comment.

MOV           DX,     00lFH

XCHG         DL,      DH

MOV         AX,       DX

IDIV          DL

9.10 What are the remainder, quotient, and registers containing them after execution of the following 8086 instruction sequence?

MOV AH, 0

MOV AL, OFFH

MOV CX, 2

IDIV CL

9.11 Write an 8086 instruction sequence to set the trap flag for single stepping without affecting the other flags in the Status register.

9.12 Write an 8086 assembly language program to subtract two 64-bit numbers.

Assume SI and DI point to the low words of the numbers.

9.13 Write an 8086 assembly program to add a 16-bit number stored in BX (bits 0 to 7 containing the high-order byte of the number and bits 8 to 15 containing the low­ order byte) with another 16-bit number stored in ex (bits 0 to 7 containing the low-order 8 bits of the number and bits 8 thorough 15 containing the high-order 8 bits). Store the result in AX.

9.14 Write an 8086 assembly program to multiply the top two 16-bit unsigned words of the stack. Store the 32-bit result onto the stack.

9.15 Write an 8086 assembly language program to add three 16-bit numbers. Store the 16-bit result in AX.

9.16 Write an 8086 assembly language to find the area of a circle with radius 2 meters and save the result in AX.

9.17 Write an 8086 assembly language program to convert 255 degrees in Celsius in BL to Fahrenheit degrees and store the value in AX. Use the equation

F=(C/5)*9+32

9.18 Assume AL, CX and DXBX contain a signed byte, a signed word, and a signed 32-bit number respectively. Write an 8086 assembly language program that will compute the signed 32-bit result: AL – CX + DXBX –+ DXBX.

9.19 Write an 8086 assembly program to divide an 8-bit signed number in CH by an 8-bit signed number in CL. Store the quotient in CH and the remainder in CL.

9.20 Write an 8086 assembly program to add 25 16-bit numbers stored in consecutive memory locations starting at displacement 0100H in DS == 0020H. Store the 16- bit result onto the stack.

9.21 Write an 8086 assembly program to find the minimum value of a string of 10 signed 8-bit numbers using indexed addressing. Assume Offset 5000H contains the first number.

9.22 Write an 8086 assembly program to move 100 words from a source with offset 0010H in ES to a destination with offset 0100H in the same extra segment.

9.23 Write an 8086 assembly program to divide a 28-bit unsigned number in the high 28 bits of DX AX by 810• Do not use any divide instruction. Store the quotient in the low 28 bits of DX AX. Discard remainder.

9.24 Write an 8086 assembly program to compare two strings of 15 ASCII characters.

The first character (string 1) is stored starting at offset 5000H in DS followed by the string. The first character of the second string (string 2) is stored starting at 6000H in ES. The ASCII character in the first location of string 1 will be compared with the first ASCII character of string 2, and so on. As soon as a match is found, store OOEE 16 onto the stack; otherwise, store 000016 onto the stack.

9.25 Write a subroutine in 8086 assembly language that can be called up by a main program in a different code segment. The subroutine will compute the 16-bit sum

image

 Assume the X;’s are signed 8-bit numbers and are stored in consecutive locations starting at displacement 0050H. Also, write the main program that will call this subroutine to compute

imageand store the 16-bit result (8-bit remainder and 8-bit quotient) in two consecutive memory bytes starting at offset 0400H.

9.26 Write a subroutine in 8086 assembly language to convert a 2-digit unpacked BCD number to binary. The most significant digit is stored in a memory location starting at offset 4000H, and the least significant digit is stored at offset 4001H. Store the binary result in DL.Use the value of the 2-digit BCD number, V = D1 x 10 + D0 Note that  arithmetic operations will provide binary result.

9.27 Assume an 8086/2732/6116/8255 microcomputer. Suppose that four switches are connected at bits 0 through 3 of port A and an LED is connected at bit 4 of port B. If the number of LOW switches is even, tum the port B LED ON; otherwise, tum the port BLED OFF. Write an 8086 assembly language program to accomplish this. Do not use any instructions involving the Parity flag.

9.28 Interface two 2732 and one 8255 odd to an 8086 to obtain even and odd 2732 locations and odd addresses for the 8255’s port A, port B, port C, and control registers. Show only the connections for the pins shown in Figure P9.28. Assume all unused address lines to be zeros.

image

9.29 In Figure P9.29, if VM > 12 V, tum the LED ON connected at bit 4 of port A. On the other hand, if VM < 11 V, tum the LED OFF. Use ports, registers, and memory locations of your choice. Draw a hardware block diagram showing the microcomputer and the connections of the figure to its ports. Write a service routine in 8086 assembly language. Assume all segment registers are already initialized. The service routine should be written as CS=1000H, IP=2000H. The main program will initialize SP to 2050H, initialize ports, and wait for interrupts.

9.30 Repeat Problem 9.29 using the 8086 NMI interrupt.

9.31 An 8086/2732/6116/8255-based microcomputer is required to drive the LEDs connected to bit 0 of ports A and B based on the input conditions set by switches connected to bit 1 of ports A and B. The I/O conditions are as follows:

  • If the input at bit 1 of port A is HIGH and the input at bit 1 of port B is low, then the LED at port A will be ON and the LED at port B will be OFF.
  • If the input at bit 1 of port A is LOW and the input at bit 1 of port B is HIGH, then the LED at port A will be OFF and the LED at port B will be ON.
  • If the inputs at both ports A and B are the same (either both HIGH or both LOW), then both LEDs at ports A and B will be ON.

Write an 8086 assembly language program to accomplish this. Do not use any instructions involving the parity flag.

9.32 An 8086/2732/6116/8255-based microcomputer is required to test a NAND gate. Figure P9.32 shows the I/O hardware needed to test the NAND gate. The microcomputer is to be programmed to generate the various logic conditions for the NAND inputs, input the NAND output, and tum the LED ON connected to bit 3 of port A if the NAND gate chip is found to be faulty. Otherwise, tum the LED ON connected to bit 4 of port A. Write an 8086 assembly language program to accomplish this.

image

9.33 An 8086/2732/6116/8255 microcomputer is required to add two 3-bit numbers in AL and BL and output the sum (not to exceed 9) to a common cathode seven­ segment display connected to port A as shown in Figure P9.33.Write an 8086 assembly language program to accomplish this by using a look-up table. Do not use XLAT instruction.

9.34 Write an 8086 assembly language program to tum an LED OFF connected to bit 2 of port A of an 8086/2732/6116/8255 microcomputer and then turn it on after delay of 15 s. Assume the LED is ON initially.

9.35 What are the factors to be considered for interfacing a hex keyboard to a microcomputer?

9.36 An 8086/2732/6116/8255 microcomputer is required to input a number from 0 to 9 from an ASCII keyboard interfaced to it and output to an EBCDIC printer. Assume that the keyboard is connected to port A and the printer is connected to port B. Write an 8086 assembly language to accomplish this. Use XLAT instruction.

9.37 Will the circuit shown in Figure P9.37 work? If so, determine the I/O map in hex.

If not, justify briefly, modify the circuit and determine the I/O map in hex. Use only the pins and signals provided. Assume all don’t cares to be zeros. Note that I/O map includes the addresses for port A, port B, port C, and the control register. Using the logical port addresses, write an instruction sequence to configure port A as input and port B as output.

image

Leave a comment

Your email address will not be published. Required fields are marked *