Assembly Flashcards

1
Q

What does the Central Processing

Unit (CPU) contain?

A

registers, clock, control unit and arithmetic logic unit

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

What does the control unit (CU) do?

A

coordinates the sequencing of steps involved in executing machine instruction

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

What is the memory storage unit?

A

where instructions and data are held while a computer program is running

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

What is a bus?

A

a group of parallel wires that transfer data from one part of the computer to another

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

What are the four bus types?

A

data, I/O, control, address

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

What does the control bus do?

A

uses binary signals to synchronize actions of all devices attached to the system bus

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

What does the address bus do?

A

holds the addresses of instructions and data when the currently executing instruction transfers data between the CPU and memory

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

How many oscillations per second is a 1 GHz?

A

a billion

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

What is a wait state?

A

empty clock cycles due to the differences in speeds of the CPU, the system bus, and memory circuit

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

What is a program loader?

A

utility to load program into memory so it can run

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

What is an entry point?

A

address at which the program is to begin execution, declared by the .CODE segment

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

How huch memory can real-address mode programns address?

A

1 MByte

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

How many segment registers are there?

A

6

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

What are the general purpose registers?

A

EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP

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

What is EAX for?

A

multiplication and division. also called the extended accumulator register

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

What is ECX for?

A

loop counter

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

What is ESP for?

A

addressing data on the stack. Also called the Extended Stack Pointer

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

What are ESI and EDI for?

A

high-speed memory transfer instructions. Also called Extended Source Index and Extended Destination Index

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

What is EBP for?

A

used by high-level languages to reference function parameters and local variables on the stack. Also called the Extended Frame Pointer

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

Which are the status flags?

A

Carry, overflow, sign, zero, auxiliary carry, parity

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

When is the carry flag set?

A

when result of unsigned arithmetic operation is too large to fit in destination

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

When is overflow flag set?

A

when result of signed arithmetic operation is too large to fit in destination

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

When is sign flag set?

A

when result of arithmetic or logic operation generates negative

AKA a copy of the high bit of the destination operand, indicating that it is negative if set and positive if clear (Zero is assumed to be positive)

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

When is parity flag set?

A

