0% found this document useful (0 votes)
36 views4 pages

PROGRAM: Generation of Fibonacci Series

The program generates the Fibonacci series by initializing registers B and C to store the previous and current numbers. It uses a loop to repeatedly add the previous and current numbers, store the result as the new current number, and output the numbers to memory by incrementing the H-L pointer. It halts when the counter reaches zero. The second program sorts an array stored in memory in ascending order. It uses two loops - the outer loop iterates through each element and the inner loop performs swaps to put the current element in its sorted position. It compares each element to the next, swapping if out of order, and increments/decrements registers and pointers to progress through the array and loops.

Uploaded by

Anonymous kqGARZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

PROGRAM: Generation of Fibonacci Series

The program generates the Fibonacci series by initializing registers B and C to store the previous and current numbers. It uses a loop to repeatedly add the previous and current numbers, store the result as the new current number, and output the numbers to memory by incrementing the H-L pointer. It halts when the counter reaches zero. The second program sorts an array stored in memory in ascending order. It uses two loops - the outer loop iterates through each element and the inner loop performs swaps to put the current element in its sorted position. It compares each element to the next, swapping if out of order, and increments/decrements registers and pointers to progress through the array and loops.

Uploaded by

Anonymous kqGARZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

PROGRAM: Generation of Fibonacci series.

Address
2000

Mnemonics
MVI

Operand
D, 08H

2001

Opcode
16

Remarks
Initialize counter to display numbers in series.

08

Immediate value 07H.

06

Initialize reg. B to store previous number.

00

Immediate value 00H.

0E

Initialize reg. C to store current number.

01

Immediate value 01H.

21

Initialize H-L pair to point to memory.

2007

00

Lower-order of 3000H.

2008

30

Higher-order of 3000H.

2002

MVI

B, 00H

2003
2004

MVI

C, 01H

2005
2006

LXI

H, 3000H

2009

MOV

M, B

70

Move 00H from reg. B to memory.

200A

INX

23

Increment H-L pair.

200B

MOV

M, C

71

Move 01H from reg. C to memory.

200C

MOV

A, B

78

Move previous number from reg. B to reg. A.

200D

ADD

81

200E

MOV

B, C

41

Add the two numbers.


Assign current number to previous number.

200F

MOV

C, A

4F

Save result as new current number.

2010

INX

23

Increment H-L pair.

2011

MOV

M, A

77

Move number from reg. A to memory.

2012

DCR

15

Decrement counter.

2013

JNZ

200DH

C2

Jump to address 200DH if counter is not zero.

2014

0D

Lower-order of 200DH.

2015

20

Higher-order of 200DH.

76

Halt.

2016

HLT

PROGRAM: Sort the array in ascending order.


Address
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
200A
200B
200C
200D
200E
200F

Mnemonics
MVI

Operand
B, 05H

MVI

C, 05H

LXI

H, 3000H

MOV
INX
CMP
JC

A, M
H
M
2015H

JZ

2015H

2010

MOV

D, M

56

2011
2012
2013
2014
2015
2016
2017
2018
2019
201A
201B
201C
201D

MOV
DCX
MOV
INX
DCR
JNZ

M, A
H
M, D
H
C
2007H

DCR
JNZ

B
2002

77
2B
72
23
0D
C2
07
20
05
C2
02
20
76

HLT

Opcode
06
05
0E
05
21
00
30
7E
23
BD
DA
15
20
CA
15
20

Remarks
Initialize counter-1.
Immediate value 05H.
Initialize counter-2.
Immediate value 05H.
Load H-L pair with address 3000H.
Lower-order of 3000H.
Higher-order of 3000H.
Move the number from memory to reg. A.
Increment H-L pair.
Compare the number with next number.
Dont interchange if number < next number.
Lower-order of 2015H.
Higher-order of 2015H.
Dont interchange if number = next number.
Lower-order of 2015H.
Higher-order of 2015H.
Otherwise, swap the numbers. Move next
number from memory to D.
Move first number from A to memory.
Decrement H-L pair.
Move next number from D to memory.
Increment H-L pair.
Decrement counter 2.
If counter-2 0, repeat.
Lower-order of 2007H.
Higher-order of 2007H.
Decrement counter-1.
If counter-1 0, repeat.
Lower-order of 2002H.
Higher-order of 2002H.
Halt.

You might also like