Assembly lang
multiple choice
Suppose we have the following pseudo-instruction in our program:
push {r0, r2, r4}
.....
Which of the following instructions would be the appropriate instruction to use when cleaning up the stack space used by the three register values that were pushed onto the stack?
Group of answer choices
sub sp, #12
add sp, #12
add lr, #12
2)
Suppose we are comparing registers R1 and R2 and we want to branch if equal to the label named next, would the following code snippet achieve this for us?
cmp r1, r2
be next
...
...
next:
True
or
False
3)
The following Assembly Code snippet will divide the contents of register R2 by sixteen and add it to the contents of register R1; storing the result of 9 in R1?
mov r1, #5
mov r2, #64
add r1, r2, asr #4
true or false
1. Option b is correct because stack is growing with decreasing address. Hence adding value 12 in stack pointer is equivalent to ignoring top 3 elements.
2. True , this code is correct for that.
3.True because in the last instruction , asr #4 will shift the content of R2 by 4 bit right, which is equivalent to diving content of R2 by 24 = 16 and hence content of R2 will become 64/16 = 4 and hence content of R1 will become 5+4 = 9
Please comment for any clarification
Assembly lang multiple choice Suppose we have the following pseudo-instruction in our program: push {r0, r2,...
Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...
Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...
13) (4 pts) Squaring a number is useful in many other algorithms. This assembly routine calculates the square of an unsigned integer. How long does this take in clock cycles (worst case). Assume ARM 32 bit instruction set and the integer is in R0 before we begin. AREA L.textl, CODE, READONLY PROC EXPORT square square MOV R1,RO; CMP R1, #0 ANDS R3,RO,R1 BNE skip ADD RO,R1, LSL R3; MOV R2,R2, LSL #1 CMP R2, #0 BNE loop BX LR loop...
Suppose we are comparing registers R1 and R2 and we want to branch if equal to the label named next, would the following code snippet achieve this for us? cmp r1, r2 be next ... ... next: True or False
Consider the following operations: A B- C The corresponding assembly code instruction list generated by a compiler are 1 load [%r0 +4], %r1 2 load [%r0 + 8], %r2 3 sub %r1, %r2,%r3 4 load [ZrO + 12], %r4 5 add %r3, %r4 , %r5 6 store %r3, [%r0 + 16] 7 store %r5, [%r0 + 20] a) Identify the potential pipeline hazards. (10 points) b) State if the found hazards can be eliminated and if so propose a scheme...
A C program has been compiled into the Atmel AVR assembly
language. The following instruction, which is located at address
0x002A, is executed:
i.) What is the binary value contained in the instruction
register (IR) when the instruction is executed?
ii.) What is the hexadecimal value of the program counter (PC)
when the instruction is executed?
iii.) If register r1 = 0x40 and register r2 = 0x02 prior to
executing the instruction, what are the contents of r1 and r2...
Exercise 3 [Conditionals] Consider the following assembly code for a function F3 with two integer arguments: F3: push EBP mov EBP, ESP mov EDX, DWORD PTR [ebp+12] mov EAX, DWORD PTR [ebp+8] cmp EAX, EDX # setup stack #if # goto .L1 #EAX- mov EAX, EDX # ignore for now mov DWORD PTR [EBP-4], EAX mov ESP, EBP pop EBE ret # cleanup stack To the right of each instruction, show the contents of the register whose value changes as...
Modify the ARMSIM program to do the following: 1) output the square sum of the data 2) output the sum of all negatives and positives separately .text @ Direvtive .global _start @ declare global begining _start: LDR R1,=idx @ content of idx is length of Vec and now R1 is a counter. LDR R1,[R1] @ R1 is now the length of Vec. read inderectly LDR R2,=Vec @ R2 is the address of first element of vector MOV...
I need help with ARM assembly program :
Using the following code as basic :
1 ) Write a program code that is able to calculate the following
: Result = A + ( B * C ) - D
Place the result as the return value so you can print it
afterwards in the command prompt.
2) This time, use MLA instruction to
reduce the number of instructions in question 1.
Place the result as the return value so...
Convert the following assembly language program into a C
program:
*Update: The variables are initialized, in lines 4 & 6 of
the red assembly language code.
Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. include "p24Hxxxx.inc" global__reset bss: Uninitialized data section: Variables start at location 0x0800 x: .space 2: Allocating space (two bytes) to variable. y: .space 2;Allocating space (two bytes) to...