can someone please explain why that is the answer to the question.
for question 3, i thought it would be a) and c)

thanks,

1 Circle which of the following (it could be any number of them) are
flags that will be set (to 1) when 0x80 and 0x40 are added using the
8-bit addition instruction ("addb") on the Intel 80386:


a) CF b) SF c) OF d) ZF
ans: b)

--------------------------------------------------------------------------------
*same question :: when 0x80 and 0x80

a) CF b) SF c) OF d) ZF
ans: a), c), d)

---------------------------------------------------------------------------------

when 0xC0 and 0xC0
a) CF b) SF c) OF d) ZF
ans: a), b)

Recommended Answers

All 3 Replies

I have NO experience with 8-bit instructions, so consider this reply a guess...

If addb (ADD.B? can't find it in the newer intel manuals) treats 8 bit values as 8 bit signed integers (does the 386 use these?) then 0x80 becomes -128 (decimal) and 0x40 becomes +64 (decimal), meaning that the result of the instruction is 0xC0 (-64 decimal) which is valid and SF will be set.

The same reasoning should apply to the other two questions, but not sure why ZF = 1 and SF = 0 in question 2?

Like I said, a guess, but hope it helps.

1) 0x80 + 0x40 = 0xC0
0xC0 > 0x80 => setting the signed flag

2) 0x80 + 0x80 = 0x(1)00
Cannot represent numbers greater than 0xFF => setting Carry
MSB cleared, so Overflow set
0x00 => Setting the Zero

3) 0xC0 + 0xC0 = 0x(1)80
Cannot represent numbers greater than 0xFF => setting Carry
0x80 => MSB set => negativ => Sign set

That's my guess.

thanks all your help =]. very appreciated
i kind of figured out how it works

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.