this code needs to display: This program will print the first 6 characters of the Fibboncci Sequence 0, 1, 1, 2, 3, 5, 8 so far it is only displaying This program will print the first 6 characters of the Fibboncci Sequence 0 0 i am not sure why this code is not working to display the numbers, what is wrong with this code( LC3 Assembly language stimulate) .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 -----; LD R1, #0 ; Load the value 0 into R1 OUT ; Output the value in R1 (0) LD R2, #1 ; Load the value 1 into R2 OUT ; Output the value in R2 (1) ;----- 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 -----; ; Calculate next Fibonacci value JSR calcNextFib JSR printNum ; Print the calculated Fibonacci value JSR printCommaSpace ; Decrement loop counter ADD R6, R6, #-1 BR MainLoop ;----- 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 -----; ST R1, SaveR3 ; Save R1 ST R2, SaveR4 ; Save R2 ADD R1, R1, R2 ; Fib1 = previous Fib2 ADD R2, R2, R1 ; Fib2 = Fib1 + Fib2 LD R0, SaveR4 ; Restore R2 LD R1, SaveR3 ; Restore R1 ; Return from subroutine ;----- End Your Code Here -----; RET ;Outputs single-digit number to the display ;R2 contains number to print printNum ;----- Your Code Here -----; LDI R0, ASCIIOFSET ; Load immediate value (ASCIIOFSET) to R3 ADD R0, R0, R2 ; Convert to ASCII ST R2, DDR ; Output to display ;----- 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 -----; LDI R0, ASCIIComma ; Load ASCIIComma to R3 ST R0, DDR ; Output comma ADD R0, R0, #1 ; Increment DDR to point to the next memory location LDI R0, ASCIISpace ; Load ASCIISpace to R3 ST R0, DDR ; Output space ;----- 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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.4: Program Input Using Cin
Problem 9E
icon
Related questions
Question

this code needs to display:

This program will print the first 6 characters of the Fibboncci Sequence

0, 1, 1, 2, 3, 5, 8

so far it is only displaying

This program will print the first 6 characters of the Fibboncci Sequence

0 0

i am not sure why this code is not working to display the numbers, what is wrong with this code( LC3 Assembly language stimulate)

.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 -----;
LD R1, #0 ; Load the value 0 into R1
OUT ; Output the value in R1 (0)

LD R2, #1 ; Load the value 1 into R2
OUT ; Output the value in R2 (1)
;----- 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 -----;
; Calculate next Fibonacci value
JSR calcNextFib
JSR printNum
; Print the calculated Fibonacci value
JSR printCommaSpace

; Decrement loop counter
ADD R6, R6, #-1

BR MainLoop



;----- 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 -----;
ST R1, SaveR3 ; Save R1
ST R2, SaveR4 ; Save R2

ADD R1, R1, R2 ; Fib1 = previous Fib2
ADD R2, R2, R1 ; Fib2 = Fib1 + Fib2

LD R0, SaveR4 ; Restore R2
LD R1, SaveR3 ; Restore R1

; Return from subroutine
;----- End Your Code Here -----;
RET

;Outputs single-digit number to the display
;R2 contains number to print
printNum
;----- Your Code Here -----;
LDI R0, ASCIIOFSET ; Load immediate value (ASCIIOFSET) to R3
ADD R0, R0, R2 ; Convert to ASCII
ST R2, DDR ; Output to display
;----- 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 -----;
LDI R0, ASCIIComma ; Load ASCIIComma to R3
ST R0, DDR ; Output comma
ADD R0, R0, #1 ; Increment DDR to point to the next memory location
LDI R0, ASCIISpace ; Load ASCIISpace to R3
ST R0, DDR ; Output space

;----- 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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning