Midterm Exam Flashcards
Get me prepared for midterm exam covering Chapter 1 to 4
What is an assembler?
A utility program that converts assembly language source code programs into machine language.
What does a linker do?
A utility program that combines individual files created by an assembler into a single executable program.
What is the function of a debugger?
Lets you trace the execution of a program and examine contents of registers and memory.
How does assembly language relate to machine language?
Assembly language consists of statements written with short mnemonics, and has a one-to-one relationship with machine language.
What is the native machine language of a computer referred to as?
Language L0.
What is Language L1?
A more human-friendly language constructed above machine language.
What are the two ways programs written in L1 can run?
- Interpretation
- Translation
What is a virtual machine?
An abstraction that allows programs written in higher-level languages to run on different hardware.
What does the term ‘MSB’ stand for?
Most Significant Bit.
What does ‘LSB’ stand for?
Least Significant Bit.
What is binary addition?
The process of adding binary digits, where the outcomes include carrying over when both bits are 1.
What is the hexadecimal system?
A base-16 number system where each digit corresponds to 4 binary bits.
How are signed integers represented in binary?
Using two’s complement notation.
What is the Boolean NOT operation?
Inverts (reverses) a boolean value.
What is the truth table for the AND operator?
The output is true only when both inputs are true.
What does the OR operator do?
The output is false only when both inputs are false.
What is a truth table?
A table that shows all the inputs and outputs of a Boolean function.
What are the main components of a CPU?
- Registers
- High-frequency clock
- Control unit
- Arithmetic logic unit (ALU)
What is the instruction execution cycle?
- Fetch
- Decode
- Fetch operands
- Execute
- Store output
What is a cache hit?
When data to be read is already in cache memory.
What is a cache miss?
When data to be read is not in cache memory.
What is an operand?
A value that is either an input or an output to an operation.
What is the purpose of general-purpose registers?
To hold values used in operations and to optimize speed.
What does the EIP register do?
Contains the address of the next instruction to be executed.
What are status flags?
Flags that reflect the outcomes of arithmetic and logic operations performed by the CPU.
What does the MOV instruction do?
Moves (assigns) one value to another.
What is a label in assembly language?
Acts as a place marker for code and data, marking the address of the instruction.
What are directives in assembly language?
Commands recognized by the assembler, used to declare code, data areas, and select memory models.
What is an integer constant?
A numerical value that can be represented in binary, decimal, hexadecimal, or octal.
What is a character constant?
A single character enclosed in single or double quotes.
How is an identifier defined in assembly language?
A programmer-chosen name to identify a variable, constant, procedure, or code label.
What is the difference between directives and instructions?
Directives are not executed at runtime, while instructions are.
What is the template for an assembly language program?
- .386
- .model flat,stdcall
- .stack 4096
- .data
- .code
- main PROC
- INVOKE ExitProcess,0
- main ENDP
- END main
What is the purpose of a data definition statement?
Sets aside storage in memory for a variable and optionally assigns a name.
Define BYTE and SBYTE data types.
- BYTE: 8-bit unsigned integer
- SBYTE: 8-bit signed integer
What is the syntax for a data definition statement?
[name] directive initializer [, initializer] …
Provide an example of defining a DWORD variable.
count DWORD 12345
True or False: MASM prevents initializing a BYTE with a negative value.
False
List the largest and smallest values for SBYTE.
- Largest: +127
- Smallest: -128
What does the DUP operator do?
Allocates space for an array or string.
Fill in the blank: A string is implemented as an array of _____ and is often null-terminated.
[characters]
What is the purpose of the .data directive?
To declare an uninitialized data segment.
What is the result of the instruction ‘mov eax, val1’ if val1 is 10000h?
EAX = 10000h
Explain the MOV instruction in assembly language.
Copies data from a source operand to a destination operand.
What are the three basic types of operands in assembly language?
- Immediate
- Register
- Memory
What is the syntax for the MOV instruction?
MOV destination, source
Fill in the blank: The instruction pointer register (IP, EIP, or RIP) cannot be a _____ operand.
[destination]
What does the MOVZX instruction do?
Zero-extends a smaller value into a larger destination.
What does the MOVSX instruction do?
Sign-extends a smaller value into a larger destination.
What is the purpose of the XCHG instruction?
Exchanges the values of two operands.
True or False: Two memory operands are permitted in the XCHG instruction.
False
Define the OFFSET operator.
Returns the distance of a variable from the beginning of its enclosing segment.
What does the TYPE operator return?
The size, in bytes, of a single element of a data declaration.
List the sizes returned by the TYPE operator for BYTE, WORD, DWORD, and QWORD.
- BYTE: 1
- WORD: 2
- DWORD: 4
- QWORD: 8
What happens when you apply the NEG instruction to a value?
Reverses the sign of an operand.
What is the syntax for adding two values in assembly language?
ADD destination, source
What is the syntax for subtracting two values in assembly language?
SUB destination, source
Fill in the blank: The _____ operator can be applied to a direct-offset operand.
[OFFSET]
What does the LENGTHOF operator do?
Returns the number of elements in an array.
What is the purpose of the SIZEOF operator?
Returns the size, in bytes, of a given data type.
What is the result of the instruction ‘mov ax, [arrayW + 2]’?
AX = 20h
True or False: The MOV instruction can have more than two operands.
False
What is a null-terminated string?
A string that ends with a null character (0).
What is the significance of the .code directive?
Indicates the start of the code segment.
What does the INVOKE statement do?
Calls a procedure.
Fill in the blank: The instruction ‘sub eax, 1’ will result in _____ being stored in EAX.
[EAX - 1]
What does the TYPE operator return?
The size, in bytes, of a single element of a data declaration.
The TYPE of a byte equals 1, the TYPE of a word equals 2, the TYPE of a doubleword is 4, and the TYPE of a quadword is 8.
What is the TYPE of a byte?
1
What is the TYPE of a word?
2
What is the TYPE of a doubleword?
4
What is the TYPE of a quadword?
8
What does the LENGTHOF operator count?
The number of elements in a single data declaration.
Examples include counting elements in arrays or strings.
What is the LENGTHOF of byte1 which is declared as BYTE 10,20,30?
3
What is the LENGTHOF of array1 declared as WORD 30 DUP(?),0,0?
32
What is the LENGTHOF of array2 declared as WORD 5 DUP(3 DUP(?))?
15
What is the LENGTHOF of array3 declared as DWORD 1,2,3,4?
4
What is the LENGTHOF of digitStr declared as BYTE ‘12345678’,0?
9
What does the SIZEOF operator return?
A value that is equivalent to multiplying LENGTHOF by TYPE.
What is the formula for SIZEOF?
SIZEOF = LENGTHOF * TYPE
What is the SIZEOF of array1?
64
What is meant by a one-to-many relationship when comparing a high-level language to machine language?
Each high-level language statement matches multiple machine language statements.
Name two types of applications that would be better suited to assembly language than a high-level language.
Device drivers and high performance graphics
Name the four virtual machine levels named in this section, from lowest to highest.
digital logic, instruction set architecture, assembly language, high-level language
Which of the following is the decimal representation of the unsigned binary integer 11111000?
248
What is the value of the boolean expression ¬(F ∨ T) ?
False
In the expression ¬Y ∧ Z, the NOT operation executes after the AND operation.
False
How many bits are used by doubleword data type?
32-bits
The central processor unit is connected to the rest of the computer system using what three buses?
Data, Address, and Control buses
What are the three basic steps in the instruction execution cycle?
Fetch instruction, decode the instruction, execute the instruction
In addition to EAX, EBX, ECX, and EDX, what are the names of the other 32-bit general-purpose registers?
ESI, EDI, ESP, EBP
Which of the following choices lists names of CPU status flags?
Sign, Zero, Carry, Overflow, Parity
Which of the following is not a reserved word in Assembly programming?
Directives
Instruction mnemonics
Attributes
Operators
What are the minimum numbers of binary bits needed to represent the unsigned decimal integers 37 and 294?
37 requires 6 bits and 294 requires 7 bits
What are the x86 processor’s three basic modes of operation?
System Management mode, Real-address mode, and Protected mode
The EIP, or instruction pointer register contains the address of the last instruction executed.
False
Which of the following lists the three basic types of operands?
register, immediate, memory
In a MOV instruction, the second operand is known as the destination operand.
False
The EIP register cannot be the destination operand of a MOV instruction.
True
An operand notated as reg/mem32 indicates that it must be either a register of any size, or a 32-bit memory operand.
False
The XCHG instruction can exchange the values of two memory operands.
False
The SAHF instruction copies the contents of the AH register into the low-order byte of the EFLAGS (or RFLAGS) register.
True
The following instruction sequence subtracts val4 from val2.
.data
val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 WORD 7FFFh
.code
mov ax,val4
sub val2,ax
True
If val3 is incremented by 1 using the ADD instruction, CF = 1, and ZF = 0.
False
The OFFSET operator always returns a 16-bit value.
False
The TYPE operator returns a value of 4 for doubleword operands.
True
Which of the following operators returns the number of bytes in an operand?
SIZEOF
The following code will move the value 3 to EAX:
.data
array DWORD 1,2,3,4
.code
mov esi, 8
mov eax, array[esi]
True
The following instruction is valid:
add WORD PTR[esi+2], 20
True
The following code will move the value 2 to EAX:
.data
array DWORD 1,2,3,4
.code
mov esi,0
mov eax, array[esi*2]
False
True or False?
The LOOP instruction first checks to see whether ECX is not equal to zero. Next, LOOP decrements ECX and jumps to the destination label.
False