CPSC 355 Lecture Notes - Lecture 12: Sign Bit
Document Summary
Cpsc 355 - lecture 12 oct 7th. Logical shift right: form (64-bit): lsr xd, xn, xm. Xm: shift count: 0 is shifted into leftmost bit. Shifted out bits are lost: lsr is a way to do division by a power of two, any remainder is lost. I. e. : by 2n, where n is the shift count. Eg: 15 / 4 = 3 mov x20, 15 mov x21, 2 lsr x19, x20, x21. // 0000 0011: do not work for negative signed integers, 32-bit form and immediate form also exist. 0 is inserted at bit 31 when using w operands. Arithmetic shift right: form (64-bit): asr xd, xn, xm. Xm: shift count: sign bit is duplicated when shifting. Called (cid:862)sign extension(cid:863: asr preserves the sign when dividing by a power of two. Eg: -8 / 2 = -4 mov x20, -8 mov x21, 1 asr x19, x20, x21. // (cid:1005)(cid:1005)(cid:1005)(cid:1005) (cid:1005)(cid:1005)(cid:1005)(cid:1005) (cid:1005)(cid:1005)(cid:1004)(cid:1004: 32-bit and immediate forms also exist.