Class 23: Counting In Hex And Integer Multi/Div Flashcards
The stack grows _____ in RAM. (the address decrease as we push more and more value onto the stack)
Downward
Hex subtraction
8000 - 0008
7FF8
_____ are places on CPU where data is stored, typically in 8 bytes
Registers
Every binary value is an addition in powers of ___
2
If we are multiplying by some number K, where K is represented by 2^k, shift _____ by k.
Left
Shifting, adds, and subtracts, generally take ___ clock cycle, many fewer clock cycles than multiplication and division
1
X = 5;
X7 = 35. / 7 = 0111
N = 2. M = 0
X«2 + x«1 + x«0
OR
X«3 - x«0
Formual for negative constants
(X«m) - (x «n+1)
N= position of leftmost 1
M = position of rightmost 1
If the most significant bit in op1 is in the position of op1n, and if operants and the result have w bit representations, how many bits can op1 be shifted left before overflow due to shifting occurs
(W-1) - op1n
Ex: w = 4 bits op1n = 2 (0110) then 4-1-2 = -1
We can only shift left once, any more than that causes overflow
What is the significance between op2n and the maximum number of bits that op1 is shifted left by the multiplication algorithm
Op2n is the maximum number of bits that op1 can be shifted left
If op2n ____ w-1-op1n, overflow due to shifting will occur.
>
Dividing by powers of 2 —> ______
Right shifting
Dividing by 2^k
Right shifting by k (x»k)
Then rounding down (toward zero)
Signed integer division
Two complement
Sign extends for arithmetic shift (fill with copy of msb)
Rounds down (away from zero for negative results)
-7/2 will yield -4 rather than -3
W = 8, op1 = 4, op2 = 3
Does overflow occur?
W(8) -1-op1n (4) = 3
Is op2n > w-1-op1n? Yes, 3>3
No overflow
Dividing by powers of 2 —>
Right shifting
Integer divison always _____
Truncates
Signed integer division
- Two’s complement
- Sign extend for arithmetic shift (fill with copy of msg)
- Rounds down (away from 0 for negative results)
-7/2 will yield -4 rather than -3