Re: signed/unsigned ALU operations



On Feb 23, 12:06 am, eliben <eli...@xxxxxxxxx> wrote:
Maybe, but not on current processors. Detecting overflow basically is a
conditional branch on the overflow bit (O for signed, C for carry),

Assuming that there is such a thing as an overflow bit.  Not all current
processors have any condition flags such as an overflow bit.  (MIPS is
probably the best known example of this.)

If you're mentioning MIPS, it's a good example of a feature I don't
understand. MIPS has ADD and ADDU on 32-bit registers. According to
the architecture manual the difference is that ADD "extends the sign
to width of register" and ADDU doesn't. I know sign extension is used
when placing 8 or 16-bit data into 32-bit registers, but why is it
needed here ? And what is the real difference between ADD and ADDU in
MIPS ?


On MIPS, ADD will trap if there's a signed overflow, and not modify
the target register. ADDU does the traditional 2's complement
overflow/wraparound, and cannot trap.
.



Relevant Pages

  • Re: signed/unsigned ALU operations
    ... conditional branch on the overflow bit, ... Assuming that there is such a thing as an overflow bit. ... If you're mentioning MIPS, it's a good example of a feature I don't ... MIPS has ADD and ADDU on 32-bit registers. ...
    (comp.arch)
  • Re: multiply accumulator overflow detection
    ... the results are stored into Hi and Lo registers. ... How do I detect overflow when the ... I'm not familiar with the MIPS architecture. ... R2000/R3000 MIPS processors the add instruction generated an exception if ...
    (alt.lang.asm)
  • multiply accumulator overflow detection
    ... I am writing a function that perform multiplication and accumulation ... in MIPS, the results are stored into Hi and Lo registers. ... How do I detect overflow when the ...
    (alt.lang.asm)
  • pointer one past malloc.ed memory
    ... The last byte of malloc.ed memory is written a magic. ... Sorry i had to give some platform specific details. ... Or is it just another case of overflow and we can not blame MIPS ...
    (comp.lang.c)
  • Re: integer limit
    ... If we do this in 32 bit registers, and do not worry about overflow, we ... so in a twos complement machine 2147483648 is negative, ... I am not surprised that Google turns up nothing for 139586437119. ...
    (comp.unix.shell)