Computer Architecture and Assembly Midterm

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

False

(True/False) Assembly Languages are portable.

True

A primary limitation on the speed of internal communication on a machine is the width of the internal bus.

PROC and ENDP

A procedure is declared using the _____ and ____ directives.

Linker

A program that combines object files into an executable program is called a linker .

The area of the stack set aside for passed arguments, return address, local variables, and saved registers.

A stack frame is _____

True

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

nested

A/An ________ procedure call occurs when a called procedure calls another procedure before the first procedure returns.

3 7 4

After the following MASM code is executed: MOV EAX, 25 MOV EBX, 7 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)?

49 23 11

After the following MASM code is executed: MOV EAX, 37 MOV EBX, 23 MOV ECX, 11 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?

True

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

a: FF a+1: FB a+2:29 a+3: B8

An SDWORD storing the integer value -317,000 (FFFB29B8h) is stored in memory on a big-endian system starting at memory address α. What Hex value is stored at each of the following memory addresses? α: α+1: α+2: α+3:

True

An argument passed by reference consists of a memory address offset.

True

An input parameter may be passed by reference.

False

An input/output parameter may be passed by value.

Activation record

Another name for a stack frame is

True

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

1: 42 2: 1C3B 3: 7

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

True

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

False

Code labels may only appear on lines with no instructions.

Direct Manipulation of Memory Hands-On Code Optimization

Compared to higher-level languages, which of the following are benefits of Assembly Language programming? (Check all that apply)

101,010,100

Complete the following Unsigned Binary Addition (answers should also be in Binary): NOTE: Canvas may add thousands place commas (for example 11001100 may appear as 11,001,100) ... Please ignore these. 10110011 + 10100001 ----------

8,343

Complete the following Unsigned Hexadecimal Addition (answers should also be in Hexadecimal): NOTE: Canvas may add thousands place commas (for example 9C4B may appear as 9,C4B) ... Please ignore these. 2C28 + 571B ------

00000010

Complete the following unsigned Binary Subtraction: 01110000 - 01101110 ---------- NOTE: Represent answer as an 8-bit value, with no spaces or characters other than 0s and 1s.

4AE6

Complete the following unsigned Hexadecimal Subtraction: 6A6F - 1F89 ------ NOTE: Represent answer as a 16-bit hex (four character) value, with no spaces or characters other than 0-9, A-F.

status register

Conditional jumps check flags in which register before jumping?

Floating

Convert the following ASCII hex representation to a character string: 46 6C 6F 61 74 69 6E 67 Do not add any spaces. For example, the hex 31 2B 7A represents the string: 1+z

30,123

Convert the following signed SWORD to a decimal value. 0111 0101 1010 1011

54 75 72 69 6E 67

Convert the following string into its ASCII hex representation: TuringDon't use 0x or h to represent the hex values. For example, the ASCII hex representation for "1+z" is 31 2B 7A

47,440

Convert the following unsigned WORD to a decimal value. 1011 1001 0101 0000

The Carry Flag: set when an unsigned arithmetic operation generates a carry The Overflow Flag: set when the result of a signed arithmetic operation is too large or too small The Sign Flag: set when the arithmetic operation generates in a negative result The Zero Flag: set when an arithmetic operation generates a result of zero The Parity Flag: set if the least significant byte in the result contains an even numbers of 1 bits

Correctly match the status flags to their description.

1,928.125

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

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

ESP always points to ______

0c1 3a 00 00

Encode the following decimal value into a IEEE 754 Single Precision Float: -11.625 Format answer as 4-byte hex value (for example, AA45F000h

No

Given the following data declarations and code (within main), what is printed to the console window? (Do not include "quotations" or "Press any key to continue", simply write anything printed with WriteString) .data yes BYTE "Yes",0 no BYTE "No",0 .code MOV EAX, 5 CMP EAX, 5 JG _printYes MOV EDX, OFFSET no JMP _finished _printYes: MOV EDX, OFFSET yes _finished: CALL WriteString

Yes

Given the following data declarations and code (within main), what is printed to the console window? (Do not include "quotations" or "Press any key to continue", simply write out anything printed with WriteString) .data yes BYTE "Yes",0 no BYTE "No",0 .code MOV EAX, 10 CMP EAX, 5 JG _printYes MOV EDX, OFFSET no JMP _finished _printYes: MOV EDX, OFFSET yes _finished: CALL WriteString

Maybe: No

Given the following data declarations and code (within main), what is printed to the console window? (Do not include "quotations" or "Press any key to continue", simply write out anything printed with WriteString) .data yes BYTE "Yes",0 no BYTE "No",0maybe 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

08FC 120h

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 doSomething00000120 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 checkThings000002A5 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)?

