Question: INCLUDELIB iofar ; * * * * * * BEGIN MAIN PROGRAM * * * * * * * * DOSSEG . 1 8 6

INCLUDELIB iofar
;****** BEGIN MAIN PROGRAM ********
DOSSEG
.186
.model large
.stack 200h
;****** MAIN PROGRAM DATA SEGMENT *******
.data
Count dw ?
Num1 dw 1
Num2 dw 1
promptCount db 'Input an integer between 1 to 22: $'
invalidMS db ' invalid input, try again'
inputVer db 'You input the integer: $'
Msg1 db 'The fiabonacci series: $'
Msg2 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 Num1 & Num2 onto the stack.
push Num1
push Num2
call Greet
; Prompts the user for a count variable.
INPUT:
mov dx, OFFSET promptCount ; point to the Prompt mesg
mov ah,9 ;DOS print string function #
int 21h ; print string
call GetDec
mov Count, ax ;moves the Count variable into ax.
cmp ax,1
jl invalid
; Verification that the input was correct.
mov dx, OFFSET inputVer ; point to the Prompt mesg
mov ah,9 ; DOS print string function #
int 21h ; print string
mov ax, Count ;retrieves the Count variable for callback.
call PutDec ;displays the number if correct.
call PutCrLf
mov dx, OFFSET Msg1 ; set pointer to 1st greeting message
mov ah,9 ; DOS print string function #
int 21h ; print string
call PutCrL
call Fib ;calls the Fibonacci procedure
mov ah,4ch
int 21h
invalid:
mov dx, OFFSET invalidMS ; point to the Prompt mesg
mov ah,9 ; DOS print string function #
call PutCrLf
jmp INPUT
Fib PROC near
push bp
mov bp, sp
cmp Count,2
jle L1
; Outputs Num1 before any changes.
mov ax,[bp +6] ;brings Num1 out for output
CALL PutDec
;This block is responsible for the Fibonacci numbers
push [bp +4] ;pushes Num2 onto the stack
mov ax,[bp +6] ;moves Num1 over to ax
add ax,[bp +4] ;Num1+ Num2
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
L1:
; Outputs Num1 before any changes.
mov ax,[bp +6] ;brings Num1 out for output
call PutDec
cmp Count,1
je RETURN
; Outputting Num2 to clarify stack values.
mov dx, OFFSET Msg2 ; set pointer to 1st greeting message
mov ah,9 ; DOS print string function #
int 21h ; print string
mov ax,[bp +4] ;brings Num2 out for output
call PutDec
jmp RETURN
RETURN:
pop bp
ret 4
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!