Concept explainers
- Print first 2 Fib values (0, 1) before starting
- These are hard-coded since they are starting values...no calculations required
- Enter MainLoop
- Loop and call subroutines to calculate each subsequent value in the sequence
- Exit the loop once all single-digit values in the sequence have been printed
- USE 3 subroutines
- calcNextFib Uses R1 and R2 to calc next value in Fibonacci sequence
- printNum Outputs single-digit number to the display
- printCommaSpace Outputs a comma and a spaceCalculate all the single-digit Fibonacci numbers in order
- Start with the first 2 values in the sequence (0, 1)
- Calculate the next value by adding together the two largest values
- Print each number in the sequence
- With a comma and space after each
- No comma after the last number
- Use LC-3 I/O device to print number, commas, and spaces
- NO numbers printed using Trap Routine
- should check ddr, dsr , load and store
modify the code to work using ALL Guidelines
For each Calculation:
; Fib2 = Fib1 + Fib2 ; Fib1 = previous Fib2
; R0 used for PUTS messages
; R1 contains current Fib1 value
; R2 contains current Fib2 value
; R6 is loop counter for main loop
; R7 is not used by this program. Used by Simulate for TRAP and Subroutines
.ORIG x3000
Setup
LEA R0, Info
PUTS
ADD R6, R6, #5; Init Main Loop counter (loop 5 times)
;Print first 2 Fib values before starting
;----- Your Code Here -----;
;----- End Your Code Here -----;
;Loop and call subroutines to calculate each subsequent value in the sequence
;Exit the loop once all single-digit values in the sequence have been printed
MainLoop
;----- Your Code Here -----;
;----- End Your Code Here -----;
Done
HALT
;----------------------------------- ;Subroutines ;-----------------------------------
;Uses R1 and R2 to calc next value in Fibonacci sequence
;When complete, Fib2 (R2) will contain the new Fib number
;and Fib1 (R1) will contain the previous value of Fib2 (R2)
calcNextFib
;----- Your Code Here -----;
;----- End Your Code Here -----;
RET
;Outputs single-digit number to the display
;R2 contains number to
print printNum
;----- Your Code Here -----;
;----- End Your Code Here -----;
RET
;Outputs a comma and a space
;No data is passed in and no data is returned
printCommaSpace
;----- Your Code Here -----;
;----- End Your Code Here -----;
RET
;End of Program
;Data Declarations-------------
DSR .FILL xFE04
DDR .FILL xFE06
Info .STRINGZ "This program will print the first 6 characters of the Fibboncci Sequence\n"
ASCIIOFSET .FILL x0030
NegASCIIOFSET .FILL xFFD0
ASCIINewline .FILL x000d ; Newline ascii code
ASCIISpace .FILL x0020 ; Space ascii code
ASCIIComma .FILL x002C ; Comma ascii code
; Memory slots for subrountines to store/restore registers
; You may or may not need to use all of these
SaveR3 .BLKW 1
SaveR4 .BLKW 1
SaveR5 .BLKW 1
SaveR6 .BLKW 1 .
.END
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
- Computer Science Write correct Python code to complete the following task. Document all assumptions. Solutions that do not incorporate a loop will receive a grade of 0. Obtain a positive integer greater than 1 but less than 20 from the user. Calculate the product of all numbers starting from the user's number up to, and including 100. If the number is evenly divisible by 7, do not include it in the product. If the product is more than or equal to 5000 stop the loop early and show the message "a big product". When the loop ends, if the product is less than 5000 show the product to the user.arrow_forwardDefine a function named get_pattern_number() which promps the user to input an integer which is between 0 and 8 (inclusive). If the user enters an invalid value, the function continues to prompt the user to enter the number (using a while loop) until the number entered is valid. The function returns the valid number. For example: Test Input Result print (get_pattern_number()) 50 Enter a number (0-8): 50 Enter a number (0-8): 25 25 -12 Enter a number (0-8): -12 Enter a number (0-8): -1 -1 9 Enter a number (0-8): 9 2 Enter a number (0-8): 2 2 Enter a number (0-8): 8 value = get_pattern_number() 8 print (value) 8 print (type(value))arrow_forwardComputer Science The script below demonstrates a very basic loop structure. Indicate the value of R1 after 5 iterations of the loop. (Given the very first line of code, you can assume R1 starts out as 0x00)arrow_forward
- Design the logic for a program either by pseudocode or flowchart that allows the user to enter a maximum of 10 numbers. If the use enters a -1 the input loop stops early. The value -1 is not data but a quit(sentinel) flag value that is not entered into the array. Then, the program displays the count of the numbers entered and numeric average of the numbers (not including the -1 of course). After display the average of all the entered numbers, the program will then display each number and its difference from that average.arrow_forward#1 Name Use a loop to write your name ten times #7 Namecount Redo #1 but every time you print your name out also print out the value of the loop counter(for example the first three lines might look like this) do this ten times Patti K 0 Patti K 1 Patti K 2arrow_forwardThe main difference between using do/while loop and while loop is that while loop executes the code block once then it checked if the condition is true so it will repeat the loop. True Falsearrow_forward
- Week runners log Coding in Python and mainly using loops create a program base on the following; Mike, Tina, Jason, Vicky, and Tammy are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day, Write a program to help them analyze their data. Your program should create a two-dimensional list of five rows and seven columns to store the number of miles run by each runner each day. Sample Output Name Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 7 Average =============================================Mike 10.00 15.00 20.00 25.00 18.00 20.00 26.00 19.14Tina 15.00 18.00 29.00 16.00 26.00 20.00 23.00 21.00Jason 20.00 26.00 18.00 29.00 10.00 12.00 20.00 19.29Vicky 17.00 20.00 15.00 26.00 18.00…arrow_forwardNeed help to do this type of questions for Excel and provide the steps as that given.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education