Using MSP430 a) Write an assembly program that first initializes two 16-bit sign
ID: 3787971 • Letter: U
Question
Using MSP430
a) Write an assembly program that first initializes two 16-bit signed integers, “Items” and “Cost”. This program will be responsible for passing data to the two subroutines created in part b and part c of this assignment.
b) Create a subroutine, called SW_COST, that determines the total price of a customer’s order by multiplying the number of items by the cost per item. You may use the multiplication technique of your choice. The parameters (Items and Cost) should be passed to the subroutine using registers and the result stored in R12.
c) Create a second subroutine, called HW_COST, that determines the cost of a customer’s order using the hardware multiplier. The parameters (Items and Cost) should be passed to the subroutine using the stack and the result should be stored in R14.
d) Assess the performance of the subroutines by monitoring the clock cycle counter in the IAR Workbench for both subroutines. Include these clock cycle counts as part of your lab submission.
Explanation / Answer
Hi
Please find the code for the ITEM and COST initiaalisation
and SW_COST and HW_COST subroutine and for the performance cycles count below
Data segment
Items DW ?
cost DW ?
R12 DB ?
R14 DB ?
r0 DB 10,15,"ENTER Item value: $"
r1 DB 10,15,"ENTER cost of the item : $"
MSG3 DB 10,15,"RESULT OF Multiplication IS : $"
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
MOV AX,DATA
2) MOV DS,AX
start MOV r0, #10 ; Set up parameters
MOV r1, #15
BL SW_COST ; Call subroutine
BL HW_COST
stop MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SVC #0x123456 ; ARM semihosting (formerly SWI)
MOV RESULT, R0
SW_COST LEA DX,AL
MUL r0, r1 ; Subroutine code
MOV R12, AL
BX lr ; Return from subroutine
END
3)
start MOV r0, #10 ; Set up parameters
MOV r1, #15
BL SW_COST ; Call subroutine
HW_COST LEA DX,AL
DIV r0, r1 ; Subroutine code
MOV R14, AL
BX lr ; Return from subroutine
END
4)
MOV BH,5
MOV Cycles to BH
INT count
ENDS
END START
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.