Question: INCLUDELIB iofar ; * * * * * * BEGIN MAIN PROGRAM * * * * * * * * DOSSEG . 1 8 6
INCLUDELIB iofar
; BEGIN MAIN PROGRAM
DOSSEG
model large
stack h
; MAIN PROGRAM DATA SEGMENT
data
Count dw
Num dw
Num dw
promptCount db 'Input an integer between to : $
invalidMS db invalid input, try again'
inputVer db 'You input the integer: $
Msg db 'The fiabonacci series: $
Msg db $
; MAIN PROGRAM CODE SEGMENT
code
extrn PutStr: PROC, PutCrLf: PROC
extrn GetDec: PROC, PutDec: PROC
Programm PROC near
; Initialize ds register to hold data segment address
mov ax @data
mov ds ax
;Pushes Num & Num onto the stack.
push Num
push Num
call Greet
; Prompts the user for a count variable.
INPUT:
mov dx OFFSET promptCount ; point to the Prompt mesg
mov ah ;DOS print string function #
int h ; print string
call GetDec
mov Count, ax ;moves the Count variable into ax
cmp ax
jl invalid
; Verification that the input was correct.
mov dx OFFSET inputVer ; point to the Prompt mesg
mov ah ; DOS print string function #
int h ; print string
mov ax Count ;retrieves the Count variable for callback.
call PutDec ;displays the number if correct.
call PutCrLf
mov dx OFFSET Msg ; set pointer to st greeting message
mov ah ; DOS print string function #
int h ; print string
call PutCrL
call Fib ;calls the Fibonacci procedure
mov ahch
int h
invalid:
mov dx OFFSET invalidMS ; point to the Prompt mesg
mov ah ; DOS print string function #
call PutCrLf
jmp INPUT
Fib PROC near
push bp
mov bp sp
cmp Count,
jle L
; Outputs Num before any changes.
mov axbp ;brings Num out for output
CALL PutDec
;This block is responsible for the Fibonacci numbers
push bp ;pushes Num onto the stack
mov axbp ;moves Num over to ax
add axbp ;Num Num
push ax ;pushes the result onto the stack.
dec Count ;will decrement count after the math is finished.
call Fib ;this should call this procedure again.
jmp RETURN
L:
; Outputs Num before any changes.
mov axbp ;brings Num out for output
call PutDec
cmp Count,
je RETURN
; Outputting Num to clarify stack values.
mov dx OFFSET Msg ; set pointer to st greeting message
mov ah ; DOS print string function #
int h ; print string
mov axbp ;brings Num out for output
call PutDec
jmp RETURN
RETURN:
pop bp
ret
THIS IS A CODE OF FIBONACCI SERRIES IN ASSEMBLY LANGUAGE.
WILL PLEASE EVERY LINE AND HOW ITS WORKING. ALSO PROVIDE WHATS THE OUTPUT WILL BE
THANK YOU
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
