# arm代写 | assembly | quiz代做 – test

### test

arm代写 | assembly | quiz代做 – 这是利用arm进行训练的代写, 对arm的流程进行训练解析, 包括了arm/assembly等方面, 这个项目是quiz代写的代写题目

ECE 6483 quiz Spring 2022 (Open book, notes and Laptop only)

Name: _____________________________________

ID: _____________________________________

NYU Tandon School of Engineering

1. Observe the following arm assembly code implementation of Function:
``````EXPORT Function
``````
``````Function
stmfd sp!, {r2-r9, lr}
``````
``````mov r4, r
mov r3, r
sub r1, r1, #
mov r9, r
loop
mov r5, r
mov r4, r
``````
``````loop
ldr r6, [r5], #
ldr r7, [r2], #
cmp r7, r
``````
``````strhs r6, [r2, #-4]
strhs r7, [r5, #-4]
``````
``````subs r4, r4, #
loop
``````
``````subs r9, r9, #
bne loop
ldmfd sp!, {r2-r9, pc}^
``````
``````END
``````
``````Comment each line of this code and determine what this function does. Be specific about data
type (bytes, long etc.) and memory locations.
``````
1. Suppose I have the following C code snippet, which simply sums 6 numbers:
``````int sum6(int a1, int a2, int a3, int a4, int a5, int a6);
``````
``````int main()
{
int t;
t=sum6(1,2,3,4,5,6);
while(1);
}
``````
``````int sum6(int a1, int a2, int a3, int a4, int a5, int a6)
{
int total;
total =a1+a2+a3+a4+a5+a6;
}
``````
``````a. Write the equivalent ARM assembly code in the following structure. Be sure to comment
each line.
``````
``````AREA sum, CODE
EXPORT __main
ALIGN
ENTRY
``````
``````__main PROC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
stop B stop
ENDP
``````

sum6 PROC

``````;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDP
END
``````
1. We learned in class how to set up GPIO pins for input and output. We also know that the vendor specific HAL provides libraries like DigitalWrite, DigitalRead etc. But often these libraries are bloated, since they need to support so many different possible configuration and need to be generic. This question requires us to write these two functions ourselves, so that we can do GPIO more efficiently.
``````SPECIFICALLY USING THE REGISTERS IN LECTURE 6 (for Arm Cortex M0+), implement the
following functions:
``````
``````Int MyPortWrite(int MyPort, int WriteMask, int MyPinValues)
{
//My port is 0 or 1 selecting the port
//WriteMask holds a 32 bit integer where there are 1  s in the bits/pins you wish to write
//MyPinValues has a 32 bit int with the write values for the pins indicated in WriteMask
//Example: WritePort = 0, WriteMask=0x00002401=Pins 0, 10, and 13 are being written
//MyPinValues = 0x00002400 = Write Port 0 Pin 0=0, Pin 10=1 and Pin 13 = 1 (ignore all
//others)
//Don  t forget to set DIR, INEN etc ... .And check for erroneous parameters
//Return 1 if successful, 0 if failed
}
``````
``````Int MyPortRead(int MyPort, int *PullEnable)
{
//My port is 0 or 1 selecting the port
//PullUpEnable holds the address of a 32 bit integer that returns the bit mask of those
//pins already configured with the Pull resistor enabled.
//Example: MyPort = 0,
//MyPortRead = 0x0000 2401 = All pins on Port 0 are 0, except Pin 0, 10 and 13
//*PullEnable returns is assigned 0x01200480, Pins 7, 10, 21 , and 24 have pull resistor
//enabled
//Don  t forget to set DIR, INEN etc ... .And check for erroneous parameters
//You may assume the port has already been configured.
//Return 1 if successful, 0 if failed
}
``````