From: Philip Jacob Smith <pj@evobsyniva.com>
To: linux-assembly@vger.kernel.org
Subject: Re: newbie :adding larger value
Date: Thu, 27 Nov 2003 10:20:58 -0500 [thread overview]
Message-ID: <oprzax88scb2epmx@localhost> (raw)
In-Reply-To: <3FC5B0C5.9040009@eprocess.fr>
> 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.
next prev parent reply other threads:[~2003-11-27 15:20 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 [this message]
2003-11-28 6:59 ` Frederic Marmond
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=oprzax88scb2epmx@localhost \
--to=pj@evobsyniva.com \
--cc=linux-assembly@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).