Question

In: Computer Science

Describe the status of the N, Z, C, and V flags of the CPSR after each...

Describe the status of the N, Z, C, and V flags of the CPSR after each of the following:
(a) ldr r1, =0xffffffff
ldr r2, =0x00000001
add r0, r1, r2
(b) ldr r1, =0xffffffff
ldr r2, =0x00000001
cmn r1, r2
(c) ldr r1, =0xffffffff
ldr r2, =0x00000001
adds r0, r1, r2
(d) ldr r1, =0xffffffff
ldr r2, =0x00000001
addeq r0, r1, r2
(e) ldr r1, =0x7fffffff
ldr r2, =0x7fffffff
adds r0, r1, r2

Solutions

Expert Solution

Denote the status of Z flag , N flag, C flag , and V flag after the execution of following instructions:

(a)

ldr r1, =0xffffffff ; load register with immediate value. r1 = 0xffffffff

ldr r2, =0x00000001 ; load register with immediate value. r2 = 0x00000001

add r0, r1, r2 ; Addition of the register r1 and register r2. r0 = r1 +r2

Answer:

Z flag: 0

N flag: 0

C flag: 0

V flag: 0

Description:

• The addition of r1 + r2 = 0xffffffff + 0x00000001 = 0x00000000 with carry = 1.

• Flags are not set as the instruction ADD does not have the suffix 'S' to execute it conditionally.

(b)

ldr r1, =0xffffffff ; load register with immediate value. r1 = 0xffffffff

ldr r2, =0x00000001 ; load register with immediate value. r2 = 0x00000001

cmn r1, r2 ; Comparison. Compare register as r1 + r2 and set the condition flags.

Answer:

Z flag: 1

N flag: 0

C flag: 1

V flag: 0

Description:

• The comparison of r1 + r2 = 0xffffffff + 0x00000001 = 0x00000000 with carry = 1.

• Z - Zero flag is Set as the comparison result is zero. Z = 1

• N - Negative flag is 0 as the comparison result is positive that means bit 31 is 0.

• C - Carry flag is set as the comparison result generates the carry. C = 1

• V - overflow flag is 0 as the comparison result does not produce overflow.

(c)  

ldr r1, =0xffffffff ; load register with immediate value. r1 = 0xffffffff

ldr r2, =0x00000001 ; load register with immediate value. r2 = 0x00000001

adds r0, r1, r2 ; Addition of the register r1 and register r2 and Set the conditional flags. r0 = r1 +r2

Answer:

Z flag: 1

N flag: 0

C flag: 1

V flag: 0

Description:

• The addition of r1 + r2 = 0xffffffff + 0x00000001 = 0x00000000 with carry = 1.

• Z - Zero flag is Set as the addition result is zero. Z = 1

• N - Negative flag is 0 as the addition result is positive that means bit 31 is 0.

• C - Carry flag is set as the addition result generates the carry. C = 1

• V - overflow flag is 0 as the addition result does not produce overflow.

(d)

ldr r1, =0xffffffff ; load register with immediate value. r1 = 0xffffffff

ldr r2, =0x00000001 ; load register with immediate value. r2 = 0x00000001

addeq r0, r1, r2 ; If the zero flag is set then perform the addition r0 = r1 + r2.

Answer:

Z flag: 1

N flag: 0

C flag: 1

V flag: 0

Description:

• If Z = 1 then addition of r1 + r2 = 0xffffffff + 0x00000001 = 0x00000000 with carry = 1.

• Z - Zero flag remains Set as the addition result is zero. Z = 1

• N - Negative flag is 0 as the addition result is positive that means bit 31 is 0.

• C - Carry flag is set as the addition result generates the carry. C = 1

• V - overflow flag is 0 as the addition result does not produce overflow.

(e)

ldr r1, =0x7fffffff ; load register with immediate value. r1 = 0x7fffffff

ldr r2, =0x7fffffff ; load register with immediate value. r2 = 0x7fffffff

