CS 271 Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

In debugging mode, which of the following (when typed into the memory window's address bar) will directly jump to the first memory address of variable userName?

&userName

Given the following procedures, with code segment instruction addresses given on each line in 4 byte hex... 00000000 main PROC ; ... ; Execution Point A 0000001A CALL someProc1 0000001F CALL WriteDec ; ... 00000030 exit 00000031 main ENDP 00000031 someProc1 PROC 00000031 PUSH EAX 00000035 CALL someProc2 0000003A POP EAX ; ... 0000016F RET 0000016F someProc1 ENDP 0000016F someProc2 PROC 0000016F PUSH EBX ; ... ; Execution Point B 00000205 POP EBX 00000209 RET 0000020A someProc2 ENDP Assume ESP = 000004DAh, EAX = 00000040h, EBX = 00000120h at Execution Point A, there are no stack operations other than those visible, and EAX and EBX are only changed by the visible instructions. At Execution Point B: What is the current value of the stack pointer (in 4 byte hex)? What is the value at the top of the stack (in 4 byte hex)?

- 04CA - 120 (the value in ESP)

Which of the following instructions always modify the ESP register? (Check all that apply) - DEC - INC - PUSH - JMP - CALL - JNE - POP - RET

- PUSH - POP - CALL - RET

There are several important uses of runtime stacks in programs (select all that apply): - When the CALL instruction executes, the stack is used to store the address where the called procedure will return to. - When calling a subroutine, you pass input values called arguments by pushing them on the stack. - The stack makes a convenient temporary save area for registers when they are used for more than one purpose. - The stack provides temporary storage for local variables.

- When the CALL instruction executes, the stack is used to store the address where the called procedure will return to. - When calling a subroutine, you pass input values called arguments by pushing them on the stack. -The stack provides temporary storage for local variables.

Which of the following identifiers are allowed in MASM? (Check all that apply) - 2towers - end - BB-8 - manBear_Pig1 - This_one?

- manBear_Pig1 - This_one?

The Carry flag The Overflow flag The Sign flag The Zero flag The Parity flag

- set when an unsigned arithmetic operation generates a carry -set when the result of a signed arithmetic operation is too large - set when the result of an arithmetic or logical operation generates a negative result - set when the result of an arithmetic or logical operation generates a result of zero - set if the least significant byte in the result contains an even number of 1 bits

What is the range of decimal values for a signed BYTE?

-128 to 127*

Decode the following IEEE 754 Single Precision Float (represented in hex) to its decimal value: C3FC3000

-504.375 Enter number as a 32 bit single HEX, and read the dec value without hitting enter

Write the syntax to set the size of the runtime stack to 2048 bytes.

.stack 2048

Given the following procedures, with code segment instruction addresses given on each line in 4 byte hex... 00000000 main PROC ; ... Execution Point A 0000011C CALL doSomething 00000120 MOV result, EAX ; ... 0000023E exit 0000023F main ENDP 0000023F checkThings PROC ; ... 00000243 XOR BX, 0A00h ; ... 00000274 RET 00000275 checkThings ENDP 00000275 doSomething PROC ; ... 000002A0 CALL checkThings 000002A5 MOV EAX, EDX ; Execution Point B ; ... 000002F3 RET 000002F4 doSomething ENDP Assume there are no stack operations other than the shown CALL and RET instructions, and ESP = 00000900h at Execution Point A. At Execution Point B: What is the current value of the stack pointer (in 4 byte hex)? What is the value at the top of the stack (in 4 byte hex)?

08FC 0120

Assume ESP equals 1C3Fh at Execution Point A. Trace the following code to Execution Point B, then answer the questions below. MOV EAX, 7 MOV EBX, 11 MOV ECX, 42 MOV EDX, 99 ; Nine Nine! ; Execution Point A PUSH EAX PUSH ECX PUSH EDX PUSH EBX POP EBX ; Execution Point B POP EDX POP EAX POP EDX At Execution Point B, what is the decimal value in EBX? At Execution Point B, what is the hexadecimal value in ESP? At Execution Point B, what is the decimal value in ESP?

11 1C33 99

The following data segment starts at memory address 1100h (hexadecimal) .data printString BYTE "MASM is fun",0 moreBytes BYTE 48 DUP(0) dateIssued DWORD ? dueDate DWORD ? elapsedTime WORD ? What is the hexadecimal address of dueDate?

1140h

How many binary digits are represented by a series of 4 hexadecimal characters?

16

What is the minimum size of a data type, in bytes, to be impacted by system endianness. (Whole numbers only)

2

What will be the value of EAX when the following sequence of instructions has executed? PUSH 5 PUSH 10 PUSH 20 POP EAX

20

How many bytes does the following string occupy in memory? .data myString BYTE "Everyone should learn to program!",135, 1, 21, 0

37 (each number counts as 1)

How many bytes long is a DWORD (doubleword) on x86?

4

After the following MASM code is executed: MOV EAX, 5 MOV EBX, 6 MOV ECX, 7 ADD EAX, EBX SUB EAX, ECX What is the decimal value in the EAX register? What is the decimal value in the EBX register? What is the decimal value in the ECX register?

4 6 7

The following data segment starts at memory address 4400h (hexadecimal) .data printString BYTE "Assembly is fun",0 moreBytes BYTE 28 DUP(0) dateIssued DWORD ? dueDate DWORD ? elapsedTime WORD ? What is the hexadecimal address of dueDate?

4430h

What will be the value of EAX when the following sequence of instructions has executed? PUSH 5 PUSH 10 POP EBX POP EAX

5

After the following MASM code is executed: MOV EAX, 149 MOV EBX, 15 MOV EDX, 0 DIV EBX What is the value in the EAX register (in decimal)? What is the value in the EBX register (in decimal)? What is the value in the EDX register (in decimal)?

9 15 14

When using the LOOP instruction, one should be wary of which common issues/problems? (Check all that apply) A) Too many instructions in the loop body B) Overwriting ECX's original value in a nested loop body without preserving its outer loop counter value. C) Modifying ECX directly within the loop body. D) Initializing ECX to a value less than or equal to zero. E) Initializing ECX to a value greater than zero. F) ECX not decrementing properly in the LOOP instruction itself.

