Chapter 5 - Procedures Flashcards

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
Q

What does the GetDateTime procedure retrieve?

A

Gets the current date and time from the system

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

What information does GetMaxXY provide?

A

Gets number of cols, rows in console window buffer

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

What does GetMseconds return?

A

Returns milliseconds elapsed since midnight

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

What does the GetTextColor procedure return?

A

Returns active foreground and background text colors in the console window

29
Q

What is the function of Gotoxy?

A

Locates cursor at row and column on the console

30
Q

What does the IsDigit procedure do?

A

Sets Zero flag if AL contains ASCII code for decimal digit (0–9)

31
Q

What is the MsgBox procedure used for?

A

Displays popup message boxes

32
Q

What does OpenInputFile do?

A

Opens existing file for input

33
Q

What does the ParseDecimal32 procedure convert?

A

Converts unsigned integer string to binary

34
Q

What is the purpose of ParseInteger32?

A

Converts signed integer string to binary

35
Q

What does the Random32 procedure generate?

A

Generates 32-bit pseudorandom integer in the range 0 to FFFFFFFFh

36
Q

What is the purpose of the Randomize procedure?

A

Seeds the random number generator

37
Q

What does RandomRange do?

A

Generates a pseudorandom integer within a specified range

38
Q

What does ReadChar read from the keyboard?

A

Reads a single character from standard input

39
Q

What value does ReadDec return?

A

Reads 32-bit unsigned decimal integer from keyboard

40
Q

What does ReadHex read?

A

Reads 32-bit hexadecimal integer from keyboard

41
Q

What does ReadInt read from the keyboard?

A

Reads 32-bit signed decimal integer from keyboard

42
Q

What does ReadKey do?

A

Reads character from keyboard input buffer

43
Q

What is the function of ReadString?

A

Reads string from stdin, terminated by [Enter]

44
Q

What does the SetTextColor procedure do?

A

Sets foreground/background colors of all subsequent text output to the console

45
Q

What does Str_compare do?

A

Compares two strings

46
Q

What is the function of Str_copy?

A

Copies a source string to a destination string

47
Q

What does Str_length return?

A

Returns the length of a string in EAX

48
Q

What does Str_trim do?

A

Removes unwanted characters from a string

49
Q

What is the purpose of Str_ucase?

A

Converts a string to uppercase letters

50
Q

What does WaitMsg do?

A

Displays message, waits for Enter key to be pressed

51
Q

What does WriteBin do?

A

Writes unsigned 32-bit integer in ASCII binary format

52
Q

What does WriteChar write to standard output?

A

Writes a single character to standard output

53
Q

What format does WriteDec use to write an integer?

A

Writes unsigned 32-bit integer in decimal format

54
Q

What does WriteHex write?

A

Writes an unsigned 32-bit integer in hexadecimal format

55
Q

What does WriteInt do?

A

Writes signed 32-bit integer in decimal format

56
Q

What does WriteString write to the console?

A

Writes null-terminated string to console window

57
Q

What does WriteToFile do?

A

Writes buffer to output file

58
Q

What does WriteWindowsMsg display?

A

Displays most recent error message generated by MS-Windows

59
Q

What does the Crlf procedure do?

A

Writes an end-of-line sequence to the console

60
Q

What is the purpose of Random64?

A

Generates a 64-bit pseudorandom integer

61
Q

What does ReadInt64 do?

A

Reads a 64-bit signed integer from the keyboard

62
Q

What is the Irvine32 library used for?

A

Use for all standard I/O and data conversion

63
Q

What is a procedure in programming?

A

Named block of executable code

64
Q

What is the runtime stack?

A

LIFO structure holds return addresses, parameters, local variables

65
Q

What does the PUSH operation do?

A

Adds value to stack

66
Q

What does the POP operation do?

A

Removes value from stack

67
Q

What is the range of integers for ReadInt?

A

−2,147,483,648 to +2,147,483,647

68
Q

What happens if ReadDec reads a blank integer?

A

EAX = 0 and CF = 1

69
Q

What happens if ReadDec reads an integer larger than 2^32−1?

A

EAX = 0 and CF = 1