Walter:

> bearophile wrote:
> > Walter:
> > 
> >> Look at the asm dump of a function. It's full of add's - not only ADD 
> >> instructions, but addressing mode multiplies and add's. Subtraction is
> >> often expressed in terms of addition, relying on twos-complement
> >> wraparound.
> > 
> > This answer is a bit relevant only if the programmer is using inline asm,
> > while the discussion was about unsigned differences in D code, that are
> > uncommon in my D code. Sometimes I even assign lengths to signed-word
> > variables, to avoid some signed/unsigned comparison bugs.
> 
> A lot of the addition is also carried out at link time, and even by the 
> loader. 
> Subtraction is done by relying on overflow.

The back-end carries out my D operations using unsigned differences on CPU 
registers, the linker has to use them, etc. But the discussion was about 
explicit operations done by the D code written by the programmer. Modular 
arithmetic done by unsigned fixed bitfields is mathematically sound, but it's a 
bit too much bug-prone for normal Safe D modules :-)

Bye,
bearophile

Reply via email to