Question

In: Computer Science

Evaluate the following ARM code line by line and show the state of each register and...

Evaluate the following ARM code line by line and show the state of each register and PC after execution.

Initial state: X1 = 0, X2 = 0, X3 = 0, X4 = 0x7, X5 = 0

If there are multiple values for a given register at a particular instruction list them in order

X1

X2

X3

X4

X5

PC after execution

0x100

ADDI  X1,X1,#4096

0x104

B #8

0x108

ADDI X3,X3,#1

0x10C

CBNZ X3, #2

0x110

CBZ  X2, #2

0x114

B #-1

0x118

AND X5,X3,X4

0x11C

XOR X5,X3,X4

0x120

ORR X2,X3,X4

0x124

CBZ X2, #7

0x128

BREAK

Solutions

Expert Solution

Below are the details of all the instructions:

Note: The instructions do not seem to form an actual practical program and hence, they are merely judging the understanding of these instructions.

In snapshot:

In text:

X1 X2 X3 X4 X5 PC after execution
0x100 ADDI  X1,X1,#4096 0, 0x1000 0 0 0x7 0 0x104
Equivalent to X1=X1+1000 (4096 = 0x1000). PC points at next instruction at 0x104
0x104 B #8 0, 0x1000 0 0 0x7 0 0x,108, 0x128
Equivalent to a jump instruction with an offset of 8*4. So PC jumps to 0x108 (pointing to next direction) plus 8*4
0x108 ADDI X3,X3,#1 0x1000 0 0, 0x1 0x7 0 0x10C
Equivalent to X3=X3+1. PC points at next instruction at 0x10C
0x10C CBNZ X3, #2 0x1000 0 0x1 0x7 0 0x110, 0x118
If X3 not equal to 0, then jump 2 steps ahead. PC = PC+2*4
0x110 CBZ  X2, #2 0x1000 0 0x1 0x7 0 0x114, 0x11C
If X2 equal to 0, then jump 2 steps ahead. PC = PC+2*4
0x114 B #-1 0x1000 0 0x1 0x7 0 0x118, 0x114
Equivalent to a jump instruction with an offset of -1*4. So PC jumps to 0x108 (pointing to next direction) minus 4. This might result in an infinite loop
0x118 AND X5,X3,X4 0x1000 0 0x1 0x7 0, 0x1 0x11C
Equivalent to X5=X3 AND X1. This is a bitwise operation [X3 (0000 0001) AND X4 (0000 0111) = 0000 0001] . PC points at next instruction.
0x11C XOR X5,X3,X4 0x1000 0 0x1 0x7 0x1,0x6 0x120
Equivalent to X5=X3 XOR X1. This is a bitwise operation [X3 (0000 0001) XOR X4 (0000 0111) = 0000 0110] . PC points at next instruction.
0x120 ORR X2,X3,X4 0x1000 0, 0x7 0x1 0x7 0x6 0x124
Equivalent to X2=X3 XOR X4. This is a bitwise operation [X3 (0000 0001) OR X4 (0000 0111) = 0000 0111] . PC points at next instruction.
0x124 CBZ X2, #7 0x1000 0, 0x7 0x1 0x7 0x6 0x128, 0x144
If X2 equal to 0, then jump 2 steps ahead. PC = PC+7*4
0x128 Break 0x1000 0, 0x7 0x1 0x7 0x6 0x129
End program, size of instruction is 1.

Related Solutions

