Member Avatar for Epic Tissue
Epic Tissue

This is for the 68k series.

This was a question in an exam I have already done. (Didn't do well). I'd just like to know if I answered this right at all!

State the value of the register and the value of the flags in the CCR after each instruction. Assume flags (X,N,C,V,Z) are clear.

move.b #8,d0

this moves a byte size value (decimal 8) to register d0. No flag is set.

move.b #-1,d1

this moves a byte size value (decimal -1) to register d1. the N (Negative) flag is set because it's a negative number.

add.b d0,d1

adds values in registers d0 and d1. d0 is unchanged and is still 8. d1 is now (decimal)7. N flag is set.

sub.b #9,d1

d1 = d1 - 9. d1 is now equal to -2. N is set.

move.b #126,d1

d1 = 126. no flags set.

add.b d0,d1

Well d0 was 8, so 8 + 126 = 134. no flags set. (or should the V(oVerflow) flag be set because it's over 127?).

and.b #127,d1

So I guess find them in binary to and them. 127(decimal) = %1111111. 134(dec) = 111111110000110. So then the product is 0000110.

d1 = 6(dec).
no flags are set.

sub.b #6,d1
d1 = d1 - 6
d1 = 0
zero flag set.

--

Sorry for the long question! Hope someone can help. That seems a bit too err.. easy.. or something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.