On Fri, Feb 8, 2013 at 9:56 AM, Harley Laue <losinggenerat...@gmail.com>wrote:

> TL;DR
>
>
> On Fri, Feb 8, 2013 at 9:08 AM, roelof 't Hooft <roel...@itholland.nl>wrote:
>
>> I am using the following in a header file :
>>
>> #define crystal 11059200
>> #define bd4800 (256 - crystal / 192 * 4800)
>>
>> Here the result is 0xef854100
>>
>
> Based on the order of precidence, this looks like the right answer to me:
> 11059200/192 = 57600
> 57600*4800 = 276480000
> 256-276480000=0xFFFFFFFFEF854100
>
>
>>
>> #define crystal 11059200
>> #define bd4800 (256 - (crystal / 921600))
>>
>> And here the (correct) result is 0xf4
>>
>
> If this is the answer you're expecting, you'd want to use:
> #define bd4800 (256 - crystal / (192 * 4800))
>

I guess I /should/ have read the rest/verified the results. Without
actually looking at SDCC's source code, I'd wager your assumption on it
doing the math in 16 bit ints is correct (as it gives the warning: integer
overflow in expression.)
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to