Chapter 4.1 Flashcards

1
Q

What is a data transfer instruction?

A

Instruction that copies data from a source operand to a destination operand

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

What is an operand?

A

A value that is used for input or output for an instruction

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

What types of operands can assembly language instructions have?

A
  • Register
  • Memory operand
  • Integer expression
  • Input–output port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an immediate operand?

A

A constant integer (8, 16, or 32 bits) encoded within the instruction

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

What is a register operand?

A

The name of a register that specifies a processor register as the source or destination of an operation

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

What is a memory operand?

A

Reference to a location in memory, specified using an address

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

What is the syntax of the MOV instruction?

A

MOV destination, source

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

What is a direct memory operand?

A

A named reference to storage in memory that is automatically dereferenced by the assembler

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

What are the restrictions on operands for the MOV instruction?

A
  • No more than one memory operand permitted
  • Both operands must be the same size
  • CS, EIP, and IP cannot be the destination operand
  • No immediate to segment moves
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why is the MOV instruction ‘mov ds, 45’ invalid?

A

DS register is a read-only control register managed by the processor

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

What does the MOVZX instruction do?

A

Fills the upper half of the destination with zeros when copying a smaller value into a larger destination

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

What does the MOVSX instruction do?

A

Fills the upper half of the destination with a copy of the source operand’s sign bit

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

What are the rules for operands in the XCHG instruction?

A
  • At least one operand must be a register
  • No immediate operands are permitted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when using ‘mov al, arrayB+1’?

A

AL = 20h, where a constant offset is added to a data label to produce an effective address

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

What is an effective address (EA)?

A

An address produced by adding a constant offset to a data label

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

What must the destination be for a MOV instruction?

A

A register

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

Fill in the blank: The MOV instruction copies data from a _______ to a destination operand.

A

source operand

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

True or False: The MOV instruction can have more than one memory operand.

A

False

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

What does the instruction ‘mov ax, num2’ do?

A

AX is loaded with the word value stored in num2

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

What is the result of ‘mov al, num1’ where num1 is a byte?

A

AL will hold the value of num1

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

What is the purpose of the STC instruction?

A

Sets the Carry flag, indicating that an overflow occurred

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

What happens if you try to copy a smaller operand to a larger one directly?

A

MOV cannot directly copy data from a smaller operand to a larger one

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

What is the result of ‘mov eax, 0FFFFFFFFh’?

A

EAX is filled with the value 4294967295d

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

What occurs when ‘mov ax, [arrayW+2]’ is executed?

A

AX will be loaded with 2000h

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

True or False: The operand types in assembly language instructions can include immediate values.

A

True

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

What is a DWORD?

A

A DWORD is a data type that consists of 32 bits or 4 bytes.

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

What does the CY (Carry Flag) indicate?

A

It indicates whether an arithmetic operation produced a carry or borrow.

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

What does the PE (Parity Flag) indicate?

A

It indicates whether the result of an operation has an even or odd number of 1 bits.

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

What is the function of the ZR (Zero Flag)?

A

It indicates whether the result of an operation is zero.

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

What does the PL (Sign Flag) indicate?

A

It indicates whether the result of an operation is negative.

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

What does the OV (Overflow Flag) indicate?

A

It indicates whether the result of an operation has exceeded the maximum or minimum value that can be represented in the destination operand.

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

What does the AC (Auxiliary Carry Flag) indicate?

A

It indicates whether a carry was generated from bit 3 to bit 4 during an arithmetic operation.

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

What is the role of the UP (Direction Flag)?

A

It controls the direction of string operations (incrementing or decrementing).

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

What do the INC and DEC instructions do?

A

INC adds 1 to the destination operand, and DEC subtracts 1 from the destination operand.

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

What does the NEG instruction do?

A

The NEG instruction reverses the sign of a number by converting it to its two’s complement.

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

Fill in the blank: The _______ flag indicates that an operation produced zero.

A

Zero Flag

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

What is the significance of the Carry flag (CF)?

A

CF = 1 when the sum exceeds the storage size of its destination operand.

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

What is the purpose of the Overflow flag (OF)?

A

It is set when the result of a signed arithmetic operation overflows or underflows the destination operand.

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

True or False: The MOV instruction affects CPU status flags.

40
Q

What happens when two positive operands are added and their sum is negative?

A

The Overflow flag is set.

41
Q

What happens when two negative operands are added and their sum is positive?

A

The Overflow flag is set.

42
Q

What is the OFFSET operator used for?

A

It is used to get the memory address of a variable.

43
Q

What is the SIZEOF operator used for?

A

It is used to determine the size of a data type or a variable.

44
Q

What does the LENGTHOF operator return?

A

It returns the length of an array or a string.

45
Q

What is the purpose of the TYPE operator?

A

It is used to determine the data type of a variable.

46
Q

What does the PTR operator specify?

A

It specifies the type of pointer to be used.

47
Q

What are the essential flags affected by arithmetic operations?

A
  • Zero flag
  • Sign flag
  • Carry flag
  • Overflow flag
48
Q

What is the result of the instruction ‘add al, 1’ when AL = 0?

A

AL becomes 1.

49
Q

Fill in the blank: The _______ flag is set when a carry occurs from bit 3 to bit 4.

A

Auxiliary Carry Flag

50
Q

What is the effect of the INC instruction on the Carry flag?

A

The INC instruction does not affect the Carry flag.

51
Q

What is the result of adding 1 to the largest possible integer signed byte value?

A

It causes the value to become negative.

52
Q

What does the Parity flag (PF) indicate?

A

It is set when the destination has an even number of 1 bits.

53
Q

What happens to the Overflow flag when the result of an operation is valid?

A

The Overflow flag is cleared.

54
Q

What is the result of ‘mov al, 80h; add al, 92h’ regarding the Overflow flag?

A

The Overflow flag is set (OF = 1).

55
Q

What happens when the instruction ‘sub cx, 1’ is executed with CX = 0?

A

CX becomes -1, and the Sign flag is set.

56
Q

What does the OFFSET operator do?

A

Returns the address of a variable in memory.

57
Q

What is the value of OFFSET bVal if the data segment starts at 00404000h?

58
Q

What is the size of a DWORD?

A

32 bits = 4 bytes.

59
Q

How does the TYPE operator function?

A

Returns the size, in bytes, of a single element of a data declaration.

60
Q

What is the result of the TYPE operator for a byte?

61
Q

What is the LENGTHOF operator used for?

A

Counts the number of elements in a single data declaration (array).

62
Q

What does the SIZEOF operator calculate?

A

Returns a value equivalent to multiplying LENGTHOF by TYPE.

63
Q

What is Little Endian order?

A

A method of storing multi-byte integers with the least significant byte at the lowest address.

64
Q

True or False: In Little Endian order, the most significant byte is stored first.

65
Q

What does the PTR operator do?

A

Overrides the default type of a label and provides access to part of a variable.

66
Q

What is an indirect operand?

A

A 32-bit general-purpose register used to hold the address of a variable.

67
Q

What happens when you dereference an indirect operand?

A

You access the value stored at the address held by the register.

68
Q

What is the purpose of using the PTR operator with indirect operands?

A

To clarify the size attribute of a memory operand.

69
Q

What is the result of the command ‘mov ax, WORD PTR [esi]’?

A

Moves a word-sized value from the address in ESI to AX.

70
Q

How do you scale an index for an array element?

A

Multiply the index by the array’s TYPE.

71
Q

What does the JMP instruction do?

A

Transfers control to a different memory address unconditionally.

72
Q

What is the LOOP instruction used for?

A

To repeat a block of code a specified number of times.

73
Q

Fill in the blank: The SIZEOF operator returns a value that is equivalent to multiplying LENGTHOF by _______.

74
Q

What is the difference between LENGTHOF and SIZEOF when dealing with multi-line data declarations?

A

LENGTHOF counts the elements, SIZEOF calculates the total size.

75
Q

What is the size returned by the TYPE operator for a doubleword?

76
Q

What is the significance of using the ‘OFFSET’ directive in assembly language?

A

It provides the memory address of a variable for indirect addressing.

77
Q

What is the result of the command ‘mov eax, DWORD PTR myBytes’ if myBytes contains 12h, 34h, 56h, 78h?

A

EAX = 78563412h

78
Q

What does the command ‘add esi, TYPE arrayW’ do?

A

Increments ESI by the size of the array elements.

79
Q

What does a pointer variable represent?

A

The address of another variable.

80
Q

True or False: An indirect operand can only hold addresses of byte-sized variables.

81
Q

What is the value of LENGTHOF for an array declared as ‘array1 WORD 30 DUP(?)’?

82
Q

What does the JMP instruction do?

A

Transfers control to a new location unconditionally.

The address is loaded into the instruction pointer (EIP) and execution continues at that address.

83
Q

What is the syntax for the JMP instruction?

A

JMP target

‘target’ is the label to which control is transferred.

84
Q

What is the purpose of the LOOP instruction?

A

Repeats a block of statements a specific number of times using ECX as a counter.

ECX is decremented each time the loop repeats.

85
Q

What is the syntax for the LOOP instruction?

A

LOOP target

‘target’ is the label to which control jumps if ECX is not zero.

86
Q

How does the LOOP instruction affect ECX?

A

ECX is decremented by 1 each time the loop executes.

If ECX reaches 0, the loop terminates.

87
Q

In the context of loops, what does ‘relative offset’ refer to?

A

The distance in bytes between the offset of the following instruction and the target label’s offset.

This offset is added to EIP for execution.

88
Q

What happens to the final value of EAX in the example of summing integers 5 + 4 + 3 + 2 + 1?

A

EAX = 15

This is the result of adding the integers in the loop.

89
Q

How many times will the inner loop execute in the nested loop example with ECX set to 20?

A

20 times

The outer loop executes 100 times while the inner loop executes 20 times for each outer loop iteration.

90
Q

What is the data type change needed when summing a doubleword array instead of a word array?

A

Change the data type to DWORD.

This ensures that the program correctly handles the size of the integers being summed.

91
Q

What is the MOV instruction used for in 64-bit programming?

A

Transfers data from a source to a destination.

The MOV instruction can handle 8, 16, 32, or 64-bit operands.

92
Q

What happens to the upper bits of a 64-bit register when a 32-bit value is moved into it?

A

The upper bits are cleared (set to zero).

For example, moving 0FFFFFFFFh into RAX results in 00000000FFFFFFFF.

93
Q

What does the MOVSXD instruction do?

A

Sign extends a 32-bit value into a 64-bit destination register.

This is useful for preserving the sign of the value when moving it to a larger register.

94
Q

What does the OFFSET operator generate?

A

A 64-bit address.

This address can be used to reference variables in memory.

95
Q

What registers does the LOOP instruction use in 64-bit mode?

A

The RCX register as a counter.

This is consistent with the behavior of the LOOP instruction in 32-bit mode.

96
Q

True or False: The ADD, SUB, INC, and DEC instructions affect CPU status flags differently in 64-bit mode compared to 32-bit mode.

A

False

They affect the CPU status flags in the same way in both modes.