Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) For each of the instructions below, assume the initial conditions shown for r3-r5 and the flags. For each instruction, show the value of

1) For each of the instructions below, assume the initial conditions shown for r3-r5 and the flags. For each  3) For both of the instructions shown below, the initial conditions are shown. The result (which the 4) Write assembly language code to find the largest of three numbers stored in r1, r2, and r3. The inputs are

1) For each of the instructions below, assume the initial conditions shown for r3-r5 and the flags. For each instruction, show the value of any registers that are changed. If the instruction affects flags, show the value for all flags that are affected. Initial conditions: A) B) C) D) E) A) B) C) ADCS r4, r3,r4 D) CMP r3,r5 E) TST r4,#0xF Initial conditions: BIC 2) For each pair of instructions below, assume the initial conditions shown for r7 and r8. State whether the branch is taken or not taken in each case. r5,r5,#0x55 MVNS r5,r3 CMP r8,#0x8 BGE somewhere CMP r7,#0x8 BGT somewhere CMP r7,#-1 BLE somewhere CMP r8,#-1 BLT somewhere r3=0xF0E1_D2B3 r4 = 0x1496 3A40 r50x47CE 811E CMP r8,#32 BEQ somewhere NZCV 1010 r7 r8 = 0x0000_0020 0xFFFF FFFF 3) For both of the instructions shown below, the initial conditions are shown. The result (which the instruction stores in r1) is also shown. For each instruction, answer these questions: What is the state of the flags after the instruction executes . if the operands were signed, are the results valid? Why or why not? if the operands were unsigned, are the results valid? Why or why not? A) B) . initial conditions: r0 = 0xAAAA AAAA r1 = 0x5555_5555 ADDS r1, r1, ro result = 0xFFFF_FFFF initial conditions: r00x7FFF FFFD r1 = 0x0000_000F ADDS r1, r0, r1 result = 0x8000_000C 4) Write assembly language code to find the largest of three numbers stored in r1, r2, and r3. The inputs are all 32-bit signed numbers. You may store the result in any register. 5) Write assembly language code that takes an 8-bit signed number in a register as its input and sign extends the number to 32-bits. The 8-bit signed input will be stored in the least significant byte of the register. The upper three bytes of the input register might contain any value. You may choose any register as the input and output. Sign extending means that the sign bit (bit 7 of the input) is copied to the upper 24-bits in the answer. Examples: input: Ox1F54_E778, output: 0x0000_0078 input: 0x0F39_29E2, output: 0xFFFF_FFE2 6) Write assembly language code to count the number of O's in a number in a register. You may pick any register as your input. 7) Write assembly language code to read a 32-bit signed number from memory address Ox300. Compute the absolute value of the number and store the result in memory address Ox304. Here is one way to implement the absolute value of a number X in C Code: if (x < 0) else return (-1*X); return (X): Recall that the negative of a signed number is found by the two's complement. To compute the two's complement of a number, invert all the bits in the number and add 1 to the result.

Step by Step Solution

3.24 Rating (122 Votes )

There are 3 Steps involved in it

Step: 1

1 A ADCS r4 r3 r4 r4 0xF0E1D2B3 0x14963A40 1 carry from previous ADCS NZCV N1 negative Z0 not zero C1 carry V overflow depends on operands B CMP r3 r5 ... blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Architecture A Quantitative Approach

Authors: John L. Hennessy, David A. Patterson

4th edition

123704901, 978-0123704900

More Books

Students also viewed these Finance questions