Binary & Int representations | Bitwise Operations Flashcards
voltage for binary numbers
0: 0V
1: 3.3V
How many bit patters can an n-bit register hold?
2^n bit patters
Range of unsigned integers and how are they encoded?
Range: 0 to (2^n)-1
Encoded using binary numbers
Range of signed integers and how are they encoded?
Range: -(2^n-1) to (2^n-1)-1
Encoded using two’s complement
How is a number negated?
- Take one’s complement (flip bits)
- Add 1 to the result
How to distinguish a +/- signed int?
The leftmost bit is the signed bit. 0 = + and 1 = -
Do we use sign-magnitude and one’s complement of signed integers?
No, they are awkward to handle in hardware, they have +0 and -0. Rarely used today.
What are hex numbers commonly used for?
Shorthands for denoting bit patterns
What data model does Linux on ARMv8 in AArch 64 use?
LP64 data model
Long ints and
Pointers are
64 bits long
What are the 5 A64 keywords, their sizes in bits and corresponding C keyword?
- Byte, 8 bits, char
- Halfword, 16 bits, short int
- Word, 32 bits, int
- Doubleword, 64 bits, long int / void
- Quadword, 128, N/A
How to define an unsigned integer in C?
unsigned int x;
or for char
unsigned char x;
What do bitwise logical instructions do?
Manipulate 1 or more bits in a register
what’s it called when these two are anded together and the result is all 0’s
1010
0000
———
0000
A bitmask “masks out” these bits
Check if bit 3 is set in x20
uses ands, check notes
set bits 4&5 in x20
uses orr, check notes
orr doesn’t need an s