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
Q

How many data registers are in the floating point unit (FPU)?

A

8

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

How much memory can protected-mode address?

A

4 GByte

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

How many general purpose registers are there in 64 bit architecture?

A

16

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

How many bits are the floating point unit registers in 64 bit architecture?

A

80

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

How many MMX registers are there in 64 bit architecture?

A

8

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

What are real number literals also known as?

A

Floating-point literals

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

What is an encoded real?

A

A real number in hexadecimal

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

How many characters can an identifier contain?

A

Between 1 and 247

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

What characters are allowed in an identifier?

A

first character must be letter, underscore, @, ?, $, subsequent characters can be digits.

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

All assemblers share the same directives. True or False?

A

False

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

Which are the two types of labels?

A

Data and code

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

In which segment must labels be followed by a colon?

A

code

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

What is a mnemonic?

A

a short word that identifies an instruction

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

How many operands does IMUL have?

A
  1. Two source operands and one destination. product ends up in eax register.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What does a linker do?

A

Produces an executable file from an object file

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

What is a listing file?

A

Contains source code, line numbers, address of each instruction, and symbol table

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

What is an operation code?

A

a number in hexadecimal representing address of machine code instruction

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

The linker extracts assembled procedures from the link library and inserts them in the executable program. True or False?

A

false?

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

what is a BYTE

A

8-bit unsigned integer. B stands for byte

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

what is a SBYTE

A

8-bit signed integer. S stands for signed

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

what is a WORD

A

16-bit unsigned integer

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

what is a SWORD

A

16-bit signed integer

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

what is a DWORD

A

32-bit unsigned integer. D stands for double

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

what is a SDWORD

A

32-bit signed integer. SD stands for signed double

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

what is a FWORD

A

48-bit integer. (Far pointer in protected mode)

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

what is a QWORD

A

64-bit integer. Q stands for quad

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

what is a TBYTE

A

80-bit (10-byte) integer. T stands for Ten-byte

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

what is a REAL4

A

32-bit (4-byte) IEEE short real, or single precision floating point

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

what is a REAL8

A

64-bit (8-byte) IEEE long real, or double precision floating point

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

what is a REAL10

A

80-bit (10-byte) IEEE extended real, or extended precision floating point

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

What is Ah in decimal?

A

10

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

What is Bh in decimal?

A

11

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

What is Ch in decimal?

A

12

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

What is Dh in decimal?

A

13

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

What is Eh in decimal?

A

14

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

What is Fh in decimal?

A

15

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

What is 1 in 4-bit binary?

A

0001

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

What is 2 in 4-bit binary?

A

0010

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

What is 3 in 4-bit binary?

A

0011

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

What is 4 in 4-bit binary?

A

0100

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

What is 5 in 4-bit binary?

A

0101

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

What is 6 in 4-bit binary?

A

0110

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

What is 7 in 4-bit binary?

A

0111

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

What is 8 in 4-bit binary?

A

1000

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

What is 9 in 4-bit binary?

A

1001

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

What is Ah in 4-bit binary?

A

1010

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

What is Bh in 4-bit binary?

A

1011

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

What is Ch in 4-bit binary?

A

1100

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

What is Dh in 4-bit binary?

A

1101

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

What is Eh in 4-bit binary?

A

1110

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

What is Fh in 4-bit binary?

A

1111

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

What is DB?

A

Legacy Directive, 8-bit integer

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

What is DW?

A

Legacy Directive, 16-bit integer

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

What is DD?

A

Legacy Directive, 32-bit integer or real

80
Q

What is DQ?

A

Legacy Directive, 64-bit integer or real

81
Q

What is DT?

A

Legacy Directive, define 80-bit (10-byte) integer

82
Q

All data definitions must have at least one initializer. True or False?

A

True

83
Q

All initializers are converted to binary format by the assembler. True or False?

A

True

84
Q

The DB directive can be signed or unsigned. True or False?

A

True

85
Q

What is CrLf

A

Carriage return line feed. Represents hexadecimal codes 0Dh and 0Ah

86
Q

What is the \ character?

A

