Chapter 5 - Procedures Flashcards

(69 cards)

1
Q

What are procedures also known as?

A

Subroutines and functions.

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

What is the structure of a stack?

A

LIFO (Last In, First Out).

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

Which registers manage the runtime stack?

A

SS (stack segment) and ESP (stack pointer).

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

What does the ESP register hold in 32-bit mode?

A

A 32-bit address in the stack.

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

What happens during a 32-bit push operation?

A

ESP is decremented by 4 and a value is copied into the location pointed by ESP.

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

What does a pop operation do?

A

Returns a copy of the value in the stack and increments the stack pointer.

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

What is the syntax for a 32-bit PUSH operation?

A

PUSH r/m32 or PUSH imm32.

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

What is the effect of a 16-bit operand in PUSH operation?

A

ESP is decremented by 2.

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

What is the purpose of the PUSHFD instruction?

A

To push the 32-bit EFLAGS register on the stack.

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

What is the structure of a procedure declaration in assembly?

A

PROC and ENDP directives with a name.

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

What does the CALL instruction do?

A

Pushes the return address on the stack and copies the called procedure’s address into EIP.

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

What does the RET instruction do?

A

Brings the processor back to the point where the procedure was called.

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

What is a nested procedure call?

A

When a called procedure calls another procedure before returning.

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

What is the difference between local and global labels?

A

Local labels are visible only inside the same procedure; global labels are visible everywhere.

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

What is the purpose of parameters in procedures?

A

To make procedures flexible and usable in different contexts.

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

What does the USES operator do?

A

Lists registers to be saved and restored within a procedure.

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

What is the structure of the ArraySum procedure?

A

Calculates the sum of an array of 32-bit integers.

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

What is a link library?

A

A file containing compiled procedures from one or more OBJ files.

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

What is the purpose of the INCLUDE directive?

A

To copy in procedure prototypes into the source code.

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

What does the Crlf procedure do?

A

Writes the end of line sequence to standard output.

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

Fill in the blank: The first instruction executed in a procedure is the _______.

A

CALL instruction.

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

True or False: The stack grows upward in memory.

A

False.

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

What does the DumpMem procedure do?

A

Writes block of memory to standard output in hex

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

What is the purpose of the GetCommandtail procedure?

A

Copies command-line args into array of bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the GetDateTime procedure retrieve?
Gets the current date and time from the system
26
What information does GetMaxXY provide?
Gets number of cols, rows in console window buffer
27
What does GetMseconds return?
Returns milliseconds elapsed since midnight
28
What does the GetTextColor procedure return?
Returns active foreground and background text colors in the console window
29
What is the function of Gotoxy?
Locates cursor at row and column on the console
30
What does the IsDigit procedure do?
Sets Zero flag if AL contains ASCII code for decimal digit (0–9)
31
What is the MsgBox procedure used for?
Displays popup message boxes
32
What does OpenInputFile do?
Opens existing file for input
33
What does the ParseDecimal32 procedure convert?
Converts unsigned integer string to binary
34
What is the purpose of ParseInteger32?
Converts signed integer string to binary
35
What does the Random32 procedure generate?
Generates 32-bit pseudorandom integer in the range 0 to FFFFFFFFh
36
What is the purpose of the Randomize procedure?
Seeds the random number generator
37
What does RandomRange do?
Generates a pseudorandom integer within a specified range
38
What does ReadChar read from the keyboard?
Reads a single character from standard input
39
What value does ReadDec return?
Reads 32-bit unsigned decimal integer from keyboard
40
What does ReadHex read?
Reads 32-bit hexadecimal integer from keyboard
41
What does ReadInt read from the keyboard?
Reads 32-bit signed decimal integer from keyboard
42
What does ReadKey do?
Reads character from keyboard input buffer
43
What is the function of ReadString?
Reads string from stdin, terminated by [Enter]
44
What does the SetTextColor procedure do?
Sets foreground/background colors of all subsequent text output to the console
45
What does Str_compare do?
Compares two strings
46
What is the function of Str_copy?
Copies a source string to a destination string
47
What does Str_length return?
Returns the length of a string in EAX
48
What does Str_trim do?
Removes unwanted characters from a string
49
What is the purpose of Str_ucase?
Converts a string to uppercase letters
50
What does WaitMsg do?
Displays message, waits for Enter key to be pressed
51
What does WriteBin do?
Writes unsigned 32-bit integer in ASCII binary format
52
What does WriteChar write to standard output?
Writes a single character to standard output
53
What format does WriteDec use to write an integer?
Writes unsigned 32-bit integer in decimal format
54
What does WriteHex write?
Writes an unsigned 32-bit integer in hexadecimal format
55
What does WriteInt do?
Writes signed 32-bit integer in decimal format
56
What does WriteString write to the console?
Writes null-terminated string to console window
57
What does WriteToFile do?
Writes buffer to output file
58
What does WriteWindowsMsg display?
Displays most recent error message generated by MS-Windows
59
What does the Crlf procedure do?
Writes an end-of-line sequence to the console
60
What is the purpose of Random64?
Generates a 64-bit pseudorandom integer
61
What does ReadInt64 do?
Reads a 64-bit signed integer from the keyboard
62
What is the Irvine32 library used for?
Use for all standard I/O and data conversion
63
What is a procedure in programming?
Named block of executable code
64
What is the runtime stack?
LIFO structure holds return addresses, parameters, local variables
65
What does the PUSH operation do?
Adds value to stack
66
What does the POP operation do?
Removes value from stack
67
What is the range of integers for ReadInt?
−2,147,483,648 to +2,147,483,647
68
What happens if ReadDec reads a blank integer?
EAX = 0 and CF = 1
69
What happens if ReadDec reads an integer larger than 2^32−1?
EAX = 0 and CF = 1