Question

Note: All assembly code should be well commented-similar level of detail to samples. 7. Write ARM code that decodes the immediate value in an instruction-takes the last 12 bits and turns it into the value it represents a. Start by loading r1 with the value E3A01CFA (machine code for a move immediate into register) b. Isolate bits 0-7 (the rightmost 8 bits) the 8-bit binary number - into r2 c. Isolate bits 8-11 d. Multiply r3 by 2 to get the actual rotation amount e. Rotate r2 to the right by that many bits. Place your answer in r4 (the four bits left of 0-7)-4 bits indicating the rotation- into r3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

        ;       since in ARM immediate operand can only be a 32 bit number such that it can be
       ;       formed by shifting an 8 bit number
       ;       hence the number should be in the form:
       ;       from 0x00000000 to 0x000000FF
       ;       or from 0x00000100 to 0x0000FF00 etc.
       ;       means only 1 byte or 8 bits of the immediate operand can be non zero
       ;       hence to move 0xE3A01CFA we need to first move the first right most byte into register
       ;       and then add another bytes into register
       MOV       R1, #0x000000FA          ; move first right most byte into register r1
       ADD       R1, R1, #0x00001C00      ; adding second right most byte
       ADD       R1, R1, #0x00A00000      ; adding third right most byte
       ADD       R1, R1, #0xE3000000      ; adding fourth right most byte
       ;       Now register r1 contains 0xE3A01CFA
       MOV       R2, #0x00000000          ; setting r2 to 0
       MOV       R3, #0x00000000          ; setting r3 to 0
       MOV       R4, #0x00000000          ; setting r4 to 0
       ;       isolating right most byte of r1 into register r2 by doing and operation
       AND       R2, R1, #0x000000FF
       ;       isolating bits 8-11 into register r3
       AND       R3, R1, #0x00000F00
       ;       rotate to bring the number to the right most
       LSR       R3, R3, #8
       ;       multiplying r3 with 2 by just rotating r3 1 bit left
       LSL       R3, R3, #1
       ;       rotating r2 right as many bits as the value in r3 is. and storing the result into
       ;       register r4
       ROR       R4, R2, R3