line continuation. Concatenates two source code lines into a single statement. Must be on last character of the line.

87
Q

What is the DUP Operator?

A

allocates storage for multiple data items, using an integer expression as a counter.

88
Q

What does the following line do:

BYTE 20 DUP(?)

A

allocates 20 bytes of uninitialized

89
Q

What does the following line do:

BYTE 4 DUP(“STACK”)

A

Allocates 20 bytes - “STACKSTACKSTACKSTACK”

90
Q

What is the offset increment in the following line of code:

myList DWORD 1, 2, 3, 4, 5

A

4

91
Q

What is a BCD?

A

Binary coded decimal

92
Q

What number must the highest byte be equal to in hexadecimal in order to be negative?

A

80h

93
Q

What directive is used to declare a BCD?

A

TBYTE

94
Q

Why is the following line of code invalid:

intval TBYTE -1234

A

not in hexadecimal

95
Q

Which legacy directives define real numbers?

A

DD, DQ, DT

96
Q

What is little-endian representation of the doubleword 12345678h?

A

78, 56, 34, 12 with offsets of 1 byte increments

97
Q

What is “.DATA?” used for?

A

declaring uninitialized data

98
Q

The following block of code is valid:

.code
mov eax, ebx
.data
temp DWORD ?
.code
mov temp, eax

True or False?

A

TRUE. Intermixing of code and data is allowed but can be hard to read.

99
Q

Symbols reserve storage. True or False?

A

False. They are only used by the assembler when scanning a program and cannot change at runtime.

100
Q

What does the equal sign directive do?

A

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
Q

What is the $ symbol?

A

Current location counter. In the line:

selfPtr DWORD $

selfPtr is initialized with the offset value

102
Q

What do the following lines of code do:

list BYTE 10, 20, 30, 40
ListSize = ($ - list)

A

subtracts offset of “list” from current location counter.

ListSize must follow immediately after list.

103
Q

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

A

ListSize = ($ - list)/4

104
Q

What is the EQU directive and which are its formats?

A

Associates symbolic name with integer expression or arbitrary text.

The 3 formats are:
name EQU expression
name EQU symbol
name EQU

105
Q

Which are the three formats of TEXTEQU?

A

name TEXTEQU
name TEXTEQU textmacro
name TEXTEQU %constExpr ;constant integer expression

106
Q

Use TEXTEQU to assign the symbol SetupESI t the following line of code:

mov esi, OFFSET myArray

A

SetupESI TEXTEQU

107
Q

Declare a symbolic constant using the equal-sign directive that contains the ASCII code (08h) for the Backspace key

A

BACKSPACE = 08h

108
Q

Declare a symbolic constant named SecondsInDay

A

SecondsInDay = 246060

109
Q

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(?)

A

ArraySize WORD ($ - myArray)

110
Q

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(?)

A

ArraySize DWORD ($ - myArray)/ 4

111
Q

Use a TEXTEQU expression to redefine “proc” as “procedure”

A

procedure TEXTEQU #proc#

the # means the horizontal carrot

112
Q

Use TEXTEQU to create a symbol named Sample for a string constant, and then use the symbol when defining a string variable named MyString

A

Sample TEXTEQU

MyString BYTE Sample

113
Q

What instruction is also known as the data transfer instruction?

A

MOV

114
Q

What 3 rules must be observed when using MOV?

A
  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
Q

What is MOVZX?

A

Move with zero extend

116
Q

What is the result of the AX register after the following lines of code?

.data
byteVal BYTE 1000111b
.code
movzx ax, byteVal

A

AX = 0000000010001111b

117
Q

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?

A
EAX = 0000A69Bh
EDX = 0000009B
CX = 009Bh
118
Q

What is MOVSX?

A

Move with sign extend

119
Q

What is the LAHF?

A

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
Q

What is SAHF

A

stare AH into status flags. for retrieving values of flags saved earlier in a variable

121
Q

What is XCHG?

A

exchanges the contents of two operands. Variants are:

XCHG reg, reg
XCHG reg, mem
XCHG mem, reg

122
Q

XCHG accepts immediate operands. True or False?

A

