Addition of unsigned int

Addition of unsigned int

Post by Mok-Kong She » Thu, 25 Dec 2003 06:15:28



I have a question of ignorance: How does one add two
unsigned int in asm for Intel machines? (The 'add'
instruction is for signed int, if I don't err.)
Thanks in advance.

M. K. Shen

 
 
 

Addition of unsigned int

Post by Jeff Kento » Thu, 25 Dec 2003 12:44:26


There is no difference with twos complement arithmetic between signed and
unsigned addition (unless you are worried about overflow).  Use the add
instructions.  And, go review binary numbers and do a few simple examples to
convince yourself.


> I have a question of ignorance: How does one add two
> unsigned int in asm for Intel machines? (The 'add'
> instruction is for signed int, if I don't err.)
> Thanks in advance.

> M. K. Shen

--

-------------------------------------------------------------------------
=    Jeff Kenton      Consulting and software development               =
=                     http://home.comcast.net/~jeffrey.kenton           =
-------------------------------------------------------------------------

 
 
 

1. WinAVR - C language question, High Byte from Unsigned Int

Hi All,

This one is driving me nuts and there is a real simple answer...

INTERRUPT(SIG_OVERFLOW1)
{
  TCNT1H = tim >> 8;    // <********
  TCNT1L = tim & 0xFF;
  ctr++;

All I want is a minimal code solution for TCNT1H = tim >> 8, Where tim
is an unsigned int.

Current compiler output is:

  TCNT1H = tim >> 8;
  60:   80 91 68 00     lds     r24, 0x0068
  64:   90 91 69 00     lds     r25, 0x0069
  68:   89 2f           mov     r24, r25
  6a:   99 27           eor     r25, r25
  6c:   8d bd           out     0x2d, r24
  TCNT1L = tim & 0xFF;
  6e:   80 91 68 00     lds     r24, 0x0068
  72:   8c bd           out     0x2c, r24

It seems that

  lds   r24, 0x0069
  out   0x2d, r24

is all that is required.

Any thoughts ?

thanks,

Mark.

2. Exposing a PCB

3. 16bit unsigned int to ASCII decimal conversion in 80C51 asm

4. gif animator "easy to use which can move a gif right to left

5. INT/F-converter (16-bit-int to frequency converter)

6. Autocad 2002 + NAV 2003 Pro

7. Signed Binary Addition

8. HPC46100 info needed

9. Addition algorithm

10. addition

11. Bit reverse addition for FFT?

12. brocade fiber switch addition

13. know could I know if there is a carry in addition?