Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!hplabs!hpfcdc!hpislx!hplvli!boyne From: boyne@hplvli.HP.COM (Art Boyne) Newsgroups: comp.lang.c Subject: Re: bitfields considered harmful? Message-ID: <340011@hplvli.HP.COM> Date: 4 May 89 14:51:27 GMT References: <1473@uwbull.uwbln.UUCP> Organization: Loveland Inst. Div Lines: 20 >sme@computing-maths.cardiff.ac.uk (Simon Elliott) writes: >In article <1473@uwbull.uwbln.UUCP>, ckl@uwbln.UUCP (Christoph Kuenkel) writes: >> I like [bitfields] cause they save space and are much more readable than >> oriing/anding with # defines and i dont have to bother with questions like >> how many flags fit into one int. > >Well, you may be right about readability, but I don't think you'll find that >you've saved much space in your program. Oh, you might save it in the >source, but the same shifting and masking is going on under the hood. Whoa! Whether or not the shifting and masking takes place depends on the processor you are running on. With the 68000, single bit bitfields can be handled with the BCLR, BSET, BCHG, and BTST instructions. The 68020 has a set of multi-bit bitfield instructions for insertion, extraction, and testing. PS. I know that, internally, the processor is still doing shift/mask, but it isn't taking up my code space! Art Boyne, boyne@hplvla.hp.com