False. Otherwise rules are the same as MOV

123
Q

What is the value of al after the following lines of code

arrayB BYTE 10h, 20h, 20h, 40h, 50h
mov al, arrayB

A

AL = 10h

124
Q

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 + ?]
A

2

125
Q

Which flags do the INC and DEC instructions affect?

A

Overflow, sign, zero, auxiliary carry and parity

126
Q

What is NEG?

A

reverses sign of a number by converting the number to its two’s complement.

127
Q

When is the carry flag set for subtraction operations?

A

When a larger unsigned integer is subtracted from a smaller one

128
Q

When is auxiliary carry flag set?

A

when a 1 bit carries out of position 3 in the least significant byte of the destination operand

129
Q

Applying NEG instruction to a nonzero operand always sets the Carry flag. True or False.

A

True

130
Q

When is the parity flag set?

A

When the least significant byte of the destination has an even number of bits.

131
Q

What is the largest possible integer of a signed byte?

A

+127

132
Q

In what two ways does overflow occur?

A
  • adding two positive operands generates a negative sum

- adding two negative operands generates a positive sum

133
Q

What is unconditional transfer?

A

control is transferred to a new location in all cases. for example JMP

134
Q

What is conditional transfer?

A

program branches if a certain condition is true. CPU interprets true/false conditions based on the contents of the ECX and Flags registers

135
Q

What is JMP instruction?

A

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
Q

How does LOOP instruction work?

A

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
Q

What is JC?

A

jump if carry flag is set

138
Q

What is JNC?

A

Jump if carry flag is clear

139
Q

What is JZ?

A

Jum if zero flag is set?

140
Q

What do the following lines of code do?

cmp eax, 5
je L1

A

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
Q

What happens in the following?

mov ax, 5
cmp ax, 6
jl L1

A

jumps to L1 because AX is less than 6. (jl = jump if less)

142
Q

What happens in the following?
mov ax, 5
cmp ax, 4
jg L1

A

Jump is taken because AX is greater than 4

143
Q

What is JCXV and JECXZ?

A

Jum if ECX = 0 or CX = 0

144
Q

What register is used to manage the runtime stack?

A

ESP

145
Q

RUNTIME STACK GROWS DOWNWARD IN MEMORY, FROM HIGHER ADDRESSES TO LOWER ADDRESSES. TRUE OR FALSE

A

tRUE

146
Q

What is a pop operation?

A

removes value from the stack

147
Q

What is a runtime stack?

A

Memory array managed directly by the cpu

148
Q

Name four instructions that modify the stack

A

CALL, RET, PUSH, POP

149
Q

ESP always points to the last value added to the stack. True or False?

A

True

150
Q

What does push operation do?

A

