0% found this document useful (0 votes)
4 views

Exercise-6(Fibonacci)

The document outlines an exercise for a Microprocessors and Microcontroller Lab at Presidency University, Bengaluru, focusing on writing an Assembly Language Program (ALP) to print N Fibonacci numbers. It details the initialization of Fibonacci series values, input handling, and the looping mechanism to generate the series. Additionally, it provides steps to execute the Assembly Language program using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Exercise-6(Fibonacci)

The document outlines an exercise for a Microprocessors and Microcontroller Lab at Presidency University, Bengaluru, focusing on writing an Assembly Language Program (ALP) to print N Fibonacci numbers. It details the initialization of Fibonacci series values, input handling, and the looping mechanism to generate the series. Additionally, it provides steps to execute the Assembly Language program using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

PRESIDENCY UNIVERISTY, BENGALURU

School of Engineering

Microprocessors and Microcontroller Lab


CSE 254

IV Semester 2018-19
Exercise-6

Write an ALP to print N Fibonacci numbers


Exercise
Description
• Initial two values of Fibonacci series are 0 and 1 and are
loaded in AX and BX respectively.
• Required size of series is given as input through
Keyboard.
• Input value’s ASCII value will be considered, which
should be converted in HEX value by SUB AL,30H
• The decimal numbers in ASCII have a code from 30H
(“0”) to 39H (“9”). When we add two ASCII numbers, the
result will not be in ASCII. The AAA instruction will
adjust the result of addition to a BCD digit
• Load size in CL register
• Adding the two successive terms in series will generate
the next term in series, i.e, fib3=fib1+fib2
• Re-initialize the values of fib1 & fib2 in every iteration in
LOOP to generate new term in series
• Continue the process of Fibonacci series generation till
CL=0
.MODEL SMALL
MOV [SI],AX
.DATA
INC SI
FIB DB ?
MOV [SI],BX
MSG DB 10d,13d,"ENTER HOW MANY FIB YOU WANT : $"
INC SI
.CODE
SUB CL,02H
MOV AX,@DATA
;Fibonacci Part
MOV DS,AX
L1:ADD AX,BX
LEA SI,FIB
; obtain 1st fib number from default
LEA DX,MSG ; To print message on screen numbers
MOV AH,09H DAA
INT 21H ; Used to Present the value in Decimal
Form
MOV AH,01H ; To read value from keyboard
MOV [SI],AX
INT 21H
; move 1st fib number to FIB array
SUB AL,30H
MOV AX,BX ; then ax=bx, bx=res[si]
MOV CL,AL ; Load the count value in CL for looping
MOV BX,[SI]
MOV AX,00H ; Starting of series 1 number
st
INC SI
MOV BX,01H ; Starting of series 2 nd
number
LOOP L1
INT 3H
END
Steps to Execute Assembly Language programs
1) Install DOSBOX 0.74

2) Launch DOSBOX, By default it will be in Z drive <Z:\>


3) Change the drive to that, in which MASM is installed
mount c c:\masm
4) C:
5) C:\> Edit filename.asm
6) C:\> Masm filename.asm;
7) C:\> Link filename.obj;
8) C:\> CV filename.exe
Execute by typing G in command window
THANK YOU

You might also like