# Can someone check this

1. Dec 31, 2009

### chelsea9947

1. The problem statement, all variables and given/known data

If the content of d0 is $30 state in words what each of the following numbered instruction pairs will do. 2. Relevant equations a. cmpi #$30,d0

beq dan

b. cmp.l unknown, d0

bne dan

c. cmp.w d1,d0

bgt dan

3. The attempt at a solution

a. cmpi #$30,d0 = Z flag gets set. beq dan = [go to label dan] [if d0] [equal to zero] b. cmp.l unknown, d0 = so no flags get set. bne dan = [go to label dan] [if d0] [not equal to zero] c. cmp.w d1,d0 = N flag gets set bgt dan = [go to label dan] [if d0] [greater than zero] 2. Dec 31, 2009 ### Mark44 ### Staff: Mentor This is probably closer to how your answers should be "stated in words." Since d0 is$30, the compare instruction sets the Z flag.
The beq instruction causes a branch to label dan, because the Z flag is set.
You can't say that no flags get set, because you don't know what value is stored in unknown. You should look at two cases: unknown == $30 and unknown !=$30 (meaning that unknown > $30 or unknown <$30).
The branch instruction will do one thing if the Z flag is set and another if the Z flag is clear. You need to have both cases covered in your explanation.
You can't say that the N flag gets set, because you don't know what value is stored in d1. You should look at two cases: d1 <= d0 and d1 > d0.
You need to have both cases covered in your explanation.

3. Jan 1, 2010

### chelsea9947

cmp.l unknown,d0 = I don’t know what value stored in unknown. Therefore their will be three cases (unknown > d0 or unknown < d0 and unknown = d0)

Unknown > d0 = N flag gets set.
Unknown < d0 = no flags get set
unknown = d0 = Z flag gets set

bne dan = [go to label dan] [if d0] [not equal to zero]

cmp.w d1,d0 = I don’t know what value stored in d1. Therefore their will be three cases (d1 < d0 or d1 > d0 and d1 = d0)

d1 > d0 = N flag gets set.
d1 < d0 = no flags get set
d1 = d0 = Z flag gets set

bgt dan = [go to label dan] [if d0] [greater than zero]

is this correct

4. Jan 6, 2010

### Staff: Mentor

This is not correct. You are writing your answers as if you were writing code, which is not what is asked for. You should not be writing your answers like this: bne dan = [go to label dan] [if d0] [not equal to zero]