decrements stack pointer by 4 and copies a value into the location in th`e stack pointed to by the stack pointer

151
Q

Name four important applications of the stack.

A
  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
Q

What are the instruction formats of PUSH?

A

PUSH reg/mem16
PUSH reg/mem32
PUSH imm32

153
Q

How does the POP instruction work?

A

first copies contents of the stack element pointed to by ESP into destination, then increments ESP

154
Q

What are the instruction formats of POP?

A

POP reg/mem16

POP reg/mem32

155
Q

The MOV instruction can be used to copy flags to a variable. True or False?

A

False, use PUSHFD

156
Q

What is PUSHAD?

A

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
Q

What is PUSHA?

A

pushes the 16-bit general purpose registers on the stack.

158
Q

6.2 What is TEST

A

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
Q

6.2 Which flags do the boolean instructions affect?

A

Zero, Carry, Sign, Overflow, & Parity

160
Q

6.2 What are the forms of the AND instruction?

A
AND reg, reg
AND reg, mem
AND reg, imm
AND mem, reg
AND mem, imm
161
Q

6.2 What is masking?

A

letting you clear 1 or more bits in an operand without affecting other bits

162
Q

6.2 What is the result in AL after this operation (spaces added only for readability):

mov al, 1010 1110b
and al, 1111 0110b

A

AL = 1010 0110

163
Q

6.2 The AND instruction always clears the Overflow and Carry flags. True or False?

A

True.

164
Q

6.2 What bit position for the ASCII codes for alphabetic characters differ in lowercase and uppercase?

A

5

165
Q

6.2 the OR instruction uses the same operand combinations as the AND instruction. True or false?

A

True.

However, the operands can be 8, 16, 32, or 64 bits and must be the same size.

166
Q

6.2 If the value in AL is greater than zero what are the values of the Zero and Sign Flags?

A

Zero = clear; Sign = clear

167
Q

6.2 If the value in AL is equal to zero what are the values of the Zero and Sign Flags?

A

Zero = set; Sign = clear

168
Q

6.2 If the value in AL is less than zero what are the values of the Zero and Sign Flags?

A

Zero = clear; Sign = set

169
Q

6.2 How do you check the parity of a number without changing its value?

A

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
Q

6.2 What is the abbreviation for parity flag is Visual Studio?

A

PE

1 if even, 0 if odd

171
Q

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.

A

mov ax, 64C1h ;//0110 0100 1100 0001

xor ah, al ;//Parity flag set (even)

172
Q

6.2 What is the NOT instruction?

A

toggles (inverts) all bits in an operand

173
Q

6.2 Write code that will test bits 0 and 3 in the AL register

A

test al, 0000 1001b

174
Q

What’s the value of the Zero and Carry flags after this operation:

mov ax, 5
cmp ax, 10

A

ZF = 0 & CF = 1

175
Q

6.2 What is one way to set or clear the Zero flag?

A

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
Q

6.2 What is one way to set or clear the Sign flag?

A

or al, 80h ;// set Sign flag

and al, 7Fh ;//clear Sign flag

177
Q

6.2 What is one way to set or clear the Carryflag?

A

use STC instruction to set; to clear use CLC:

stc
clc

178
Q

6.2 What is one way to set or clear the Overflow flag?

A

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
Q

5.2 How do you create a global label?

A

double colon ::

180
Q

5.2 How does the CALL instruction work?

A

pushes its return address on the stack and copies the called procedure’s address into the instruction pointer.

181
Q

4.3 Operators and directives are executable instructions. True or False?

A

False. they are interpreted by the assembler

182
Q

4.3 What is the OFFSET operator?

A

returns the distance of a variable from the beginning of its enclosing segment

i.e. returns the offset of a data label

183
Q

4.3 What is the PTR operator?

A

lets you override an operand’s default size

184
Q

4.3 What is the LENGTHOF operator?

A

returns the number of elements in an array

185
Q

4.3 What is the SIZEOF operator?

A

returns the number of bytes used by an array initializer

it is equivalent to multiplying LENGTHOF by TYPE

186
Q

4.3 why bother aligning data?

A

because the CPU can process data stored at even-numbered addresses more quickly than those at odd-numbered addresses

187
Q

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 ?
A
wVal = 0040 4002h
dVal = 0040 4008h
188
Q

4.3 What is the point of PTR?

A

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
Q

4.3 What happens in the following line, if myDouble = 123456789h:

mov ax, WORD PTR myDouble

A

5678h is moved to AX

because little endian

190
Q

4.3 What do the following lines of code do:

.data
wordList WORD 5678h, 1234h
.code
mov eax, DWORD PTR wordList

A

first word is co.pied to the lower half of EAX and the second word is copied to the upper half. EAX = 123456789h

191
Q

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]
A
AX = 5678h
DX = 1234h

val16 is an alias for the same storage location as val32

192
Q

In Protected Mode, which registers can act as indirect operands?

A

Any 32-bit general-purpose register (EAX, EBX, ECX, EDX, ESI, EDI, EBP, & ESP)

193
Q

How do you fix the following line of code:

inc [esi]

A

inc BYTE PTR [esi]

the assembler does not know whether ESI points to a byte, word, doubleword, or some other size

194
Q

What is a stack frame?

A

AKA activation record, the area of the stack set aside for passed arguments, subroutine return address, local variables, and saved registers

195
Q

Pass the following by reference and then call a subroutine named “swap”

val1, val2

A

push OFFSET val2
push OFFSET val1
call swap