CS计算机代考程序代写 database arm CSE/EE 5/7385 Microprocessor Architecture and Interfacing Laboratory 5: Status flags and arithmetic instructions

CSE/EE 5/7385 Microprocessor Architecture and Interfacing Laboratory 5: Status flags and arithmetic instructions
In this experiment, you will gain familiarity with using arithmetic instructions and how they affect the status flags.
Consider the following example ARM program:
AREA Lab5, CODE, READONLY ;name the block
ENTRY
mov r0, #15 mov r1, #20 bl FIRSTFUNC
FIRSTFUNC addsr0,r0,r1
mov pc, lr
STOP b STOP
END
;mark first instruction ;set up parameters ;call subroutine
;r0<-r0+r1 ;return from subroutine ;processing complete Step 1: Create the project and source files Make sure the MCBSTM32C board is connected to your computer through the ULINK-ME adapter and is properly powered. 1. Create a new directory named logic. From the μVision menu, create a new project called logic and save it in the logic project directory. 2. Select the microcontroller from the Device Database. Vendor: STMicroelectronics, Device: STM32F107VC 3. After selecting the device, μVision prompts with a dialog, Answer NO since we use a custom startup file for this project. 4. Go to the shared directory below, download the startup file to the project directory and add the startup file to the project. http://goo.gl/BB3mnx 5. Create a new file (File -> New) and save it as logic.s 6. Add logic.s to the project
STEP 1: Enter and assemble the above program and single-step through it. As you execute the program, monitor the contents of the registers (especially note the CPSR status flags) and observe what the program does.
STEP 2: Modify the program (3 different times) with the following operands, A and B, and use the program to evaluate A+B. Predict what you think the A+B value and values of the status flags will be before you execute the programs then check to see if your predictions are correct. Be sure you understand why the status flags are the values that result.
a) A=0xFFFF0000 B=0x87654321 b) A=0xFFFFFFFF B=0x12345678 c) A=0x67654321 B=0x23110000
1

STEP 3: Change the add instruction in the example code program above to a muls. Also change one of the operand registers so that the source registers are different from the destination register, as the convention for multiplication instructions requires. Put 0xFFFFFFFF and 0x80000000 into the source registers. Now rerun your program and check the result.
a) Does your result make sense? Why or why not?
b) Assuming that these two numbers are signed integers, is it possible to overflow in this case?
c) Why is there a need for two separate long multiply instructions, umull and smull? Give an example to support your answer.
STEP 4: Assume that a signed long multiplication instruction is not available. Write a program that performs long multiplications, producing 64 bits of result. Use only the umull instruction and logical operations such as mvn to invert, logical-XOR, and logical-OR. Run the program using the two operands –2 and –4 to verify.
Additional questions
1- The Current Program Status Register (CPSR) contains status flags. According to the result of an operation:
– When does an overflow occur?
– Give two scenarios that cause a carry to occur
2- An instruction with a condition code is only executed according to the status of the condition code flags. Which condition code suffix can be used in the following cases?
– Update the destination register only if the Carry flag C is set
– Update the destination register only if the Negative flag N is set
2