<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>40 bit subtraction</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17481/40-bit-subtraction</link><description> Can anyone please give me some hints as to how to go about subtracting one 40 bit number from another? 
At the start of a process I read a 5 byte counter from external hardware and store it. At the end of the process I read the 5 byte counter again.</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: 40 bit subtraction</title><link>https://community.arm.com/thread/41974?ContentTypeID=1</link><pubDate>Mon, 05 Apr 2004 08:02:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a4cb16eb-4631-4c3e-b4a2-7e209f09f2e6</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;Something like the following model, perhaps?  Adjust to suit your taste...&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;struct _40BITS
{
    unsigned char ms8;
    unsigned long ls32;
};

struct _40BITS sub40(struct _40BITS minuend, struct _40BITS subtrahend)
{
    struct _40BITS difference;

    if (minuend.ls32 &amp;lt; subtrahend.ls32)
        --minuend.ms8;

    difference.ls32 = minuend.ls32 - subtrahend.ls32;
    difference.ms8  = minuend.ms8  - subtrahend.ms8;
    return difference;
}

int main(void)
{
    struct _40BITS start = {0xFF,0xFFFFFFFE};
    struct _40BITS end   = {0x00,0x00000001};
    struct _40BITS diff  = sub40(end, start);
    return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>