Question: comment | ; * * * * * * * * * * * * Assembler : Borland TASM 3 . 0 File Name :
comment
;
Assembler : Borland TASM
File Name : Pasm
Input : One integer for Fib numbers
Output : Confirmation of user input.
Input Files : None
Output Files: None
PROCEDURES CALLED:
External procedures called:
FROM iofar.lib: PutCrLf, GetDec, PutDec
Internal procedures called: Fib
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: $
invalidMS db invalid input, try again"
inputVer db 'You input the integer: $
endPrompt db 'Ending...$
Msg db 'Num is: $
Msg db 'Num is: $
; 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
INPUT:
; Prompts the user for a count variable.
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
jle INPUT
; 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
call Fib ;calls the Fibonacci procedure
mov ahch
int h
Programm ENDP
comment
; PROCEDURE HEeader
PROCEDURE NAME : Greet
PURPOSE : Prints out the name, the date and the goal of this program.
INPUT PARAMETERS :
OUTPUT PARAMETERS or RETURN VALUE: None
NONLOCAL VARIABLES REFERENCED: None
NONLOCAL VARIABLES MODIFIED :None
PROCEDURES CALLED :
FROM iofar.lib: PutCrLf
CALLED FROM : main program
; SUBROUTINE DATA SEGMENT
data
PrgmMsg db 'Progra$
NameMsg db $
DateMsg db 'Date: $
; SUBROUTINE CODE SEGMENT
code
Greet PROC near
; Save registers on the stack
pusha
pushf
; Print name of program
mov dx OFFSET PrgmMsg ; set pointer to st greeting message
mov ah ; DOS print string function #
int h ; print string
call PutCrLf
; Print name of programmer
mov dx OFFSET NameMsg ; set pointer to nd greeting message
mov ah ; DOS print string function #
int h ; print string
call PutCrLf
; Print date
mov dx OFFSET DateMsg ; set pointer to rd greeting message
mov ah ; DOS print string function #
int h ; print string
call PutCrLf
; Restore registers from stack
popf
popa
; Return to caller module
ret
Greet ENDP
comment
; PROCEDURE HEADER
PROCEDURE NAME : Fibonacci Sequence Fib
PURPOSE :Fibonacci Sequence
INPUT PARAMETERS : OUTPUT PARAMETERS or RETURN VALUE: None
NONLOCAL VARIABLES REFERENCED:
NONLOCAL VARIABLES MODIFIED :
PROCEDURES CALLED : None
CALLED FROM :
; SUBROUTINE CODE SEGMENT
code
Fib PROC near
push bp
mov bp sp
cmp Count,
je L;
Outputs Num before any changes.
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
call PutCrLf
;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 ;
jmp RETURN
; Outputs Num before any changes.
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
call PutCrLf
; Outputting Num to clarify stack values.
mov dx OFFSET Msg ;
mov ah ; DOS print string function #
int h ; print string
mov axbp ;brings Num out for output
call PutDec
call PutCrLf
jmp RETURN
RETURN:
pop bp
ret
jmp Ending
Ending:
mov dx OFFSET endPrompt ; set pointer to location move
mov ah ; DOS print string function #
int h ; print string
call PutCrLf
Fib ENDP
end Programm
Please solve this code that it work with bit integer, will not work with or negative number. And the base case will be The sequence will start with not like Please do not change the pattern of this code. Just add some code with the provided code which will work with the conditions. And must be work with TASM and DOSBOX
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