The following code fragment is expressed in arm assembly code. Fill in the blanks, so that...
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that it is equivalent to the following C code. int counter; int x = 5; int y = 6; for (counter =10; counter >0;counter--) IF(X==Y) Y = Y + 1 ; ELSE Y = Y + 2} Fill in the blanks in the following code: MOV__________ ;loop counter into r0-ten times round the loop MOV__________ ;Value of y loaded into r1 MOV__________ ;Value of x...
Show the lessons learned register at the current, planning state of the project. Also identify any...
Show the lessons learned register at the current, planning state of the project. Also identify any new or updated constraints and assumptions. project management Class
Show how each of the following C statements would be translated to ARM Cortex M3/M4 assembly...
Show how each of the following C statements would be translated to ARM Cortex M3/M4 assembly language: 3.1. a |= (1<<3) 3.2. a &= ~(1<<1) 3.3. a ^= 1<<2 If a was an 8-bit variable with initial value 0xA7: 3.4. What would be its value after each operation, assuming each operation runs individually.
For each of the following write the line(s) of code that: Declares and initializes (creates) an...
For each of the following write the line(s) of code that: Declares and initializes (creates) an ArrayList that holds String objects Adds to your ArrayList the words "Too" and "Fun" Verifies that your ArrayList now contains 2 elements Sets the second String in the ArrayList to "No" Verifies that your ArrayList still contains exactly 2 elements Prints the contents of the ArrayList to the screen in the following format: <element>, <element>, . . . , <element>
The following code fragment is expressed in arm assembly code.Fill in the blanks, so that...
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that it is equivalent to the following C code.int counter;int x = 5;int y = 6;for (counter =10; counter >0;counter--)IF(X==Y)Y = Y + 1 ;ELSEY = Y + 2}Fill in the blanks in the following code:MOV__________ ;loop counter into r0-ten times round the loopMOV__________ ;Value of y loaded into r1MOV__________ ;Value of x loaded into r2Next CMP ____________ ;assume r1 contains y and r2 contains...
Two arrays “Array1” and “Array2” are given with 25 words each. Design an ARM assembly code...
Two arrays “Array1” and “Array2” are given with 25 words each. Design an ARM assembly code to compare sum of the numbers sotred in the arrays. If sum of Array1 is greater, save a “1” in R10, otherwise, save “0’ in R10.
On each of the following 1- State the null and alternte hypothesis. 2- Show the test...
On each of the following 1- State the null and alternte hypothesis. 2- Show the test statistic, 3- State the conclusion in terns of the null hypothesis, 4-State the conclusion in terms of the question 5-tell the p-value (if one sided): Emma dosent believe that women take longer in the restroom than men, so she stands outside the restrooms in the union and times people as they enter and exit. Besides getting strange looks, she collects the following data. The...
. What does each line of the following code do? fsrPin = ‘A4’; ledPin = ‘D4’;...
. What does each line of the following code do? fsrPin = ‘A4’; ledPin = ‘D4’; anArduinoObj = arduino(); forceVoltage = readVoltage(anArduinoObj, fsrPin); if forceVoltage > 4.0 writeDigitalPin(anArduinoObj, ledPin, 1); end Based on the Adafruit pages related to their round FSR sensor, what is the required force to read a voltage greater than 4V?
4. Explain what is happening on each line of the following AVR assembly code. If you...
4. Explain what is happening on each line of the following AVR assembly code. If you were to execute this code what would be the final decimal values in R20, R21 and SREG registers? BCLR 0 BCLR 1 BCLR 2 BCLR 3 BCLR 4 BCLR 5 BCLR 6 BCLR 7 LDI ​R19, 0x02 LDI​R20, 0x74 LDI​R21, 0x04 LDI​R22, 0x22 ADD​R20, R22 SUB​R22, R21 ADD​R20, R21 MOV​R20, R21 JMP​DONE ADD​R21, R20 SUB​R21, R22 DONE:​SUB​R20, R21 -embedded system-
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert...
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert temperatures from Celsius to Fahrenheit or from Fahrenheit to Celsius. Here are the two formulas for your reference. Use variable to read and store values. C= 5* (F - 32) / 9 F = (9 * C / 5 ) + 32 My code below: TempConvert.s LDR R8,=temperature LDR R1,[R8] LDR R8,=unit LDRB R2,[R8] LDR R8,=celsius LDRB R3,[R8] LDR R8,=fahrenheit LDRB R4,[R8] MOV R6,#9...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT