CS 271 Module 8

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following string primitives will modify the EDI register? Check all that apply.

MOVSB SCASB STOSB CMPSB

Which structure is the following true for? _________ have a return mechanism involving the system stack.

Procedures

Which of the following would be appropriate to scan through one string, stopping when a character in AL is successfully matched to a character in the string? Assume AL, ECX, ESI, and EDI have already been set appropriately (if necessary).

REPNE SCASB

Which of the following string primitives will compare the BYTEs stored in the memory locations pointed to by EDI and ESI?

CMPSB

What is the implied index for the LODSB instruction?

ESI

If the string direction flag is not set, string operations will move backward through the string.

False

The REPNE prefix checks the value of the Zero flag but requires its operand-instruction (the instruction which follows it) to modify the flag.

True

STOSW will write how many bytes to memory?

2 bytes STOSW is "Store String WORD", and WORDs are 2 bytes

Suppose that a program's data and executable code require 2048 bytes of memory. A new section of code must be added which will be used (with various values) 30 times during the execution of a program. When implemented as a macro, the macro code requires 48 bytes of memory per expansion. When implemented as a procedure, the procedure code requires 128 bytes of memory (including parameter-passing, etc.), and each procedure call requires 5 bytes of overhead. a)How many bytes of memory will the entire program require if the new code is added as a macro? b)How many bytes of memory will the entire program require if the new code is added as a procedure?

3488 Bytes2048 (Program before adding code) + 30*48 (48 bytes per expansion, 30 expansions) = 3488 bytes 2326 Bytes2048 (Program before adding code) + 128 (procedure code) + 30*5 (5 bytes per call, 30 calls) = 2326 bytes

Inside a loop which executes 1000 times, is it better to use a macro or a procedure? Why?

A macro is better. The code in the loop is only expanded once, but is executed many times. This means that there will only be one macro expansion. However, if a procedure is used, then all the overhead from a procedure call (building the stack frame, changing the instruction pointer, etc...) will occur 1000 times causing execution delay.

Which structure is the following true for? ________may have LOCAL labels.

Both Macros and Procedures

What is the implied index for the STOSB instruction?

EDI

The REP prefixes may be used with most instructions (MOV, CMP, ADD, etc...).

False

True/False) If a procedure uses the LOCAL directive, the procedure doesn't need a RET statement

False While the setup and takedown of the activation record is handled by the LOCAL directive, the return statement is not. The programmer must still write the return statement and account for any passed parameters.

Which of the following string primitives will copy a BYTE from the memory location pointed to by ESI to the AL register?

LODSB

Which of the following string primitives will modify the ESI register?

LODSB, CMPSB, MOVSB

Which of the following string primitives will modify the EDI register?

MOVSB, SCASB, STOSB, CMPSB

Which structure is the following true for? For _________, arguments are substituted exactly as entered, without checking for memory, registers, or literals.

Macros

In a procedure using the LOCAL directive, where are the local variables created?

On the runtime stack, immediately above the old EBP value.

Which structure is the following true for? _________ are translated only once, and can be called many times.

Procedures

Which of the following string primitives will compare the BYTE stored in the memory locations pointed to by EDI to the contents of the AL register?

SCASB

Which of the following string primitives will copy a BYTE from the AL register to the memory location pointed to by EDI?

STOSB

What mechanism is responsible for implementing inline expansion?

The MASM preprocessor.


Set pelajaran terkait

Ch. 4.1 Sound Byte:Where does Binary Show Up?

View Set

לָתֵת - to GIVE, LET (to), ALLOW (to), PUT, PLACE [infinitive noun] Shoresh: נתן

View Set

Beat the GMAT Practice Questions

View Set

Medical Law and Ethics Chapter 1

View Set

Biology 103 Sample Test Questions Exam 1.0

View Set