Re: A92: Question about flags...
[Prev][Next][Index][Thread]
Re: A92: Question about flags...
Niklas Brunlid schrieb:
>
> At 19:16 1998-07-07 +0200, you wrote:
> >
> >
> >I don't really understand the difference between the overflow flag (V) and
> >the carry flag (C).
> >Could someone explain me it ? (in fact, I think I don't understand the
> >carry flag)
> >
> >And I have an other question :
> >for example, if we have for d4.l=0x0000FFFE
> >and we do : add.w #0x20,d4
> >I know that the overflow flag will be set, but what will be the value of
> >d4.l ???? 0x0000FFFF or 0x0001001E ?
>
> d4.l will be 0x0000001E and the carry bit will be set.
>
> The .w in add.w simply tells the CPU how much data it should operate on. If
> your example was right, you should be able to do add.l #20,d4 with d4.l =
> 0xFFFFFFFE and get d4.? = 0x10000001E ;-) That extra bit is simply sent to
> the
> carry instead.
>
> >From the Motorola 68000 Programmers Reference:
> V—Overflow
> ------------------
> Set if an arithmetic overflow occurs implying that the result cannot be
> represented in the
> operand size; otherwise clear.
Here you should mention that the V-flag indicates an overflow to the sign(i.e.
the highest bit of the operand on signed operations)
>
No, look above > I believe this goes for both signed and unsigned arithmetics.
>
> C—Carry
> --------------
> Set if a carry out of the most significant bit of the operand occurs for an
> addition, or if a
> borrow occurs in a subtraction; otherwise clear.
>
>
> Niklas Brunlid - http://www.efd.lth.se/~e96nbr
> PQF Quote follows:
>
> Bigmac's brother was reliably believed to be in the job of moving video
> recorders around in an informal way.
> -- (Terry Pratchett, Only You Can Save Mankind)
>
References: