Access Without AND / Re: Do You Use Bit Fields?

Clay Phipps phipps at fortune.UUCP
Fri Sep 28 11:45:10 AEST 1984

> 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 }          
   { ihnp4  cbosgd  decvax!decwrl!amd  harpo  allegra}

More information about the Comp.lang.c mailing list