when the least signficant byte contains an even number of 1s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How many data registers are in the floating point unit (FPU)?
8
26
How much memory can protected-mode address?
4 GByte
27
How many general purpose registers are there in 64 bit architecture?
16
28
How many bits are the floating point unit registers in 64 bit architecture?
80
29
How many MMX registers are there in 64 bit architecture?
8
30
What are real number literals also known as?
Floating-point literals
31
What is an encoded real?
A real number in hexadecimal
32
How many characters can an identifier contain?
Between 1 and 247
33
What characters are allowed in an identifier?
first character must be letter, underscore, @, ?, $, subsequent characters can be digits.
34
All assemblers share the same directives. True or False?
False
35
Which are the two types of labels?
Data and code
36
In which segment must labels be followed by a colon?
code
37
What is a mnemonic?
a short word that identifies an instruction
38
What is an operand?
A value that is used for input or output for an instruction
39
How many operands does IMUL have?
3. Two source operands and one destination. product ends up in eax register.
40
What does a linker do?
Produces an executable file from an object file
41
What is a listing file?
Contains source code, line numbers, address of each instruction, and symbol table
42
What is an operation code?
a number in hexadecimal representing address of machine code instruction
43
The linker extracts assembled procedures from the link library and inserts them in the executable program. True or False?
false?
44
what is a BYTE
8-bit unsigned integer. B stands for byte
45
what is a SBYTE
8-bit signed integer. S stands for signed
46
what is a WORD
16-bit unsigned integer
47
what is a SWORD
16-bit signed integer
48
what is a DWORD
32-bit unsigned integer. D stands for double
49
what is a SDWORD
32-bit signed integer. SD stands for signed double
50
what is a FWORD
48-bit integer. (Far pointer in protected mode)
51
what is a QWORD
64-bit integer. Q stands for quad
52
what is a TBYTE
80-bit (10-byte) integer. T stands for Ten-byte
53
what is a REAL4
32-bit (4-byte) IEEE short real, or single precision floating point
54
what is a REAL8
64-bit (8-byte) IEEE long real, or double precision floating point
55
what is a REAL10
80-bit (10-byte) IEEE extended real, or extended precision floating point
56
What is Ah in decimal?
10
57
What is Bh in decimal?
11
58
What is Ch in decimal?
12
59
What is Dh in decimal?
13
60
What is Eh in decimal?
14
61
What is Fh in decimal?
15
62
What is 1 in 4-bit binary?
0001
63
What is 2 in 4-bit binary?
0010
64
What is 3 in 4-bit binary?
0011
65
What is 4 in 4-bit binary?
0100
66
What is 5 in 4-bit binary?
0101
67
What is 6 in 4-bit binary?
0110
68
What is 7 in 4-bit binary?
0111
69
What is 8 in 4-bit binary?
1000
70
What is 9 in 4-bit binary?
1001
71
What is Ah in 4-bit binary?
1010
72
What is Bh in 4-bit binary?
1011
73
What is Ch in 4-bit binary?
1100
74
What is Dh in 4-bit binary?
1101
75
What is Eh in 4-bit binary?
1110
76
What is Fh in 4-bit binary?
1111
77
What is DB?
Legacy Directive, 8-bit integer
78
What is DW?
Legacy Directive, 16-bit integer
79
What is DD?
Legacy Directive, 32-bit integer or real
80
What is DQ?
Legacy Directive, 64-bit integer or real
81
What is DT?
Legacy Directive, define 80-bit (10-byte) integer
82
All data definitions must have at least one initializer. True or False?
True
83
All initializers are converted to binary format by the assembler. True or False?
True
84
The DB directive can be signed or unsigned. True or False?
True
85
What is CrLf
Carriage return line feed. Represents hexadecimal codes 0Dh and 0Ah
86
What is the \ character?
line continuation. Concatenates two source code lines into a single statement. Must be on last character of the line.
87
What is the DUP Operator?
allocates storage for multiple data items, using an integer expression as a counter.
88
What does the following line do: BYTE 20 DUP(?)
allocates 20 bytes of uninitialized
89
What does the following line do: BYTE 4 DUP("STACK")
Allocates 20 bytes - "STACKSTACKSTACKSTACK"
90
What is the offset increment in the following line of code: myList DWORD 1, 2, 3, 4, 5
4
91
What is a BCD?
Binary coded decimal
92
What number must the highest byte be equal to in hexadecimal in order to be negative?
80h
93
What directive is used to declare a BCD?
TBYTE
94
Why is the following line of code invalid: intval TBYTE -1234
not in hexadecimal
95
Which legacy directives define real numbers?
DD, DQ, DT
96
What is little-endian representation of the doubleword 12345678h?
78, 56, 34, 12 with offsets of 1 byte increments
97
What is ".DATA?" used for?
declaring uninitialized data
98
The following block of code is valid: ``` .code mov eax, ebx .data temp DWORD ? .code mov temp, eax ``` True or False?
TRUE. Intermixing of code and data is allowed but can be hard to read.
99
Symbols reserve storage. True or False?
False. They are only used by the assembler when scanning a program and cannot change at runtime.
100
What does the equal sign directive do?
associates a symbol name with an integer expression. Ordinarily 32 bits. Syntax is: name = expression When program is assembled, all occurrences of "name" is replaced by "expression" during preprocessor step
101
What is the $ symbol?
Current location counter. In the line: selfPtr DWORD $ selfPtr is initialized with the offset value
102
What do the following lines of code do: list BYTE 10, 20, 30, 40 ListSize = ($ - list)
subtracts offset of "list" from current location counter. ListSize must follow immediately after list.
103
How would you write code to calculate the number of elements in the array list given the following line: list DWORD 1h, 2h, 3h, 4h
ListSize = ($ - list)/4
104
What is the EQU directive and which are its formats?
Associates symbolic name with integer expression or arbitrary text. The 3 formats are: name EQU expression name EQU symbol name EQU
105
Which are the three formats of TEXTEQU?
name TEXTEQU name TEXTEQU textmacro name TEXTEQU %constExpr ;constant integer expression
106
Use TEXTEQU to assign the symbol SetupESI t the following line of code: mov esi, OFFSET myArray
SetupESI TEXTEQU
107
Declare a symbolic constant using the equal-sign directive that contains the ASCII code (08h) for the Backspace key
BACKSPACE = 08h
108
Declare a symbolic constant named SecondsInDay
SecondsInDay = 24*60*60
109
Write a statement that causes the assembler to calculate the number of bytes in the following array, and assign the value to a symbolic constant named ArraySize: myArray WORD 20 DUP(?)
ArraySize WORD ($ - myArray)
110
Show how to calculate the number of elements in the following array, and assign the value to a symbolic constant named ArraySize: myArray DWORD 30 DUP(?)
ArraySize DWORD ($ - myArray)/ 4
111
Use a TEXTEQU expression to redefine "proc" as "procedure"
procedure TEXTEQU #proc# the # means the horizontal carrot
112
Use TEXTEQU to create a symbol named Sample for a string constant, and then use the symbol when defining a string variable named MyString
Sample TEXTEQU | MyString BYTE Sample
113
What instruction is also known as the data transfer instruction?
MOV
114
What 3 rules must be observed when using MOV?
1. Both operands must be the same size 2. Both operands cannot be memory operands 3. The instruction pointer register cannot be a destination operand (IP, EIP, RIP)
115
What is MOVZX?
Move with zero extend
116
What is the result of the AX register after the following lines of code? .data byteVal BYTE 1000111b .code movzx ax, byteVal
AX = 0000000010001111b
117
For the following lines of code: mov bx, 0A69Bh movzx eax, bx movzx edx, bl movzx cx, bl what is the value of EAX, EDX and CX?
``` EAX = 0000A69Bh EDX = 0000009B CX = 009Bh ```
118
What is MOVSX?
Move with sign extend
119
What is the LAHF?
Load status flags into AH. copies the low byte of the EFLAGS register into AH. Using this instruction, you can easily save a copy of the flags in a variable for safekeeping
120
What is SAHF
stare AH into status flags. for retrieving values of flags saved earlier in a variable
121
What is XCHG?
exchanges the contents of two operands. Variants are: XCHG reg, reg XCHG reg, mem XCHG mem, reg
122
XCHG accepts immediate operands. True or False?
False. Otherwise rules are the same as MOV
123
What is the value of al after the following lines of code arrayB BYTE 10h, 20h, 20h, 40h, 50h mov al, arrayB
AL = 10h
124
What is the offset used to access the second element in the array below? ``` .data arrayW WORD 100h, 200h, 300h .code mov ax, arrayW mov ax, [arrayW + ?] ```
2
125
Which flags do the INC and DEC instructions affect?
Overflow, sign, zero, auxiliary carry and parity
126
What is NEG?
reverses sign of a number by converting the number to its two's complement.
127
When is the carry flag set for subtraction operations?
When a larger unsigned integer is subtracted from a smaller one
128
When is auxiliary carry flag set?
when a 1 bit carries out of position 3 in the least significant byte of the destination operand
129
Applying NEG instruction to a nonzero operand always sets the Carry flag. True or False.
True
130
When is the parity flag set?
When the least significant byte of the destination has an even number of bits.
131
What is the largest possible integer of a signed byte?
+127
132
In what two ways does overflow occur?
- adding two positive operands generates a negative sum | - adding two negative operands generates a positive sum
133
What is unconditional transfer?
control is transferred to a new location in all cases. for example JMP
134
What is conditional transfer?
program branches if a certain condition is true. CPU interprets true/false conditions based on the contents of the ECX and Flags registers
135
What is JMP instruction?
causes unconditional transfer to a destination, identified by a code label that is translated by the assembler into an offset. Syntax is: JMP destination
136
How does LOOP instruction work?
subtracts 1 from ECX, then compares ECX to zero. If ECX does not equal zero, a jump is taken to the label identified by destination. Otherwise, if ECX equals zero, no jump takes place and control passes to the instruction following the loop.
137
What is JC?
jump if carry flag is set
138
What is JNC?
Jump if carry flag is clear
139
What is JZ?
Jum if zero flag is set?
140
What do the following lines of code do? cmp eax, 5 je L1
jumps to L1 when EAX equals 5. If EAX equals 5, the CMP instruction sets the zero flag. JE instruction always jumps based on the value of the Zero flag.
141
What happens in the following? mov ax, 5 cmp ax, 6 jl L1
jumps to L1 because AX is less than 6. (jl = jump if less)
142
What happens in the following? mov ax, 5 cmp ax, 4 jg L1
Jump is taken because AX is greater than 4
143
What is JCXV and JECXZ?
Jum if ECX = 0 or CX = 0
144
What register is used to manage the runtime stack?
ESP
145
RUNTIME STACK GROWS DOWNWARD IN MEMORY, FROM HIGHER ADDRESSES TO LOWER ADDRESSES. TRUE OR FALSE
tRUE
146
What is a pop operation?
removes value from the stack
147
What is a runtime stack?
Memory array managed directly by the cpu
148
Name four instructions that modify the stack
CALL, RET, PUSH, POP
149
ESP always points to the last value added to the stack. True or False?
True
150
What does push operation do?
decrements stack pointer by 4 and copies a value into the location in th`e stack pointed to by the stack pointer
151
Name four important applications of the stack.
1. temporary save area for registers; 2. save current subroutine's return address when a call instruction is executed; 3. when calling a subroutine, pass input values by pushing them onto the stack; 4. provides temporary storage for local variables inside subroutines
152
What are the instruction formats of PUSH?
PUSH reg/mem16 PUSH reg/mem32 PUSH imm32
153
How does the POP instruction work?
first copies contents of the stack element pointed to by ESP into destination, then increments ESP
154
What are the instruction formats of POP?
POP reg/mem16 | POP reg/mem32
155
The MOV instruction can be used to copy flags to a variable. True or False?
False, use PUSHFD
156
What is PUSHAD?
Pushes all the 32-bit general purpose registers on the stack in the following order: EAX, ECX, EDX, EBX, ESP, EBP, ESI & EDI ESP value is before executing PUSHAD
157
What is PUSHA?
pushes the 16-bit general purpose registers on the stack.
158
6.2 What is TEST
Implied boolean AND operation between a source and destination operand, setting the CPU flags appropriately Difference between TEST & AND is that TEST does not modify the destination operand TEST is particularly valuable for finding out whether individual bits in an operand are set.
159
6.2 Which flags do the boolean instructions affect?
Zero, Carry, Sign, Overflow, & Parity
160
6.2 What are the forms of the AND instruction?
``` AND reg, reg AND reg, mem AND reg, imm AND mem, reg AND mem, imm ```
161
6.2 What is masking?
letting you clear 1 or more bits in an operand without affecting other bits
162
6.2 What is the result in AL after this operation (spaces added only for readability): mov al, 1010 1110b and al, 1111 0110b
AL = 1010 0110
163
6.2 The AND instruction always clears the Overflow and Carry flags. True or False?
True.
164
6.2 What bit position for the ASCII codes for alphabetic characters differ in lowercase and uppercase?
5
165
6.2 the OR instruction uses the same operand combinations as the AND instruction. True or false?
True. However, the operands can be 8, 16, 32, or 64 bits and must be the same size.
166
6.2 If the value in AL is greater than zero what are the values of the Zero and Sign Flags?
Zero = clear; Sign = clear
167
6.2 If the value in AL is equal to zero what are the values of the Zero and Sign Flags?
Zero = set; Sign = clear
168
6.2 If the value in AL is less than zero what are the values of the Zero and Sign Flags?
Zero = clear; Sign = set
169
6.2 How do you check the parity of a number without changing its value?
exclusive-OR the number with zero: mov al, 1011 0101b ;//5 bits = odd parity xor al, 0 ;//Parity flag clear (odd) mov al, 1100 1100b ;//4 bits = even parity xor al, 0 ;//Parity flag set (even)
170
6.2 What is the abbreviation for parity flag is Visual Studio?
PE 1 if even, 0 if odd
171
6.2 Write code that will check the parity of a 16-bit integer by performing an exclusive-OR between the upper and lower-bytes.
mov ax, 64C1h ;//0110 0100 1100 0001 | xor ah, al ;//Parity flag set (even)
172
6.2 What is the NOT instruction?
toggles (inverts) all bits in an operand
173
6.2 Write code that will test bits 0 and 3 in the AL register
test al, 0000 1001b
174
What's the value of the Zero and Carry flags after this operation: mov ax, 5 cmp ax, 10
ZF = 0 & CF = 1
175
6.2 What is one way to set or clear the Zero flag?
TEST or AND an operand with Zero to set. To clear, OR an operand with 1 test al, 0 ;//set Zero flag and al, 0 ;// set Zero flag or al, 1 ;// clear Zero flag
176
6.2 What is one way to set or clear the Sign flag?
or al, 80h ;// set Sign flag | and al, 7Fh ;//clear Sign flag
177
6.2 What is one way to set or clear the Carryflag?
use STC instruction to set; to clear use CLC: stc clc
178
6.2 What is one way to set or clear the Overflow flag?
add two positive values that produce a negative sum. To clear, OR an operand with 0: mov al, 7Fh ;//AL = +127 inc al ;// AL = 80h (-128), OF = 1 or eax, 0 ;// clear Overflow flag
179
5.2 How do you create a global label?
double colon ::
180
5.2 How does the CALL instruction work?
pushes its return address on the stack and copies the called procedure's address into the instruction pointer.
181
4.3 Operators and directives are executable instructions. True or False?
False. they are interpreted by the assembler
182
4.3 What is the OFFSET operator?
returns the distance of a variable from the beginning of its enclosing segment i.e. returns the offset of a data label
183
4.3 What is the PTR operator?
lets you override an operand's default size
184
4.3 What is the LENGTHOF operator?
returns the number of elements in an array
185
4.3 What is the SIZEOF operator?
returns the number of bytes used by an array initializer it is equivalent to multiplying LENGTHOF by TYPE
186
4.3 why bother aligning data?
because the CPU can process data stored at even-numbered addresses more quickly than those at odd-numbered addresses
187
4.3 In the following lines of code bVal is located at offset 0040 4000h. What are the locations of wVal and dVal? ``` bVal BYTE ? ALIGN 2 wVal WORD ? bVal BYTE ? ALIGN 4 dVal DWORD ? dVal2 DWORD ? ```
``` wVal = 0040 4002h dVal = 0040 4008h ```
188
4.3 What is the point of PTR?
it's necessary when you're trying to access the operand using a size attribute that is different from the one assumed by the assembler
189
4.3 What happens in the following line, if myDouble = 123456789h: mov ax, WORD PTR myDouble
5678h is moved to AX because little endian
190
4.3 What do the following lines of code do: .data wordList WORD 5678h, 1234h .code mov eax, DWORD PTR wordList
first word is co.pied to the lower half of EAX and the second word is copied to the upper half. EAX = 123456789h
191
What is the value of AX and DX after the following: ``` .data val16 LABEL WORD val32 DWORD 12345678h .code mov ax, val16 mov dx, [val16 + 2] ```
``` AX = 5678h DX = 1234h ``` val16 is an alias for the same storage location as val32
192
In Protected Mode, which registers can act as indirect operands?
Any 32-bit general-purpose register (EAX, EBX, ECX, EDX, ESI, EDI, EBP, & ESP)
193
How do you fix the following line of code: inc [esi]
inc BYTE PTR [esi] the assembler does not know whether ESI points to a byte, word, doubleword, or some other size
194
What is a stack frame?
AKA activation record, the area of the stack set aside for passed arguments, subroutine return address, local variables, and saved registers
195
Pass the following by reference and then call a subroutine named "swap" val1, val2
push OFFSET val2 push OFFSET val1 call swap