4D6h 001F

Given the following procedures, with code segment instruction addresses given on each line in 4 byte hex... 00000000 main PROC ; ...; Execution Point A0000001A CALL someProc1 0000001F CALL WriteDec; ... 00000030 exit00000031 main ENDP 00000031 someProc1 PROC 00000031 PUSH EAX 00000035 CALL someProc2 0000003A POP EAX; Execution Point B; ... 0000016F RET 0000016F someProc1 ENDP 0000016F someProc2 PROC 0000016F PUSH EBX ; ... 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)?

False

Groups of bytes in memory can only be interpreted a single way.

4

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

8

How many bytes long is a QUADWORD on x86 systems?

8

How many bytes long is a SQWORD on x86 systems?

sign: 1 exponent: 8 normalized mantissa: 23

Identify the sizes (in bits) of the sign, exponent, and normalized mantissa for a Single Precision x86 floating point value. Sign: bits Exponent: bits Normalized Mantissa: bits

False

If an integer's sign bit is 1, the integer is positive.

False

If the LOOP instruction sets ECX to zero, a jump to the destination label does take place.

F5

In debugging mode, what is the keyboard shortcut to continue execution to the next breakpoint (or to the end of the program if no more breakpoints exist)?

F10

In debugging mode, which function key is will execute a library procedure, then stop on the next instruction after the procedure?

&userName

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?

True

In the IA32 architecture, ESP (the stack pointer) is incremented each time data is popped from the stack.

False

In the IA32 architecture, ESP (the stack pointer) is incremented each time data is pushed onto the stack.

True

In the IA32 architecture, the top item on the stack will always have a lower memory address than the bottom item.

JA : jump if leftOP > rightOP (unsigned) JG: jump is leftOP > rightOP(signed) JNZ: Jump if result is nonzero JE: Jump if result is zero JC: Jump if carry flag set JECXZ: Jump if the counter register is zero

Match the Conditional Jump instruction to its operation.

The control unit fetches the next instruction from the instruction queue The control unit increments the instruction pointer (IP, also known as instruction counter). The control unit decodes the instruction's function to determine what the instruction will do. if the instruction uses an input operand located in memory... The ALU executes the instruction using the named registers and internal registers as operands. If the output operand is in memory, the control unit uses a write operation to store the data.

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

Correct!WORD 16-bit unsigned integer. Correct!SWORD 16-bit signed integer Correct!DWORD 32-bit unsigned integer Correct!SDWORD 32-bit signed integer. Correct!REAL4 32-bit (4-byte) IEEE short real Correct!REAL8

Match the datatype to its use/description. BYTE 8-bit unsigned integer. Correct!WORD 16-bit unsigned integer. Correct!SWORD 16-bit signed integer Correct!DWORD 32-bit unsigned integer Correct!SDWORD 32-bit signed integer. Correct!REAL4 32-bit (4-byte) IEEE short real Correct!REAL8

Answer 1:Correct!Specify the memory address on the Address Bus via MAR. Answer 2:Correct!Assert a Read Answer 3:Correct!Wait until operation is complete. Answer 4:Correct!Move data to its destination

Place the steps for a memory read in the correct order.

Decrement ECX, then Jump if ECX is nonzero

Please select the appropriate description of the LOOP instruction.

myList SDWORD 500 DUP (-1)

Select a data definition statement that creates an array of 500 signed doublewords named myList and initializes each array element to the value -1.

if (c < 0): print (yes)else:print (maybe)

