Re: [cc65] More assignments and typecasting questions

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-07-23 19:59:08


On Tue, Jul 23, 2002 at 09:19:55AM -0700, Shawn Jefferson wrote:
> How do I do this:
>
> hdt_lo = hdtable % 256;
> hdt_hi = hdtable / 256;

There are several possibilities but the following one generates the best code:

        struct lo_hi {
            unsigned char lo, hi;
        };

        hdt_lo = ((struct lo_hi*) &hdtable)->lo;
        hdt_hi = ((struct lo_hi*) &hdtable)->hi;

As most casts of this type, it is non portable, but I'm sure you don't care
about that:-)

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-07-23 19:59:56 CEST