Question: Write an assembly program with the following functionality. The program generates two random numbers in the range 1 1 - 9 9 and computes their
Write an assembly program with the following functionality. The program generates two random numbers in the range and computes their sum and also asks the user to compute the sum. The user got seconds to type in the answer. If no user response is obtained within seconds, the program reports timeout and starts over. Otherwise, the program verifies user's answer, prints the corresponding report and starts over. This way the program can be used for training users to add integers without using calculators
Here is a sample dialog with a user, where all numbers to the right of the sign are user input:
Correct! Incorrect! Right answer is here timeout occurred Timeout. Answer is Correct!
Implement timeouts with RTCCCC channel and detect keyboard key presses by using USARTRX hardware interrupt and its processing in NVIC. For this you may modify ReadChar and ReadInt routines from the Terminal.lib library. Your program must have no polling loops which implies that RTCC interrupts must be also processed in NVIC and CPU must be put in sleep mode with wfi instruction while waiting for the user's input or timeout.
Hint: use software random number generator that generates next random number in the range according to the recursive formula
rand rand
Before generating the random numbers initialize variable rand with Recursive implementation of the random number generator is not required.
Write it in this format:
INCLUDE EFRBGinc ; CPU register definitions
INCLUDE terminal.inc ; terminal function definitions
EXPORT main
IMPORT LETIMERsetup ; import names from other code files
IMPORT GPIOsetup
; ; noninitialized DATA segment in RAM
AREA RAM, DATA, NOINIT, READWRITE, ALIGN
;myWord SPACE ; bit variable MUST BE ALIGHED!
;myHalf SPACE ; bit variable MUST BE ALIGHED!
;myByte SPACE ; bit variable NO alighment required
; ; CODE segment in flash ROM
AREA text CODE, READONLY
main PROC ; main user code
bl Terminalsetup ; setup TeraTerm communication
; bl GPIOsetup ; configure port pins
; bl LETIMERsetup ; start sec timer for periodic events
; your code starts here
loop ; periodic task starts here
b loop ; repeat periodic task
ENDP
;
;prompt DCB "Enter a number: ; allocate constant strings here
ALIGN
;constW DCD ; initialized bit constant
;constH DCW ; initialized bit constant
;constB DCB ; initialized bit constant
ALIGN
END
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
