Question 1 ARM’s literature often describes its assembly language instruction sy
ID: 3878631 • Letter: Q
Question
Question 1 ARM’s literature often describes its assembly language instruction syntax in BNF notation. Suppose an instruction is described in BNF as having the syntax:This|That{B}{S}{,P|Q} Give 5 examples of possible legal instructions using this format.
Question 2 If r1 = 0FFF16, and r2 = 4, what is the value of r3 after each of the following instructions has been executed (assume that each instruction uses the same data).
MOV r3,r1, LSR r2
MVN r3,r1, LSL r2
Question 3
Additionally, encode the number 5768 (0b1011010001000) as accurately as possible using ARM's 12-bit literal. What is the percent error in this encoding?
ARM instructions have a 12bit literal. Instead of permitting a word in the range 0 to 2 12 1, the ARM uses an 8bit format for the integer and a 4bit alignment field that allows the integer to be shifted in steps of 2. What are the advantages and disadvantages of this mechanism in comparison with a straight 12bit integer?
Question 4
For each of the following instructions indicate what the result will be, and give the binary encoding of the instructions (in hex format). Show your work and explain your result. Feel free to consult an assembly website or use Keil to verify your work.
a) RSB r1,r0,LSL#2
b) MLA r1,r0,r0,r1
c) STR r0,[r2,r3,ROR #3]!
Question 5
Look through the instructions on the U of R ARM sheet, and try to find a combination of condition, opcode, and “S” flag which makes a dictionary word in English (or another language), or some close approximation of a word. The only point of this question is to make you download the sheet, look at it, and look through the opcode/condition pairs. What does your instruction do? Question 1 ARM’s literature often describes its assembly language instruction syntax in BNF notation. Suppose an instruction is described in BNF as having the syntax:
This|That{B}{S}{,P|Q} Give 5 examples of possible legal instructions using this format.
Question 2 If r1 = 0FFF16, and r2 = 4, what is the value of r3 after each of the following instructions has been executed (assume that each instruction uses the same data).
MOV r3,r1, LSR r2
MVN r3,r1, LSL r2
Question 3
Additionally, encode the number 5768 (0b1011010001000) as accurately as possible using ARM's 12-bit literal. What is the percent error in this encoding?
ARM instructions have a 12bit literal. Instead of permitting a word in the range 0 to 2 12 1, the ARM uses an 8bit format for the integer and a 4bit alignment field that allows the integer to be shifted in steps of 2. What are the advantages and disadvantages of this mechanism in comparison with a straight 12bit integer?
Question 4
For each of the following instructions indicate what the result will be, and give the binary encoding of the instructions (in hex format). Show your work and explain your result. Feel free to consult an assembly website or use Keil to verify your work.
a) RSB r1,r0,LSL#2
b) MLA r1,r0,r0,r1
c) STR r0,[r2,r3,ROR #3]!
Question 5
Look through the instructions on the U of R ARM sheet, and try to find a combination of condition, opcode, and “S” flag which makes a dictionary word in English (or another language), or some close approximation of a word. The only point of this question is to make you download the sheet, look at it, and look through the opcode/condition pairs. What does your instruction do? Question 1 ARM’s literature often describes its assembly language instruction syntax in BNF notation. Suppose an instruction is described in BNF as having the syntax:
This|That{B}{S}{,P|Q} Give 5 examples of possible legal instructions using this format.
Question 2 If r1 = 0FFF16, and r2 = 4, what is the value of r3 after each of the following instructions has been executed (assume that each instruction uses the same data).
MOV r3,r1, LSR r2
MVN r3,r1, LSL r2
Question 3
Additionally, encode the number 5768 (0b1011010001000) as accurately as possible using ARM's 12-bit literal. What is the percent error in this encoding?
ARM instructions have a 12bit literal. Instead of permitting a word in the range 0 to 2 12 1, the ARM uses an 8bit format for the integer and a 4bit alignment field that allows the integer to be shifted in steps of 2. What are the advantages and disadvantages of this mechanism in comparison with a straight 12bit integer?
Question 4
For each of the following instructions indicate what the result will be, and give the binary encoding of the instructions (in hex format). Show your work and explain your result. Feel free to consult an assembly website or use Keil to verify your work.
a) RSB r1,r0,LSL#2
b) MLA r1,r0,r0,r1
c) STR r0,[r2,r3,ROR #3]!
Question 5
Look through the instructions on the U of R ARM sheet, and try to find a combination of condition, opcode, and “S” flag which makes a dictionary word in English (or another language), or some close approximation of a word. The only point of this question is to make you download the sheet, look at it, and look through the opcode/condition pairs. What does your instruction do?
Explanation / Answer
Question 1
BNF syntax is given as: This|That {B} {S} {,P|Q}. 5 example are given below:-
Eg 1:- This BS,Q [Select This from This|That, then select {B}, then select {S}, then select {,Q}]
Eg 2:- That BS,Q [Select That from This|That, then select {B}, then select {S}, then select {,Q}]
Eg 3:- This BS,P [Select This from This|That, then select {B}, then select {S}, then select {,P}]
Eg 4:- That BS,P [Select That from This|That, then select {B}, then select {S}, then select {,P}]
Eg 5:- This B,P [Select This from This|That, then select {B}, {S} is not selected since its optional, say, then select {,P}]
Question 2
MOV r3,r1, LSR r2
This instruction right shifts r1 by r2 and stores the value in r3.
r3 = r1 >> r2
r3 = 0x0FFF16 >> 4
r3 = 0x00FFF1
MVN r3,r1, LSL r2
This instruction left shifts r1 by r2, negates it and stores it in r3
r3 = !(r1 << r2)
r3 = !(0xFFF160)
r3 = 0x000E9F
Question 3
The ARM architectur uses 12 bit to store immediate data values. In this encoding, the most significant 4 bits are for specifying the number of right rotation steps and the remaining 8 bits are to be rotated. The most significant 4 bit value is multiplied by 2 and the result gives the number of steps the 8 bits are to be rotated right in 32 bit representation. Now the given number 5768 has 13 bits 1 0110 1000 1000 = 0x1688(in hexadecimal). Now we need to convert it to the closest number that can be represented using 8 bits with triling zeros and zeros at the begining. Thus our target is to find the closest number such that all the 1's in its binary representation fall within a 8 bit range. Such a number is 0x1680 = 1 0110 1000 0000(5760 in decimal). Here b6 to b12 represent the 8 bit number which is 0 1011 010. By adding trailing zeros, we can make it 0X1680. We need 6 trailing zeros. Thus the 32 bit representation would be :
0000 0000 0000 0000 0001 0110 1000 0000. We can achieve this by rotating 0 1011 010 by 26 places to the right.
Thus in the encoded value most significant 4 bits would be 26/2 = 13 = 1101(in binary) and the rest 8 bits would be 01011010. Thus the encode value is:
110101011010.
percentage error = (5768-5760)/5768 *100% = 0.14%
Question 4
a) RSB r1,r0,LSL #2
Evaluate to r1 =(r0<<1)-r0
Left shift by 1 bit
Also equal to
r1=r0*(22-1)
=(r0*3)
b) MLA r1,r0,r0,r1
Multiply Accumulate
r1=(r0*r0)+r1
c) STR r0[r2,r3,ROR #3]!
=1st calculate (r2+r3>>3)
=store r0 in (r2+r3>>3)
=update r2 also
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.