Week Three Flashcards
The decimal integer 24685 is 606Dh. Show the endian form of the 32-bit representation:
a. 32-bit Big Endian
b. 32-bit Little Endian
a. Big Endian: 00 00 60 6D
b. Little Endian: 6D 60 00 00
When does MUL set the Carry and Overflow flags?
Carry and overflow flags are only set when there are numbers in the higher bits of the product. This means that the product will not fit solely into the lower half of the destination operand.
When AX is multiplied by a 16-bit operand where is the product stored?
When would the Carry flag be set?
The high 16 bits are stored in DX, the low 16 bits are stored in AX.
The Carry flag is set if DX is not equal to zero, which lets us know that the product will not fit into the lower half of the implied destination.
To create a hamming code word, we need n = m + r with m data bits, r check bits (parity), for an n-bit code word.
How many possible code words are there?
How many possible valid codes?
How many possible error codes?
a. 2^n code words
b. 2^m valid code words
c. 2^r invalid code words
How many parity bits should we have in a given code word of:
8 bits?
16 bits?
32 bits?
log2 m + 1 parity bits
log2 8 + 1 = 3 + 1 = 4
log2 16 +1 = 4 + 1 = 5
log2 32 +1 = 5 + 1 = 6
How do you find the hamming distance between two strings?
What does this hamming distance mean?
xor the values and then count the number of 1 bits.
1101 1001
1001 1101
0100 0100 = 2 bits
To change from one valid code to another valid code, at least 2 bits must be changed.
How do you determine a parity bit’s value of 0 or 1?
Sum the parity bits selected data bits. For even parity, if the data bits sum total is an even number, set the check bit to 0, else set it to 1. Perform the reverse for odd parity.
In a given hamming code, which bits are parity bits?
Bits numbered with powers of 2 are parity bits.
2^0, 2^1, 2^2, 2^3, etc.
Write an instruction to clear bit 5 without affecting any other bits.
and AL, 1101 1111
and-ing with 1 allows bits to remain unchanged, while and-ing with zero clears that bit.
Write an instruction to set bit 5 without affecting any other bits.
or AL, 0010 0000
or-ing with 0 allows bits to remain unchanged, while or-ing with 1 sets that bit.
Write an instruction to flip all the bits in order to find the complement.
mov eax, SetX
not eax
reverses all bits in Setx to find the complement
What is a single instruction that inverts bits 5 and 6 in AL without changing any other bits?
xor al, 0110 0000
xor using a 0 retains the value, xor with a 1 flips the value.
What are the values of the carry, zero and sign flags for the following code:
mov al, 6
cmp al, 5
destination > source
CF = 0, ZF = 0, SF = 0
What are the values of the zero and carry flags for the following unsigned comparisons?
a. destination < source
b. destination > source
c. destination = source
a. ZF = 0, CF = 1
b. ZF = 0, CF = 0
c. ZF = 1, CF = 0
What are the values of the carry, zero and sign flags for the following code:
mov al, 5
cmp al, 7
destination < source CF = 1 ZF = 0 SF = 1 The sign flag is set because 5 - 7 = -2