ù untitled·S-(Unsaved-VisUAL File Help Ne per etting ols Emulator Off Execute Reset Step Step Forwards Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex since in ARM immediate operand can only be a 32 bit number such that it can be ; formed by shifting an 8 bit number ; hence the number should be in the form: ; from 8x8088e808 to 8x808000FF 0x8 0x8 0x8 0x8 R2 or from exeeee01ee to exee88FFee etc : means only 1 byte or 8 bits of the immediate operand can be non zero : hence to move exE3Ae1CFA we need to first move the first right most byte into register R3 and then add another bytes into register MOV ADD ADD ADD RI, #exeeeeeeFA RI, RI, #exeeeelcee R1, R1, frexeeAeeeee RI, R1, #8xE 3 eeeeee ; move first right most byte into register r1 : adding second right most byte : adding third right most byte R5 R6 R7 10 0x8 0x8 0x8 0x8 adding fourth right most byte Now register r1 contains exE3A01CFA setting r2 to e 14 15 16 MOV MOV MOV R23 #exeeeeeeee R3, exeeeeeeee R4 , #ex00000000 : setting r3 to ; setting r4 to θ isolating right most byte of ri into register r2 by doing and operation isolating bits 8-11 into register r3 rotate to bring the number to the right most R9 R10 R11 R12 R13 AND R2, R1, # exeeeeeeFF 18 19 2e AND R3R1#exeeeeeFee , , LSR : multiplying r3 with 2 by just rotating r3 1 bit left LSL ; rotating r2 right as many bits as the value in r3 is.and storing the result into R3, R3, register r4 R3, #8 0x8 0xFF008008 0x8 23 R3, #1 25 26 27 28 ROR R4, R2, R3 Clock Cycles Current Instruction Total:0 7:01 PM Type here to search A)ENG 1/23/2019untitled.S - [Unsaved] - VisUAL File Help New Open Save Settings Tools Emulation Complete Execute Reset Step BackwardsStep Forwards 27 0 Reset to continue editing code Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex Dec Bin Hex since in ARM immediate operand can only be a 32 bit number such that it can be formed by shifting an 8 bit number hence the number should be in the form: From 8x88080000 to 8x800000FF or from exeeee0180 to 8xee0eFF00 etc means only 1 byte or 8 bits of the immediate operand can be non zero hence to move exE3AB1CFA we need to first move the first right most byte into regi and then add another bytes into register RI, #exeeeeeeFA RI, RI, #exeeeelcee RI, RI, 芥exeeAeeeee R1, R1, #8xE 3eeeeee Now register r1 contains exE3Ae1CFA R23 #exeeeeeeee 8xE3A01CFA R2 R3 8x18 0xFA00 0x8 0x8 0x8 0x8 0x8 0x8 0x8 0x8 0xFF008008 0x8 0x34 MOV ADD ADD ADD ; move first right most byte into register r1 : adding second right most byte : adding third right most byte R5 R6 R7 10 adding fourth right most byte setting r2 to e 14 15 16 MOV MOV MOV : setting r3 to ; setting r4 to isolating right most byte of ri into register r2 by doing and operation R2, R1, # isolating bits 8-11 into register r3 R3R1#exeeeeeFee rotate to bring the number to the right most R3, R3, #8 multiplying r3 with 2 by just rotating r3 1 bit left R3, R3, #1 rotating r2 right as many bits as the value in r3 is. and storing the result into register r4 R9 R10 R11 R12 R13 AND exeeeeeeFF 18 19 2e 21 AND , , LSR 23 LSL 25 26 28 Clock Cycles Current Instruction: 1 Total: 12 CSPR Status Bits (NZCV)

At right in the image, you can see the value of registers.

the code 0xE3A01CFA

is a code for a mov instruction into a register with value #FA00. So at the end in our program, the register r4 contains the value #FA00.

The tool that i have used to visualize is "Visual" arm emulator.

Add a comment
Know the answer?
Add Answer to:
Note: All assembly code should be well commented-similar level of detail to samples. 7. Write ARM...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    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...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

  • 2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z r...

    2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...

  • 1.) a.) Using the simplified instruction set shown for part b, write code for the following....

    1.) a.) Using the simplified instruction set shown for part b, write code for the following. Suppose memory locations 1400 to 1449 contain 16-bit words. Each word represents 2 ASCII characters. Write code to read in and write out these 100 characters. Left-side character from location 1400 should be first, right-side character from location 1400 should be second, and remaining characters follow in numeric order. Assume you have access to 4 registers: R1, R2, R3, R4. Each register holds one...

  • You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers....

    You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers. However, it has only 29 physical registers. Register RO, R1 and R31 are not physically implemented. Instead, every read from RO, R1 and R31 will return a constant zero (00000000), constant one (00000001) and all ones (11111111), respectively. Every write to RO, R1 and R31 will go to null (dummy write). Assume that all other registers have initially unknown (X) state (This in fact...

  • third photo is problem 8 pt 2. anything would help please Problem 7 (15pts) Convert this...

    third photo is problem 8 pt 2. anything would help please Problem 7 (15pts) Convert this following pseudo-code in high level language into a piece of an assembly code (NIOS 2). In the following pseudo-code in high level language, r4, r5, r6, and r10 represent registers 4,5, 6, and 10, respectively Consider this pseudo-code in high level language: If ! (r4 >r5 or rs <r6) r10=r10+1 else r10- r10-1 This becomes the following piece in assembly code (put you answers...

  • 5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2,...

    5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2, $0, 11 add $t3, $t1,$t2 move $t4, $t3 The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted. Data Text x Text Regs Int Regs [16] Int Regs [16] PC = 400028 EPC 0 Cause = 0 BadAddr = 0 Status = 3000ff10 HI LO = 0 = 0...

  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT