Advertisements
Advertisements
Question
Write an Assembly Language Program to generate the Fibonacci number upto 5 terms.(Fibonacci terms – 00H, 01H, 01Н, 02Н, 03H)
Very Long Answer
Advertisements
Solution
| Label | Instructions | Comment |
| LXI H 7000H | ; Set HL pair 7000H | |
| MVI D, 03H | ; Move OOH to Reg. B | |
| MVI B, OOH | ; Move data 03 H to Reg. D | |
| MOV M, B | ; Move 1st number to memory 7000H | |
| CYCLE | IHX H | ; Increment Reg. HL by one |
| MVIC, 01 H | ; Move 01H to Reg. C | |
| MOV M, C | ; Move Reg. C to M | |
| INX H | ; Increment Reg. pair HL by 1 | |
| MOV A, B | ; Move B to Acc | |
| ADD C | ; Add C to Acc | |
| MOV M, A | ; Move Acc to M | |
| MOV B, C | ; Move Reg. C to Reg. B | |
| MOV C, A | ; Move Reg. A to Reg. С | |
| DCR D | ; Decrement Reg. D by one | |
| INZ Cycle | ; If D ≠ 0 go to cycle | |
| HLT | ; STOP |
shaalaa.com
Is there an error in this question or solution?
