Question: Can you write under this template: ; File: HA 5 - main.s ; Student Name: EXPORT main ; this line is needed to interface with

Can you write under this template:
; File: HA5-main.s
; Student Name:
EXPORT main ; this line is needed to interface with init.s
IMPORT GetCh ; Input one ASCII character from the UART #1 window (from keyboard)
IMPORT PutCh ; Output one ASCII character to the UART #1 window
IMPORT PutCRLF ; Output CR and LF to the UART #1 window
IMPORT UDivMod ; Perform unsigned division to obtain quotient and remainder
IMPORT GetDec ; Input a signed number from the UART #1 window
IMPORT PutDec ; Output a signed number to the UART #1 window
IMPORT GetStr ; Input a CR-terminated ASCII string from the UART #1 window
IMPORT PutStr ; Output null-terminated ASCII string to the UART #1 window
AREA MyCode, CODE, READONLY
ALIGN
main
PUSH {LR}
POP {PC}
ALIGN
END ; end of source program in this file
This is the reference that you can reviews for the Calculation B
; File: HA4-main.s
; Student's Name:
; This file needs to be in a Keil version 5 project, together with file init.s
; This is an initial demo program for HA4, which you need to change to complete HA4
; All future CS 238 Home Assignments, will have similar but different files,
; like HA5-main.s, HA6-main.s, etc.
; Executable code in HAx-main.s files should start at label main
EXPORT main ; this line is needed to interface with init.s
; Usable utility functions defined in file init.s
; Importing any label from another source file is necessary
; in order to use that label in this source file
IMPORT GetCh ; Input one ASCII character from the UART #1 window (from keyboard)
IMPORT PutCh ; Output one ASCII character to the UART #1 window
IMPORT PutCRLF ; Output CR and LF to the UART #1 window
IMPORT UDivMod ; Perform unsigned division to obtain quotient and remainder
IMPORT GetDec ; Input a signed number from the UART #1 window
IMPORT PutDec ; Output a signed number to the UART #1 window
IMPORT GetStr ; Input a CR-terminated ASCII string from the UART #1 window
IMPORT PutStr ; Output null-terminated ASCII string to the UART #1 window
AREA MyCode, CODE, READONLY
ALIGN ; highly recommended to start and end any area with ALIGN
; Start of executable code is at following label: main
main
;-------------------- START OF MODIFIABLE CODE ----------------------
PUSH {LR} ; save return address
; Prompt for the number of terms n
LDR R0,=Prompt1
BL PutStr ; display prompt for number of terms
BL GetDec ; read number into R0
MOV R1, R0 ; store input number in R1
; Calculate the sum using the formula: n *(n +1)/2
ADD R2, R1, #1 ; R2= n +1
MUL R2, R2, R1 ; R2= n *(n +1)
; Divide by 2 to get the sum
MOV R0, R2 ; Move product (n *(n +1)) to R0 for division
MOV R1, #2 ; R3=2
BL UDivMod ; R0= quotient (R2/2), R1= remainder (ignored)
; Output the result
LDR R0,=ResultMsg
BL PutStr ; display result message
MOV R0, R1 ; move result to r0
BL PutDec ; display result
; Final message
LDR R0,=ByeMsg
BL PutStr ; display goodbye message
POP {PC} ; return from main
; Some commonly used ASCII codes
CR EQU 0x0D ; Carriage Return (to move cursor to beginning of current line)
LF EQU 0x0A ; Line Feed (to move cursor to same column of next line)
; The following data items are in the CODE area,
; so they are all READONLY (i.e. cannot be modified at run-time),
; but they can be initialized at assembly-time to any value
Prompt1 DCB "Please enter the number of terms in your series: ",0
ResultMsg DCB "The sum of your series is ",0
ByeMsg DCB "Bye!", 0
ALIGN
; The following data items are in the DATA area,
; so they are all READWRITE (i.e. can be modified at run-time),
; but are automatically initialized at assembly-time to zeroes
AREA MyData, DATA, READWRITE
ALIGN
MaxName EQU 1000 ; your name better be within 1000 characters :)
Name SPACE MaxName +1 ; storage space for name (and NULL byte at end)
Value SPACE 4 ; 4 bytes for storing input number
;-------------------- END OF MODIFIABLE CODE ----------------------
ALIGN
END ; end of source program in this file
Can you write under this template: ; File: HA 5 -

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!