Initial commit
[nyankernel.git] / ARITHMETICS
blob4333847cd6a4055aca4287a18c8f5c52f8ddd13b
1 We always forget those:
3 log2 vals:
5 512GiB  39
6 1GiB    30
7 2MiB    21
8 4KiB    12
10 BYTES_N(log2)   shl(1,log2)
11 MSK_LO(log2)    (BYTES_N(log2) - 1)
12 MSK_HI(log2)    not(MSK_LO(log2))
14 Dangerous x86_64 ISA with its bitwise operators with sign extension from negative 32bits numbers to
15 64bits:
16 MSK_HI_S32(log2) (-BYTES_N(log2))
17 MSK_HI_S32(log2) (-MSK_LO(log2) - 1)
19 ALIGN_DOWN(val,log2)    val & MSK_HI(log2)
20 ALIGN_UP(val,log2)      (val + MSK_LO(log2) & MSK_HI(log2)
22 -X = ~X + 1, 2 complement.