Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site fortune.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!fortune!phipps From: phipps@fortune.UUCP (Clay Phipps) Newsgroups: net.lang.c,net.arch Subject: Access Without AND / Re: Do You Use Bit Fields? Message-ID: <4360@fortune.UUCP> Date: Thu, 27-Sep-84 21:45:10 EDT Article-I.D.: fortune.4360 Posted: Thu Sep 27 21:45:10 1984 Date-Received: Fri, 28-Sep-84 07:18:50 EDT References: <12150@sri-arpa.UUCP> Organization: Fortune Systems, Redwood City, CA Lines: 23 > It could be worse: the JOVIAL I saw masked off bitfields > by shifting them to the high order end of the word, > then shifting back to the low order end. > Never heard of the AND instruction, I guess.) On some machines (the IBM 360s come to mind, since 4300s were mentioned), the technique you disparage was *faster* than using an AND, assuming that the sign-extended or zero-extended bit field was needed, and the necessary mask was in storage, not in a register. If those conditions held, you avoided a time-expensive memory access by keeping everything in registers and shifting (the "immediate" AND, with an 8-bit mask in the instruction, was slower). The superiority of the shift-shift technique ended for IBM mainframes when the cache-bearing 370s became available; with a cache hit, ANDing from memory (160 ns) was faster than 2 shifts (240 ns). -- Clay Phipps -- { amd hplabs!hpda sri-unix ucbvax!amd } !fortune!phipps { ihnp4 cbosgd decvax!decwrl!amd harpo allegra}