Select the pseudo-code that corresponds to the following assembly code. Assume that the variables a, b, c, and d are initialized elsewhere in the program.You may want to review the usage of EAX, AH, and AL (IA32 registers).Also recall that the inequality a > b is equivalent to b < a.i.e. If A is greater than B, that's equivalent to saying that B is less than A. .data ; General purpose variables a SDWORD ? b SDWORD ? c SBYTE ? d SBYTE ? upperLevel SDWORD 18 lowerLevel SDWORD 3 ; Strings yes BYTE "Yes",0 no BYTE "No",0 maybe BYTE "Maybe",0 .code main PROC MOV EAX, 1 CMP AH, c JG option1 JMP option3 option1: MOV EDX, OFFSET yes CALL WriteString JMP endOfProgram option2: MOV EDX, OFFSET no CALL WriteString JMP endOfProgram option3: MOV EDX, OFFSET maybe CALL WriteString endOfProgram: exit main ENDP END main

125

Suppose that result is declared as DWORD, and the following MASM code is executed: MOV EAX, 17 MOV EBX, 13 MOV ECX, 6 _label5: ADD EAX, EBX ADD EBX, 2 LOOP _label5 MOV result, EAX What is the value stored in the memory location named result?

9562

Suppose that you are given the following program. What decimalvalue does the AX register hold when someProcedure is called? .data x DWORD 153461 y BYTE 37 z BYTE 90 .code main PROC MOV AH, y MOV AL, z CALL someProcedure INC EAX MOV EBX, z XOR EAX, EBX exit main ENDP END MAIN

byte-wise ordering

System endianness affects:

False

System endianness will impact the ordering (indexing) of elements in an array.

False

The ASCII code values for alphabetic letters (e.g. 'a') are smaller than for decimal digits (e.g. '1').

Push, then Jump

The CALL instruction functions similarly to which of the following?

False

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

True

The INC instruction does not affect the Carry flag.

syntax logic, run-time, or execution

The MASM assembler is used for locating syntax errors, but the debugging system is used for locating logic, run-time, or executionerrors.

True

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

EIP

The RET instruction pops the top of the stack into what register?

little endian

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

big endian

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

102Dh

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

1330h

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

True

The following is a valid data definition statement: str1 \ BYTE "This string is quite long!", 0

1,451,919,394

The four-byte hexadecimal sequence 22 88 8A 56 stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit unsigned integer.

301,958,600

The four-byte hexadecimal sequence C8 85 FF 11 stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.

True

The linker combines object files into an executable file.

True

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

data, address, control

The three types of buses connected to the CPU are:

reversing (inverting) the bits and adding 1

The two's complement of an binary value is formed by which process?

8

There are 8 general purpose registers.

The stack makes a convenient temporary save area for registers when they are used for more than one purpose. 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.

There are several important uses of runtime stacks in programs (select all that apply):

Stack parameters are compatible with high-level languages.

What advantages do stack parameters have over register parameters?

Internal Bus

What component is responsible for communication among the various internal CPU components?

System Clock

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

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

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

PUSHF

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

16,777,215

What is the largest unsigned integer that may be stored in 24 bits?

DL

What is the name of the lowest 8 bits of the EDX register?

PUSHA

What single instruction would I use to save all general purpose registers?

False

When an argument is passed by value, a copy of the address is pushed on the stack.

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

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

parameters

When values are received by a called subroutine, they are called __________.

REAL8

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

RandomRange

Which library procedure generates a 32-bit pseudorandom integer in a caller-specified range?

Gotoxy

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

IsDigit

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

call WriteInt

Which of the following CALL instructions writes the contents of EAX to standard output as a signed decimal integer?

nearly one to one

Which of the following best describes the relationship from assembly language instructions to machine language instructions?

0100 1010 0010 1011

Which of the following binary values is equivalent to hexadecimal 4A2B?

0111 1100 1011 1110

Which of the following binary values is equivalent to hexadecimal 7CBE?

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

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

manBear_Pig1 Correct! This_one?

Which of the following identifiers are allowed in MASM? (Check all that apply)

POP RET CALL PUSH

Which of the following instructions always modify the ESP register? (Check all that apply)

MAXVAL = 365

Which of the following statements correct makes a constant integer defining a maximum integer value of 365?

ECX

Which register is known as a loop counter?

False

x86-64 systems default to big-endian byte ordering.


Ensembles d'études connexes

Ch 6 - Intellectual Property Rights

View Set

APUSH-Containment, the Truman Doctrine, the Marshall Plan

View Set

Practical/Exam 3 Muscle Structures, Movements, Parts, Clinical Application

View Set

BIO 110: Final Exam: info from Exam 2: test form A

View Set

Managerial Accounting & Job-Order Cost

View Set