Calculate the factorial of a number | 8086 Microprocessor

PROGRAM NO.4

OBJECT:Write a program to calculate the Factorial of a Number.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
PROGRAM:

MEMORY LOCATION MACHINE CODE OPCODE OPERAND
0204 BE 00 02 MOV SI,0200H
0207 8B 04 MOV AX,[SI]
0209 8B D8 MOV BX,AX
020B 4B DEC BX
020C F7 E3 L1 : MUL BX
020E 4B DEC BX
020F 75 FB JNZ L1  
0211 BF 02 02 MOV DI,0202H
0214 89 05 MOV [DI],AX
0216 F4 HLT  

DESCRIPTION:

To solve the given objective we have taken a hexadecimal number in the memory location of 0200H and multiplied it successively to obtain the factorial.

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

  1. Move the source index register (SI) pointer to the location of the number.
  2. Store the number in the AX register using SI.
  3. Move the same number in the BX register to act as a counter.
  4. Decrement BX to get the next number to be multiplied.
  5. Multiply the number in BX and AX recursively and decrement BX simultaneously to get the factorial eventually.
  1. Move the destination index (DI) pointer to point to the memory location where the result is to be stored.
  2. Finally move the result from the AX register to the destination using DI and Halt.

INPUT VALUE:

MEMORY LOCATION VALUE
0200H 05
0201H 00
0202H 00
0203H 00

OUTPUT:

MEMORY LOCATIONVALUE
0202H78
0203H00

RESULT:The factorial of the hexadecimal number 0005H comes out to be as 0078H, which gets stored in the memory location 0202H.

COMMENTS:

  1. MOV SI,0200H: 16 bit data can be moved using immediate addressing. 0200 is moved to source index.
  2. MUL BX: This instruction is used for the multiplication of 2 unsigned numbers. It multiplies the content of BX with AX and stores in AX.
  3. DEC BX: This instruction decrements specified 16-bit register by one.
  4. JNZ: It causes the program execution to jump to the label given in the instruction.
  5. HLT: This instruction stops program execution. The processor stops fetching and executing instructions.

FLOWCHART:

Calculate the factorial of a number  8086 Microprocessor


Most Important Question for Exam

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




Answer is A
Magnetic tape


2. Register, which are partially visible to users and to hold conditional, are known as




Answer is B)
General purpose register


3. One of the main feature that distinguish Microprocessor from Micro-computer is




Answer is D)
Microprocessor dos not contain I/O devices

4. The First Microprocessor built by the Intel Corporation was called




Answer is B)
4004

5. An integrated circuit is




Answer is A)
Fabricated on a tiny silicon chip

6. Most important advantage of an IC is its




Answer is C)
Extremely high reliablity

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




Answer is A)
All of the these

8. The width of a processor’s data path is meausred in bits of the following are common data paths?




Answer is D)
8 bit

9. Which is the type of memory for information on your Computer?




Answer is C)
ROM

10. What type of memory is not directly addressable by the CPU and requires special softwaqre called EMS (Expanded Memory Specification) ?




Answer is C)
Expanded

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




Answer is D)
Formatted

12. Which company is the biggest player in the Microprocessor industry?




Answer is B)
Intel

13. A typical personal computer used for business purpose would have…of ROM.




Answer is A)
256 K

14. The word length of a computer is measured in




Answer is A)
Bits

15. What are the three decision making operation performed by the ALU a computer?




Answer is A)
All of these

16. Which part of the computer is used for calculating and comparing?




Answer is B)
ALU

17. Can you tell what pass into and out from the computer via its ports?




Answer is C)
Data

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




Answer is C)
To compare numbers

19. The secondary storage device can only data but they cannot perform




Answer is A)
Either of these

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




Answer is C)
RAM

21. Which of the following memories has the shortest access times?




Answer is D)
Cache memory

22. A 32 bit Microprocessor has the word length equal to




Answer is B)
4 byte

23. An error in computer data is called




Answer is C)
Bug

24. The silicon chip used for data processing are called




Answer is C)
ROM Chips

25. The metal disk, which are permanentaly housed in sealed and contamination free containers are called




Answer is B)
Winchester disk

26. The ALU of a computer normally contains a number of highs speed storage element called




Answer is C)
Register

27. The first digital computer built with IC chips was know as




Answer is B)
IBM System /360

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




Answer is A)
Temporary

29. Which of the following is used for manufaturer chips?




Answer is A)
Semiconductor

30. To locate the data item for storage is




Answer is B)
Fetch

Related Link