A - D

The stack frame inside a procedure is also known as the ____________.

Activation Record

Encode the following decimal value into a IEEE 754 Single Precision Float: -65.84375

C283B000 (if negative, enter 0 - number) as 32 bit single dec, HIT ENTER, and read the hex value

Language Hierarchy: The purpose of a Compiler is to...

Convert High/low level Program Code to Assembly/Machine Code

Please select the appropriate description of the LOOP instruction.

Decrement ECX, then Jump if ECX is nonzero

Which library procedure displays the CPU flags and 32-bit registers?

DumpRegs*

The ___ register holds the 32-bit address of the next instruction to be fed to the instruction execution cycle

EIP

(True/False) In debugging mode, the values of watched variables/registers may only be viewed in hexadecimal format.

False

Adding 0FFh and 05h in the 8-bit register sets the Overflow flag

False

An input/output parameter may be passed by value.

False

High-level languages always pass arrays to subroutines by value.

False

PUSHF is used to preserve all general purpose register contents on the stack.

False

The CPU clock cycle length is the only contributing factor to the speed of operations on a computer.

False

The EQU directive permits a constant to be redefined at any point in a program.

False

x86-64 systems default to big-endian byte ordering

False

Which library procedure locates the cursor at a specific row and column on the screen?

Gotoxy

Which library procedure sets the Zero flag if the AL register contains the ASCII code for a decimal digit (0-9)?

IsDigit

JA JG JNZ JE JC JECXZ

Jump above (unasigned a > b) Jump greater (signed a > b) Jump not zero (result not zero) Jump Equal (result is zero) Jump Carry (carry flag is set) Jump Counter Register Zero (counter register is zero)

Given the following partial data segment (lines numbered for convenience), select all line numbers that contain invalid data definitions. Check all that apply. 1 real4 DWORD 5 2 one2? BYTE "step",0 3 Intro BYTE "You can call me",0 4 1two? BYTE "punch",0 5 One_two BYTE "three o-clock",0

Line 1 Line 3 Line 4

Which of the following defines a text macro named MESSAGE that contains this string data? "I'm good at this!",0

MESSAGE TEXTEQU <"I'm good at this!",0>

Which of the following code sequences assigns the value 10 to EBX? PUSH 20 MOV ECX, 10 PUSH ECX POP EAX POP EBX MOV ECX, 10 MOV EDX, 20 PUSH ECX PUSH EDX POP EBX POP EDX MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX

MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX

What does the ENDP directive do? (Check all that apply)

Marks the end of the module, Sets the entry point (procedure) for the program

Given the following data declarations and code (within main), what is printed to the console window? .data yes BYTE "Yes",0 no BYTE "No",0 maybe BYTE "Maybe: ",0 .code MOV EAX, 20 CMP EAX, 10 JG _printMaybe _printNo: MOV EDX, OFFSET no JMP _finished _printYes: MOV EDX, OFFSET yes JMP _finished _printMaybe: MOV EDX, OFFSET maybe CALL WriteString CMP EAX, 15 JL _printYes JMP _printNo _finished: CALL WriteString

Maybe: No

A procedure is declared using the ____ and ___ directives.

PROC and ENDP

What instruction would I use to save the current value of the flags register?

PUSHF PUSHFD PUSHFQ

When values are received by a called subroutine, they are called __________. - parameters - arguments - return values - variables

Parameters

The CALL instruction functions similarly to which of the following?

Push, then Jump

Which directive is used when defining 64-bit IEEE long reals?

REAL8

What general types of parameters are passed on the stack? - activation records - reference parameters - local variables - stack frames - value parameters

Reference parameters Value parameters

Identify the sizes of the sign, biased exponent, and normalized mantissa for a Double Precision x86 floating point value.

Sign: 1 Biased Exponent: 11 Normalized Mantissa: 52

Match the Instruction Execution steps to the correct order and description. *

Step 1. The control unit fetches Step 2. The control unit increments Step 3. The control unit decodes Step 4. If the instruction uses Step 5. The ALU executes the Step 6. If the output operand

What component's primary duty is synchronizing processes inside a computer?

System clock

A stack frame is ________. - An area in the heap that is used to store global variables - The area of the stack set aside for storing global strings - A register window pointing to local variables. - The area of the stack set aside for passed arguments, return address, local variables, and saved registers. - The area of the text segment set aside for passed arguments, subroutine return address, local variables, and saved registers

The area set aside for a procedure's return address, passed parameters, saved registers and local variables.

(True/False) In debugging mode, the contents of internal memory and registers can be viewed when a breakpoint is encountered.

True

A subprocedure's stack frame contains the return address and its local variables.

True

An IEEE 754 Floating Point value contains three components: a sign, a normalized mantissa, and an biased exponent.

True

Arrays are passed by reference to avoid copying each element into the stack/registers.

True

By default, code labels are visible only within the procedure in which they are assigned (created).

True

In MASM all text following a semicolon (on the same line) is treated as a comment and ignored when the program is converted to machine code.

True

Passing by reference requires accessing a parameter's offset from inside the called procedure.

True

The INC instruction does not affect the Carry flag

True

The MOVSX instruction sign-extends an integer into a larger operand.

True

The USES operator, coupled with the PROC directive, lets you list the names of all registers modified within a procedure and preserves them automatically for you.

True

The byte ordering method used on the internet is big-endian.

True

The linker combines files into an executable file.

True

The number 37.71875 can be represented exactly in IA-32 Floating Point Unit 32-bit IEEE 754 format.

True (put it in 32 single bit dec and if the float is the same then it can)

Which library procedure writes a single character to standard output?

WriteChar

When branching in MASM, you will normally jump to ___________.

a code label (representing an address in the code segment)

Which utility program reads an assembly language source file and produces an object file?

assembler

The byte-ordering scheme which stores integers in memory with the most significant byte at the lowest address (first) is called:

big endian

A ____ is a set of parallel wires used to conduct a group of electrical signals simultaneously

bus

System endianness affects: - byte-wise ordering - bit-wise ordering - memory page ordering - array index ordering

byte-wise ordering

A program is considered portable if it

can be executed on multiple platforms.

The three types of buses connected to the CPU are:

data, address, and control

ESP always points to ______ - the next, empty, location above the stack - the last value to be added to, or pushed on, the top of stack. - the next, empty, location below the stack. - the beginning of the stack when your program first began.

last value to be added to, or pushed on, the top of stack.

Select the answer choice that best implements the following expression. Do not permit dword1, ECX, or EDX to be modified: For reference, NEG EAX will replace the value in EAX with its two's complement (e.g. 14d becomes -14d, or -20d becomes 20d). eax = -dword1 + (edx - ecx) + 1 mov eax,dword1 neg eax mov ebx,edx sub ebx,ecx add eax,ebx inc eax neg dword1 mov ebx,edx sub ebx,ecx add eax,ebx inc eax mov eax,dword1 neg eax sub edx,ecx add eax,edx inc eax mov eax,dword1 mov edx,ebx sub ebx,ecx add eax,ebx inc eax

mov eax,dword1 neg eax mov ebx,edx sub ebx,ecx add eax,ebx inc eax

Given the following data declarations and code (within main), what is printed to the console window? .data yes BYTE "Yes",0 no BYTE "No",0 .code MOV EAX, 10 CMP EAX, 0 JS _printYes MOV EDX, OFFSET no JMP _finished _printYes: MOV EDX, OFFSET yes _finished: CALL WriteString

no

Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?

on the stack

Select the proper syntax for establishing a subprocedure. procedureName PROC ;... ;... RET ;return to calling procedure procedureName ENDP -------------------------------------------- PROC procedureName ;... ;... RET ;return to calling procedure procedureName ENDP --------------------------------------------- procedureName PROC ;... ;... exit ;return to calling procedure procedureName ENDP ---------------------------------------------- PROC procedureName ;... ;... exit ;return to calling procedure ENDP procedureNam

procedureName PROC ;... ;... RET ;return to calling procedure procedureName ENDP

A _______ is a container for data which resides on the CPU chip

register

The MASM assembler is used for locating ________ errors, but the debugging system is used for locating _______ errors.

syntax; logic, run-time, or execution

Given the following data declarations and code (within main), what is printed to the console window? .data yes BYTE "Yes",0 no BYTE "No",0 .code MOV EAX, 10 CMP EAX, 15 JS _printYes MOV EDX, OFFSET no JMP _finished _printYes: MOV EDX, OFFSET yes _finished: CALL WriteString

yes

An SDWORD storing the integer value -540,000 (FFF7C2A0h) is stored in memory on a little-endian system starting at memory address α. What Hex value is stored at each of the following memory addresses?

α: A0 α+1: C2 α+3: F7 α+4: FF


Ensembles d'études connexes

AP Chemistry - Photoelectron Spectroscopy (PES)

View Set