Let’s load each of the powers of two up to 2³¹, in canonical form.
LDA Ra, 0x0001(zero) ; Ra = 0x00000000`00000001 ; bit 0 LDA Ra, 0x0002(zero) ; Ra = 0x00000000`00000002 ; bit 1 LDA Ra, 0x0004(zero) ; Ra = 0x00000000`00000004 ; bit 2 LDA Ra, 0x0008(zero) ; Ra = 0x00000000`00000008 ; bit 3 LDA Ra, 0x0010(zero) ; Ra = 0x00000000`00000010 ; bit 4 LDA Ra, 0x0020(zero) ; Ra = 0x00000000`00000020 ; bit 5 LDA Ra, 0x0040(zero) ; Ra = 0x00000000`00000040 ; bit 6 LDA Ra, 0x0080(zero) ; Ra = 0x00000000`00000080 ; bit 7 LDA Ra, 0x0100(zero) ; Ra = 0x00000000`00000100 ; bit 8 LDA Ra, 0x0200(zero) ; Ra = 0x00000000`00000200 ; bit 9 LDA Ra, 0x0400(zero) ; Ra = 0x00000000`00000400 ; bit 10 LDA Ra, 0x0800(zero) ; Ra = 0x00000000`00000800 ; bit 11 LDA Ra, 0x1000(zero) ; Ra = 0x00000000`00001000 ; bit 12 LDA Ra, 0x2000(zero) ; Ra = 0x00000000`00002000 ; bit 13 LDA Ra, 0x4000(zero) ; Ra = 0x00000000`00004000 ; bit 14 LDAH Ra, 0x0001(zero) ; \ LDA Ra, 0x8000(Ra) ; / Ra = 0x00000000`00008000 ; bit 15 LDAH Ra, 0x0001(zero) ; Ra = 0x00000000`00010000 ; bit 16 LDAH Ra, 0x0002(zero) ; Ra = 0x00000000`00020000 ; bit 17 LDAH Ra, 0x0004(zero) ; Ra = 0x00000000`00040000 ; bit 18 LDAH Ra, 0x0008(zero) ; Ra = 0x00000000`00080000 ; bit 19 LDAH Ra, 0x0010(zero) ; Ra = 0x00000000`00100000 ; bit 20 LDAH Ra, 0x0020(zero) ; Ra = 0x00000000`00200000 ; bit 21 LDAH Ra, 0x0040(zero) ; Ra = 0x00000000`00400000 ; bit 22 LDAH Ra, 0x0080(zero) ; Ra = 0x00000000`00800000 ; bit 23 LDAH Ra, 0x0100(zero) ; Ra = 0x00000000`01000000 ; bit 24 LDAH Ra, 0x0200(zero) ; Ra = 0x00000000`02000000 ; bit 25 LDAH Ra, 0x0400(zero) ; Ra = 0x00000000`04000000 ; bit 26 LDAH Ra, 0x0800(zero) ; Ra = 0x00000000`08000000 ; bit 27 LDAH Ra, 0x1000(zero) ; Ra = 0x00000000`10000000 ; bit 28 LDAH Ra, 0x2000(zero) ; Ra = 0x00000000`20000000 ; bit 29 LDAH Ra, 0x4000(zero) ; Ra = 0x00000000`40000000 ; bit 30 LDAH Ra, 0x8000(zero) ; Ra = 0xFFFFFFFF`80000000 ; bit 31
Bit 15. Ugh. Bit 15.
It’s the only one that requires two instructions to calculate the 32-bit mask in canonical form.
This means that if you have a bitfield, bit 15 is slightly more expensive than the others.
Bonus chatter: In an internal discussion of byte manipulation on the Alpha AXP, I happened to have written “Bit 15. Ugh. Bit 15.” Gov Maharaj (co-host of The Defrag Show and application compatibility master extraordinaire) told me, “That needs to be the title of a blog post.” So here it is.
0 comments