Week Three Flashcards

1
Q

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

a. Big Endian: 00 00 60 6D

b. Little Endian: 6D 60 00 00

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When does MUL set the Carry and Overflow flags?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When AX is multiplied by a 16-bit operand where is the product stored?
When would the Carry flag be set?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

a. 2^n code words
b. 2^m valid code words
c. 2^r invalid code words

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many parity bits should we have in a given code word of:
8 bits?
16 bits?
32 bits?

A

log2 m + 1 parity bits
log2 8 + 1 = 3 + 1 = 4
log2 16 +1 = 4 + 1 = 5
log2 32 +1 = 5 + 1 = 6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you find the hamming distance between two strings?

What does this hamming distance mean?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you determine a parity bit’s value of 0 or 1?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In a given hamming code, which bits are parity bits?

A

Bits numbered with powers of 2 are parity bits.

2^0, 2^1, 2^2, 2^3, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write an instruction to clear bit 5 without affecting any other bits.

A

and AL, 1101 1111

and-ing with 1 allows bits to remain unchanged, while and-ing with zero clears that bit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write an instruction to set bit 5 without affecting any other bits.

A

or AL, 0010 0000

or-ing with 0 allows bits to remain unchanged, while or-ing with 1 sets that bit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write an instruction to flip all the bits in order to find the complement.

A

mov eax, SetX
not eax
reverses all bits in Setx to find the complement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a single instruction that inverts bits 5 and 6 in AL without changing any other bits?

A

xor al, 0110 0000

xor using a 0 retains the value, xor with a 1 flips the value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the values of the carry, zero and sign flags for the following code:

mov al, 6
cmp al, 5

A

destination > source

CF = 0, ZF = 0, SF = 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

a. ZF = 0, CF = 1
b. ZF = 0, CF = 0
c. ZF = 1, CF = 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the values of the carry, zero and sign flags for the following code:

mov al, 5
cmp al, 7

A
destination < source
CF = 1
ZF = 0
SF = 1 
The sign flag is set because 5 - 7 = -2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Write code to access the following elements in the array:

a. 0th element
b. 1st element
c. last element

.data
array SWORD 8, 2, 3, -4

A

mov esi, 0 ; initialize esi to 0
mov ax, array[esi] ; AX = 8
mov ax, array[esi + 2] ; AX = 2
mov ax, [esi + 6] ; AX = -4

Or for the last element:
mov esi, 3 * TYPE array ; offset of array[3]
mov ax, array[esi] ; AX = -4

OR
mov    esi, OFFSET array
mov    ax, [esi]
mov    ax, [esi+2]
mov    ax, [esi+6]
17
Q

Where is the product stored for the following MUL instructions?

a. MUL AL, reg/mem8
b. MUL AX, reg/mem16
c. MUL EAX, reg/mem32

A

a. AX
b. DX: AX (high bits: low bits)
c. EDX: EAX (high bits: low bits)

18
Q

When are the overflow and carry flags set with the IMUL instruction?

A

When the higher bits of the product are not a sign extension of the lower bits or if significant digits are lost due to two operand multiplication.

19
Q

Why is the Overflow flag not set after the following instructions?

mov ax,48
mov bx,4
imul bx

A

The upper bits of ax are 0000 0000 and these were sign extended into dx, which cleared the overflow flag.

20
Q

What is the value of the Overflow flag after the following instructions and why?

.data
word1 SWORD 4
dword1 SDWORD 4

.code
imul bx, word1, -16
imul ebx, dword1, -16
imul ebx, dword1, -2000000000

A

The value of the overflow flag is 1 because the final instruction is too large for it’s destination. Two and three-operand IMUL instructions use a destination operand that is the same size as the multiplier.

21
Q

What size destination operands do the following instructions use?

a. single operand IMUL
b. two-operand and three-operand IMUL

A

a. destination registers that are twice the size of the source operand
b. The two-operand and three-operand IMUL instructions use a destination operand that is the same size as the multiplier. Therefore, it is possible for signed overflow to occur.

22
Q

What is the value of the Overflow flag after the following instructions? Why?

mov al, 48 ; AL = 30
mov bl, 4
imul bl ; AX = 00C0

A

OF flag = 1
The flag is set because sign extension did not occur.
The result of multiplying 48 *4 = 1100 0000b, and the 1’s did not get extended into the higher bits of AX.

23
Q

What is the value of the Carry flag after the following instructions?

.data
val1 WORD 0010.0000.0000.0000b
val2 WORD 0000.0001.0000.0000b

.code
mov ax,val1
mul val2 
; dx = 0000.0000.0010.0000b
; ax = 0000.0000.0000.0000b
A

The carry flag is set to 1 because the DX does not equal zero.

24
Q

What is the value of the Overflow flag after the following instructions?

mov al,-4 ; AL = FC
mov bl,4 ; BL = 04
imul bl ; AX = FFF0

A

OF flag = 0 because sign extension occurs in AX.

25
Q

Identify the sizes of the following parts that make up a Single Precision x86 floating point number:

a. sign
b. exponent
c. significand

A

a. 1
b. 8
c. 23

26
Q

The following instruction is invalid:

inc [ESI]

A

True, PTR is required.

inc BYTE PTR [ESI]

27
Q

When should you not push?

A

When pushing will hide a return address.

28
Q

When should you not pop?

A

When popping will lose a return address, replace needed values, or when the stack is empty.