Computer Systems Midterm: x86 Registers, Flags, and Bitwise Operations

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/50

encourage image

There's no tags or description

Looks like no tags are added yet.

51 Terms

1
New cards

What is the size of a byte in bits?

A byte contains 8 bits.

2
New cards

What does the EAX register represent in terms of bits?

EAX is a 32-bit register.

3
New cards

How do AH and AL relate to AX?

AH is the upper 8 bits and AL is the lower 8 bits of AX.

4
New cards

What is the result of changing AL in AX?

Changing AL replaces only the lower byte of AX.

5
New cards

What happens when you change AX?

Changing AX replaces both AH and AL, but leaves the upper 16 bits of EAX unchanged.

6
New cards

How is AX calculated from AH and AL?

AX = AH Ɨ 256 + AL.

7
New cards

What is the purpose of the MOV instruction?

MOV copies a value; it does not remove the value from the source.

8
New cards

What does the ADD instruction do?

ADD adds to the destination.

9
New cards

What does the INC instruction do?

INC adds 1 to the destination.

10
New cards

What are the binary place values for 8 bits?

128, 64, 32, 16, 8, 4, 2, and 1.

11
New cards

What is the range of 8-bit unsigned numbers?

0 to 255.

12
New cards

What is the range of 8-bit two's complement numbers?

āˆ’128 to 127.

13
New cards

How is a negative number represented in two's complement?

Flip every bit of its positive representation and add 1.

14
New cards

What is the representation of +6 in sign-magnitude?

+6 = 00000110.

15
New cards

What is the representation of -6 in one's complement?

āˆ’6 = 11111001.

16
New cards

What does the Zero Flag (ZF) indicate?

ZF = 1 when all result bits are zero.

17
New cards

What does the Sign Flag (SF) represent?

SF copies the result's leftmost bit.

18
New cards

What does the Carry Flag (CF) indicate?

CF = 1 for an unsigned carry out in addition or an unsigned borrow in subtraction.

19
New cards

What does the Overflow Flag (OF) indicate?

OF = 1 when a signed arithmetic result cannot fit in the destination.

20
New cards

What is the effect of the INC and DEC instructions on flags?

INC and DEC change ZF, OF, and SF but preserve CF.

21
New cards

What is the result of adding 1 to 12FFh in AX?

AX becomes 1300h; CF = 0.

22
New cards

What is the two's complement representation of -1 in 8 bits?

11111111.

23
New cards

How do you decode a negative pattern in two's complement?

Invert and add 1 to find its magnitude, then attach the negative sign.

24
New cards

What is the 8-bit range for sign-magnitude representation?

āˆ’127 to 127.

25
New cards

What is the result of adding AL and 1 when AL is 00h?

AL wraps to 00h; AH stays the same.

26
New cards

What is the result of changing AH to 78h when AX is 1256h?

AX becomes 7856h.

27
New cards

What is the effect of the MOV instruction on flags?

MOV does not change ZF, OF, CF, or SF.

28
New cards

What is the condition for signed addition overflow when adding two positive numbers?

Positive + positive producing a negative stored result → overflow.

29
New cards

What indicates signed addition overflow when adding two negative numbers?

Negative + negative producing a nonnegative stored result → overflow.

30
New cards

What is the outcome of adding a positive and a negative number regarding overflow?

Positive + negative → no signed addition overflow.

31
New cards

What is the shortcut rule for detecting signed addition overflow?

Same-sign inputs, opposite-sign result → OF = 1.

32
New cards

In an 8-bit addition, what happens when 127 is added to 1?

It results in overflow: 01111111 + 00000001 → 10000000, which means āˆ’128.

33
New cards

What is the condition for carry flag (CF) in signed addition?

No carry left the 8-bit destination, so CF = 0.

34
New cards

What is the difference between carry and overflow in arithmetic operations?

Carry checks unsigned arithmetic; overflow checks signed arithmetic.

35
New cards

What does CF indicate in subtraction?

CF = 1 if the first unsigned value is smaller than the value being subtracted.

36
New cards

What does ZF represent in the context of arithmetic results?

ZF = 1 if all stored result bits are zero.

37
New cards

What is the result of the bitwise AND operation?

AND → 1 only when both bits are 1.

38
New cards

What is the result of the bitwise OR operation?

OR → 1 when at least one bit is 1.

39
New cards

What does the XOR operation yield?

XOR → 1 when the bits are different.

40
New cards

What does the NOT operation do?

NOT → flips every bit.

41
New cards

What happens during a left shift (SHL)?

SHL shifts left and inserts zeros on the right.

42
New cards

What is the effect of a right shift (SHR)?

SHR shifts right and inserts zeros on the left.

43
New cards

What does a left shift by k multiply by?

A left shift by k multiplies by 2^k if the result fits.

44
New cards

What does an arithmetic right shift (SAR) do?

SAR shifts right and repeats the original sign bit on the left.

45
New cards

What is the purpose of the shift flags?

Shift flags reflect the outcome of shift operations and indicate overflow and carry.

46
New cards

What is the range of an 8-bit two's-complement representation?

The range is āˆ’128 to 127.

47
New cards

What is the result of the operation 5 SHL 2?

It results in 20.

48
New cards

What is the result of the operation 29 SHR 3?

It results in 3.

49
New cards

What is the difference between SHR and SAR for signed values?

SHR fills with zeros; SAR copies the sign bit.

50
New cards

What common mistake is made regarding the sizes of AH and AL?

AH and AL are both 8 bits; AX is 16 bits.

51
New cards

What happens when you update AL?

Updating AL does not replace all of AX or EAX.