adds r0, r1, r2 ; Addition of the register r1 and register r2 and Set the conditional flags. r0 = r1 +r2

Answer:

Z flag: 0

N flag: 1

C flag: 0

V flag: 1

Description:

• The addition of r1 + r2 = 0x7fffffff + 0x7fffffff = 0xFFFFFFFE.

• Z - Zero flag is 0 as the addition result is non-zero.

• N - Negative flag is set as the addition result is negative that means bit 31 is 1. N = 1

• C - Carry flag is 0 as the addition result does not generate the carry.

• V - overflow flag is 1 as the addition result produce an overflow. V = 1

(Overflow is detected when the result of two positive number generates negative result.)


Related Solutions

Insurance status—covered (C) or not covered (N)—is determined for each individual arriving for treatment at a...
Insurance status—covered (C) or not covered (N)—is determined for each individual arriving for treatment at a hospital's emergency room. Consider the chance experiment in which this determination is made for two randomly selected patients. The simple events are O1 = (C, C), O2 = (C, N), O3 = (N, C), and O4 = (N, N). Suppose that probabilities are P(O1) = 0.81, P(O2) = 0.09, P(O3) = 0.09, and P(O4) = 0.01. (a) What outcomes are contained in A, the...
Choose two flags (bits) from the 8086 status register, also known as flags register. In your...
Choose two flags (bits) from the 8086 status register, also known as flags register. In your own words briefly describe the purpose of each flag and how it works
Prove 1. For each u ∈ R n there is a v ∈ R n such...
Prove 1. For each u ∈ R n there is a v ∈ R n such that u + v= 0 2. For all u, v ∈ R n and a ∈ R, a(u + v) = au + av 3. For all u ∈ R n and a, b ∈ R, (a + b)u = au + bu 4.  For all u ∈ R n , 1u=u
Calculate V and Z for methyl chloride at 100 ° C and 55bar for the ideal...
Calculate V and Z for methyl chloride at 100 ° C and 55bar for the ideal gas equation, by the equation of virial. Data: R = 83.14 cm 3 bar/molK; viral coefficient B equals -242.5 cm3/mol.
How to compute the Z, N, C, and Z the condition code bit values? Given A...
How to compute the Z, N, C, and Z the condition code bit values? Given A and B, and after subtracting how do I find the condition codes? Please provide a few examples with the explanation.
Let f : Z × Z → Z be defined by f(n, m) = n −...
Let f : Z × Z → Z be defined by f(n, m) = n − m a. Is this function one to one? Prove your result. b. Is this function onto Z? Prove your result
a) Find the recurrence relation for the number of ways to arrange flags on an n...
a) Find the recurrence relation for the number of ways to arrange flags on an n foot flagpole with 1 foot high red flags, 2 feet high white flags and 1 foot high blue flags. b) solve the recurrence relation of part a
let v and u are random variables fvu(v,u)= e^-v-u for u ,v>=0 Z= e^v+u find fz(z)...
let v and u are random variables fvu(v,u)= e^-v-u for u ,v>=0 Z= e^v+u find fz(z) ?
Find the probability of each of the following, if Z~N(μ = 0,σ = 1). a) P(Z...
Find the probability of each of the following, if Z~N(μ = 0,σ = 1). a) P(Z < -1.88) b) P(Z > 1.51) = c) P(-0.61 < Z < 1.54) = d) P(| Z | >1.78) = e)  P(Z < -1.27) = f) P(Z > 1.02) = g) P(-0.69 < Z < 1.78) = h) P(| Z | >1.86) =
For a particular DRAM design the cell capacitance is C,=50fF, Vpp=5 V and V=1.4 V. Each...
For a particular DRAM design the cell capacitance is C,=50fF, Vpp=5 V and V=1.4 V. Each cell represents a capacitive load on the bit line of 2fF. The sense amplifier and other circuitry attached to the bit line has a 20fF. What is the maximum number of cells that can be attached to a bit line while ensuring a minimum bit line signal of 0.1 V? How many bits of row addressing can be used? If the sense amplifier gain...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT