From: Frederic Marmond <fmarmond@eprocess.fr>
To: pj@evobsyniva.com
Cc: linux-assembly@vger.kernel.org
Subject: Re: newbie :adding larger value
Date: Fri, 28 Nov 2003 07:59:54 +0100 [thread overview]
Message-ID: <3FC6F26A.4060604@eprocess.fr> (raw)
In-Reply-To: <oprzax88scb2epmx@localhost>
! yes !
Hum, I feel like I have to play more often with x86 asm, I'm forgetting
all but the basic... (my work makes me let the asm in the side and focus
on C/C++ progs, ...)
Of course you are right!
Thanks to refresh my (so volatile?) memory! ;)
Fred
Philip Jacob Smith wrote:
>> jnc no_lowcarry : if no carry, just add the upper 32bits
>> inc ecx ;if carry, increments the upper 32bits
>> no_lowcarry:
>
>
> Oh my god...
>
> Ok, this is real easy now. Say we have two 64-bit numbers, as such:
>
> big_one dd 1, 2
> big_two dd 3, 4
>
> In normal intel backwardness (the right way, btw) 1 and 3 are the
> least signifigant dwords.
>
> It's as easy as this:
>
> add [big_one+0], [big_two+0]
> adc [big_one+4], [big_two+4]
>
> or, if you prefer code that compiles:
>
> mov eax, [big_two]
> add [big_one], eax
> mov eax, [big_two+4]
> adc [big_one+4], eax
>
> jc overflow_handler
>
> You just go from least signifigant to most signifigant adding them
> together, and use 'add' for the first and 'adc' for each one after
> that, and when you're done, the carry flag is the same as if you had
> added just one number, the 'jc overflow_handler' will jump only if the
> answer in this case would not fit into 64 bits. To subtract you do
> exactly the same thing, just using sub and sbc.
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2003-11-28 6:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-27 7:17 newbie :adding larger value Vadiraj C S
2003-11-27 8:07 ` Frederic Marmond
2003-11-27 15:20 ` Philip Jacob Smith
2003-11-28 6:59 ` Frederic Marmond [this message]
2003-11-27 12:41 ` peter willy krause
2003-11-27 11:51 ` Vadiraj C S
2003-11-27 12:57 ` peter willy krause
2003-11-27 16:34 ` Randall Hyde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FC6F26A.4060604@eprocess.fr \
--to=fmarmond@eprocess.fr \
--cc=linux-assembly@vger.kernel.org \
--cc=pj@evobsyniva.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.