Chapter 5 - Procedures Flashcards
What are procedures also known as?
Subroutines and functions.
What is the structure of a stack?
LIFO (Last In, First Out).
Which registers manage the runtime stack?
SS (stack segment) and ESP (stack pointer).
What does the ESP register hold in 32-bit mode?
A 32-bit address in the stack.
What happens during a 32-bit push operation?
ESP is decremented by 4 and a value is copied into the location pointed by ESP.
What does a pop operation do?
Returns a copy of the value in the stack and increments the stack pointer.
What is the syntax for a 32-bit PUSH operation?
PUSH r/m32 or PUSH imm32.
What is the effect of a 16-bit operand in PUSH operation?
ESP is decremented by 2.
What is the purpose of the PUSHFD instruction?
To push the 32-bit EFLAGS register on the stack.
What is the structure of a procedure declaration in assembly?
PROC and ENDP directives with a name.
What does the CALL instruction do?
Pushes the return address on the stack and copies the called procedure’s address into EIP.
What does the RET instruction do?
Brings the processor back to the point where the procedure was called.
What is a nested procedure call?
When a called procedure calls another procedure before returning.
What is the difference between local and global labels?
Local labels are visible only inside the same procedure; global labels are visible everywhere.
What is the purpose of parameters in procedures?
To make procedures flexible and usable in different contexts.
What does the USES operator do?
Lists registers to be saved and restored within a procedure.
What is the structure of the ArraySum procedure?
Calculates the sum of an array of 32-bit integers.
What is a link library?
A file containing compiled procedures from one or more OBJ files.
What is the purpose of the INCLUDE directive?
To copy in procedure prototypes into the source code.
What does the Crlf procedure do?
Writes the end of line sequence to standard output.
Fill in the blank: The first instruction executed in a procedure is the _______.
CALL instruction.
True or False: The stack grows upward in memory.
False.
What does the DumpMem procedure do?
Writes block of memory to standard output in hex
What is the purpose of the GetCommandtail procedure?
Copies command-line args into array of bytes
What does the GetDateTime procedure retrieve?
Gets the current date and time from the system
What information does GetMaxXY provide?
Gets number of cols, rows in console window buffer
What does GetMseconds return?
Returns milliseconds elapsed since midnight
What does the GetTextColor procedure return?
Returns active foreground and background text colors in the console window
What is the function of Gotoxy?
Locates cursor at row and column on the console
What does the IsDigit procedure do?
Sets Zero flag if AL contains ASCII code for decimal digit (0–9)
What is the MsgBox procedure used for?
Displays popup message boxes
What does OpenInputFile do?
Opens existing file for input
What does the ParseDecimal32 procedure convert?
Converts unsigned integer string to binary
What is the purpose of ParseInteger32?
Converts signed integer string to binary
What does the Random32 procedure generate?
Generates 32-bit pseudorandom integer in the range 0 to FFFFFFFFh
What is the purpose of the Randomize procedure?
Seeds the random number generator
What does RandomRange do?
Generates a pseudorandom integer within a specified range
What does ReadChar read from the keyboard?
Reads a single character from standard input
What value does ReadDec return?
Reads 32-bit unsigned decimal integer from keyboard
What does ReadHex read?
Reads 32-bit hexadecimal integer from keyboard
What does ReadInt read from the keyboard?
Reads 32-bit signed decimal integer from keyboard
What does ReadKey do?
Reads character from keyboard input buffer
What is the function of ReadString?
Reads string from stdin, terminated by [Enter]
What does the SetTextColor procedure do?
Sets foreground/background colors of all subsequent text output to the console
What does Str_compare do?
Compares two strings
What is the function of Str_copy?
Copies a source string to a destination string
What does Str_length return?
Returns the length of a string in EAX
What does Str_trim do?
Removes unwanted characters from a string
What is the purpose of Str_ucase?
Converts a string to uppercase letters
What does WaitMsg do?
Displays message, waits for Enter key to be pressed
What does WriteBin do?
Writes unsigned 32-bit integer in ASCII binary format
What does WriteChar write to standard output?
Writes a single character to standard output
What format does WriteDec use to write an integer?
Writes unsigned 32-bit integer in decimal format
What does WriteHex write?
Writes an unsigned 32-bit integer in hexadecimal format
What does WriteInt do?
Writes signed 32-bit integer in decimal format
What does WriteString write to the console?
Writes null-terminated string to console window
What does WriteToFile do?
Writes buffer to output file
What does WriteWindowsMsg display?
Displays most recent error message generated by MS-Windows
What does the Crlf procedure do?
Writes an end-of-line sequence to the console
What is the purpose of Random64?
Generates a 64-bit pseudorandom integer
What does ReadInt64 do?
Reads a 64-bit signed integer from the keyboard
What is the Irvine32 library used for?
Use for all standard I/O and data conversion
What is a procedure in programming?
Named block of executable code
What is the runtime stack?
LIFO structure holds return addresses, parameters, local variables
What does the PUSH operation do?
Adds value to stack
What does the POP operation do?
Removes value from stack
What is the range of integers for ReadInt?
−2,147,483,648 to +2,147,483,647
What happens if ReadDec reads a blank integer?
EAX = 0 and CF = 1
What happens if ReadDec reads an integer larger than 2^32−1?
EAX = 0 and CF = 1