4.2 Numbers and Bits
- Data Types. Read IA-32 Volume 1 [3]
Pages 4-1 through 4-10 Sections 4.1 -- 4.5
- Flags. Read IA-32 Volume 1 [3] Pages 3-21 -- 3-22.
Section 3.4.3.1 about bits CF, ZF, SF, and OF.
- Binary Arithmetic Instructions.
Read IA-32 Volume 1 [3]
Pages 7-12 -- 7-13. Sections 7.3.2 -- 7.3.3
- Logical Instructions. Read IA-32 Volume 1 [3]
Pages 7-15. Sections 7.3.5
- Floating-point. Read IA-32 Volume 1 [3]
Pages 4-15 through 4-21 Sections 4.8 -- 4.8.3.2
- Browse at IA-32 Volume 1 [3] After page 5-4.
- Section 5.1.2 Binary Arithmetic Instructions
- Section 5.1.4 Logical Instructions
- Section 5.1.5 Shift and Rotate Instructions
- Section 5.1.6 Bit and Byte Instructions
- Section 5.1.7 Control Transfer Instructions
- Section 5.2.2 x87 FPU Basic Arithmetic Instructions
- Unsigned (positive) numbers
- Numbers, decimal, binary, and hexadecimal
Conversion table for small numbers
Binary | Octal | Decimal | Hexadecimal |
0000 | 0 | 0 | 0 |
0001 | 1 | 1 | 1 |
0010 | 2 | 2 | 2 |
0011 | 3 | 3 | 3 |
0100 | 4 | 4 | 4 |
0101 | 5 | 5 | 5 |
0110 | 6 | 6 | 6 |
0111 | 7 | 7 | 7 |
1000 | 10 | 8 | 8 |
1001 | 11 | 9 | 9 |
1010 | 12 | 10 | A |
1011 | 13 | 11 | B |
1100 | 14 | 12 | C |
1101 | 15 | 13 | D |
1110 | 16 | 14 | E |
1111 | 17 | 15 | F
|
- Math, add and subtract
- Math, multiply and divide by 2 (Popsicle toes [2])
- Fixed word lengths 8, 16, 32, 64, and 128 bits.
Possible values. 2n
Range. 2n-1
- 210, 1024 is about equal to 1000
- 220, 1048576 is about equal to 1,000,000
- overflow, carry bit, zero bit
Unsigned number range
Bits | Minimum | Maximum |
n | 0 | 2n-1 |
4 | 0 | 7 |
8 | 0 | 255 |
16 | 0 | 65535 |
32 | 0 | 4294967295 |
64 | 0 | 18446744073709551615 |
128 | 0 | 340282366920938463463374607431768211455
|
- Signed, ones complement, and twos complement numbers
- Twos complement numbers
- Range
- Possible values: 2n
- Possible positive values: 1 <==> 2n-1-1
- Zero.
- Possible negative values: -2n-1 <==> -1
- Range: -2n-1 <==> 2n-1-1
Twos complement range
Bits | Minimum | Maximum |
n | -2n-1 | 2n-1-1 |
4 | -8 | 7 |
8 | -128 | 127 |
16 | -32768 | 32767 |
32 | -2147483648 | 2147483647 |
64 | -9223372036854775808 | 9223372036854775807
|
- Twos complement operation
- Addition
- Subtraction
- Multiplication by 2
- Division by 2
- overflow, carry bit, zero bit, & sign bit
- Extended precision arithmetic.
- Base 256
- Base 65536
- Base 4294967296
- Base 18446744073709551616
- Logical operations
AND
, OR
, XOR
, and NOT
Logical Functions
a | b | a AND b | a OR b | a XOR b | NOT a |
0 | 0 | 0 | 0 | 0 | 1 |
0 | 1 | 0 | 1 | 1 | 1 |
1 | 0 | 0 | 1 | 1 | 0 |
1 | 1 | 1 | 1 | 0 | 0
|
- shifting, bit packing
- bit banging instructions
- I/O control registers
Number conversion: Fill in table
Binary | Decimal | Hexadecimal |
| 133 | |
| 158 | |
1011011 | | |
1100100 | | |
| | 0x00 |
| | 0x12 |
| | 0x34 |
| | 0x77 |
| | 0xA7 |
| | 0x80 |
| .125 | |
10110.011012 |
|
|
Arithmetic: Fill in table
Expression | Binary | Decimal | Hexadecimal |
0xABCD + 0x94DB |
| XXXXX | |
0xABCD - 0x94DB | | XXXXX | |
0xABCD * 2 | | XXXXX | |
0x94DB / 2 | | XXXXX | |
133 + 158 | | | |
0xA7 + 0x12 | | | |
0x77 + 0x77 | | | |
0x77 / 2 | | | |
0x77 * 2 | | |
|
8 bit twos complement - conversion: Fill in table
Binary | Decimal | Hexadecimal |
| 57 | |
| -57 | |
| 128 | |
| | 0x00 |
| | 0x12 |
| | 0x34 |
| | 0x77 |
| | 0xA7 |
| | 0x80
|
8 bit math: Fill in table
Expression | Signed | Unsigned | Hex | OF | SF | ZF | CF |
0x00 - 0x77 | | | | | | | |
0x00 - 0xA7 | | | | | | | |
0x34 + 0x12 | | | | | | | |
0x34 - 0x12 | | | | | | | |
0xA7 - 0x77 | | | | | | | |
0x77 + 0x77 | | | | | | | |
0xA7 + 0xA7 | | | | | | | |
-0x77 / 2 | | | | | | | |
-0x77 / 2 | | | | | | | |
0x00 - 0x80 | | | | | | | |
0xFF + 0x01 | | | | | | |
|
Logical Function Practice
a | b | a AND b
| a OR b
| a XOR b
| NOT a
0x03 | 0x06 | | | | |
0xFF | 0x5A | | | | |
0x00 | 0x5A | | | | |
0x00 | 0xFF | | | |
|
Turn in the five (5) tables with your name written on them. This is the math lab.
Instructor: Louis Taber, louis.taber.at.pima at gmail dot com (520) 206-6850
My web site in California
The Pima Community College web site