8086 program to convert binary to Grey code

PROGRAM NO.10

OBJECT:Write a program to find Gray Code Equivalent of a binary number using Lookup Table.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
PROGRAM:

MEMORY LOCATION MACHINE CODE OPCODE OPERAND
0202 BB 00 03 MOV BX,0300H
0205 BE 00 02 MOV SI,0200H
0208 AC LOD SB  
0209 D7 XLAT  
020A 88 04 MOV [SI],AL
020C F4 HLT  

DESCRIPTION:

To solve the given objective we have taken a binary number (its hexadecimal equivalent) in the memory location 0200H and left the memory location of 0201H and 0201H empty with 00. Then we have taken a lookup table to check for the gray code equivalent of the input binary number. The lookup table being stored from memory location of 0300H to 030FH.

To solve the given objective we have taken the following steps:

  1. Move the first gray code number from the lookup table into the BX registe
  2. Move the source index (SI) pointer to point to the memory location of the input binary number (its hexadecimal equivalent).
  3. Then the string byte is loaded from the lookup table and translated from gray to binary number.
  4. Move the source index pointer to  point to the  memory location where the  gray  equivalent number is to be stored, i.e. AL.

INPUT:

LOCATION SPECIFICATION VALUE STORED
0200H   0201H NUMBER INPUT(BINARY)) NUMBER OUTPUT(GRAY CODE) 0A     00

LOOKUP TABLE:-

MEMORY LOCATION VALUE
0300H 00
0301H 01
0302H 03
0303H 02
0304H 06
0305H 07
0306H 05
0307H 04
0308H 0C
0309H 0D
030AH 0F
030BH 0E
030CH 0A
030DH 0B
030EH 09
030FH 08

INPUT BINARY CODE VALUE:

MEMORY LOCATIONVALUE
0200H0A
0201H00

OUTPUT:

MEMORY LOCATIONVALUE
0201H0F

RESULT: The gray code equivalent of the binary number is checked from the lookup table and stored at the output.

FLOWCHART:

8086 program to convert binary to Grey code


Most Important Question for Exam

1. Synchronization bit at the beginning of character is called ________.




Answer is A)
start bit


2. Which is a 8 bit Microprocessor ?




Answer is B)
Motorala MC-6801


3. The First electronic computer was completed in __________.




Answer is D)
1946

4. What is the microprocessor comprises:




Answer is C)
All of these

5. Customized ROMS are called




Answer is D)
Mask ROM

6. Each memory location has




Answer is D)
Both a and b

7. Which of the following memory medium is not used as main memory system?




Answer is A)
Magnetic tape

8. One of the main feature that distinguish microprocessors from micro-computers is




Answer is B)
Microprocessor does not contain I/O devices

9. An integrated circuit is




Answer is A)
Fabricated on a tiny silicon chip

10. Most important advantage of an IC is its




Answer is C)
Extremely high reliability

11. Which of the following items are examples of storage devices?




Answer is A)
All of the these

12. Before a disk can be used to store data. It must be…….




Answer is D)
Formatted

13. What are the three decisions making operations performed by the ALU of a computer?




Answer is B)
All of the these

14. What is the responsibility of the logical unit in the CPU of a computer?




Answer is C)
To compare numbers

15. The secondary storage devices can only store data but they cannot perform




Answer is C)
Either of the these

16. Which of the following memories allows simultaneous read and write operations?




Answer is C)
RAM

17. A 32 bit microprocessor has the word length equal to




Answer is B)
4 byte

18. The instructions for starting the computer are house on




Answer is B)
Read only memory chip

19. The ALU of a computer normally contains a number of high speed storage element called




Answer is C)
Registers

20. Which of the following terms is the most closely related to main memory?




Answer is A)
Temporary

21. In which form CPU provide output:




Answer is C)
Digital signals

22. A nibble can be represented in the from of:




Answer is B)
Hexadecimal

23. Pseudo instructions are basically




Answer is B)
assembler directives

24. EPROM is generally erased by using




Answer is D)
Ultraviolet rays

25. Signal voltage ranges for a logic high and for a logic low in RS-232C standard are




Answer is C)
Low =-15 volt to –3 vol, high = +3 volt to +15 volt

26. The first modern computer was called_____________




Answer is B)
ENIAC

27. The first task of DOS operating system after loading into the memory is to use the file called___________




Answer is C)
CONFIG.SYS

28. A microprocessor without the interrupt facility




Answer is C)
is not useful for process control system

29. The multiplexing of address bus and data buses are used in microprocessor




Answer is B)
to reduce the number of pins

30. A bus connected between the CPU and main memory that permits transfer of information between main memory and the CPU is known as




Answer is C)
Memory bus

Related Link