CS 271 Assembly Midterm

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

- When the CALL instruction executes, the CPU saves the current subroutine's return address on the stack. - The stack provides temporary storage for local variables inside subroutines. - A stack makes a convenient temporary save area for registers when they are used for more than one purpose. After they are modified, they can be restored to their original values. - When calling a subroutine, you pass input values called arguments by pushing them on the stack.

Convert the following binary number into a signed decimal value. 1100 1101 0011 1100

-12996

The four-byte sequence 0xD6 0x45 0x41 0x90 stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.

-1874770474

The four-byte sequence 0x86 0x65 0x53 0x82 stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.

-2108463738

Which of the following are FALSE about assembly language instructions and directives?

-an instruction is executed at assembly time -a directive is executed at runtime

Which of the following are TRUE about assembly language instructions and directives?

-an instruction is executed at runtime -a directive is executed at assembly time

What is the value of the Carry flag after the following instructions? mov al,5h mov bl,10h mul bl

0

What is the value of the Carry flag after the following instructions? mov eax,12345h mov ebx,1000h mul eb

0

What is the value of the Overflow flag after the following instructions? mov eax,+4823424 mov ebx,-423 imul ebx

0

After executing the following instruction sequence, what is the value of AL, in binary: mov al,11001111b and al,00101011b

0000 1011b

Select the correct ODD parity 12 bit Hamming code value for the unsigned integer value 178

0111 0110 0010

Select the correct EVEN parity 12 bit Hamming code value for the unsigned integer value 191

0111 0110 1111

0101 1101 1011 is an EVEN parity 12 bit Hamming code that contains a single-bit error. What is the corresponding uncorrupted Hamming code?

0111 1101 1011

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

0x1521

The following data segment starts at memory address 0x2100 (hexadecimal) .data printString BYTE "Do not add decimal to hex",0 someBytes WORD 56 DUP(0) moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90 questionAddr DWORD ? ignoreMe WORD ? What is the hexadecimal address of questionAddr?

0x2193

What is the value of the Overflow flag after the following instructions? mov ax,-32000 imul ax,2

1

Instruction execution cycle:

1) Fetch the instruction at the address in the Instruction Pointer into the Instruction Register 2) Increment the Instruction Pointer to point to next instruction 3) Decode the instruction in the Instruction Register 4) If the instruction requires memory access, determine the memory address, and fetch the operand from memory into a CPU register, or send the operand from a CPU register to memory 5) Execute the instruction 6) If the output operand is in memory, the control unit uses a write operation to store the data

Place the stesp for creating a stack frame in the correct order

1) Passed arguments, if any, are pushed on the stack 2) The subroutine is called, causing the subroutine return address to be pushed on the stack 3) As the subroutine begins to execute, EBP is pushed on the stack 4) EPB is set equal to ESP. From this point on, EBP acts as a base reference for all of the subroutine parameters 5) If there are local variables, ESP is decremented to reserve space for the variables on the stack 6) If any registers need to be saved, they are pushed on the stack

What advantages do stack parameters have over register parameters?

1) Stack parameters are compatible with high-level languages 2) Stack parameters reduce code clutter because registers do not have to be saved & restored

Instruction Execution steps in the correct order:

1) The control unit fetches the next instruction from the instruction queue 2) The control unit increments the instruction pointer 3) The control unit decodes the instruction's function to determine what the instruction will do 4) If the instruction uses an input operand located in memory, the control unit uses a read operation to retrieve the operand and copy it into internal registers 5) The ALU executes the instruction using the named registers and internal registers as operands 6) If the output operand is in memory the control unit uses it as a write operation to store data

If a clock oscillates 10 billion times per second, what is the duration of a single clock cycle?

1.0 x 10^-10 seconds

Select the correct ODD parity 12 bit Hamming code value for the unsigned integer value 137

1010 0001 1001

After executing the following instruction sequence, what is the value of AL, in binary: mov al,94h xor al,37h

1010 0011b

1010 1111 0011 is an EVEN parity 12 bit Hamming code that contains a single-bit error. What is the corresponding uncorrupted Hamming code?

1010 1111 1011

After executing the following instruction sequence, what is the value of AL, in binary: mov al,00111100b or al,82h

1011 1110b

1100 0101 0110 is an ODD parity 12 bit Hamming code that contains a single-bit error. What is the corresponding uncorrupted Hamming code?

1110 0101 0110

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?

125

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

16,777,215

The four-byte sequence 0xC7 0xAB 0xDC 0x6B stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.

1809624007

Suppose that result is declared as DWORD, and the following MASM code is executed: mov eax,14 mov ebx,23 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?

182

How much memory can be addressed in Real Address Mode?

1MB

The four-byte sequence 0x8D 0xAB 0x52 0xAB stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit unsigned integer.

2874321805

The four-byte sequence 0x2D 0xAC 0x52 0xCB stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit unsigned integer.

3411192877

Given the following MASM code using Irvine's library: mov eax,1 mov ebx,4 label6: mul ebx call WriteDec call CrLf inc ebx cmp eax,40 jbe label6 mov eax,ebx call WriteDec call CrLf Show the output produced by execution of the code. Note: Pay special attention to line breaks

4 20 120 7

After executing the following instruction sequence, what is the value of AL, in hexadecimal mov al,4Bh and al,74h

40h

How much memory can be addressed in Protected Mode

4GB

What will be the value of EAX when the following sequence of instructions has executed? push 5 push 10 pop ebx pop eax

5

Suppose that result is declared as DWORD, and the following MASM code is executed: mov eax,7 mov ebx,5 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?

67

Which letter choice shows the memory byte order, from low to high address, of the following: BigVal DWORD 12345678h

78h, 56h, 34h, 12h

Suppose that you are given the follow program. What decimal value 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

9562

What will be the hexadecimal value of AL after these instructions execute? mov al,94h xor al,37h

A3h

Within the CPU, all calculations and logic operations take place inside the ___________.

ALU

Another name for a stack frame is:

Activation record

After the following MASM code is executed: mov eax, 96 mov ebx, 13 mov edx, 0 div ebx Value of EAX register: 7 Value of EBX register: 13 Value of ECX register: 5

After the following MASM code is executed: mov eax,123 mov ebx,13 mov edx,0 div ebx EAX: 9 EBX: 13 EDX: 6

After the following MASM code is executed: mov eax,11 mov ebx,3 mov ecx,10 add eax,ebx sub eax,ecx EAX: 4 EBX: 3 ECX: 10

After the following MASM code is executed: mov eax, 219 mov ebx, 23 mov ecx, 56 add eax, ebx sub eax, ecx Value of EAX register: 186 Value of EBX register: 23 Value of ECX register: 56

Given the following array definition, which letter choice contains a valid constant declaration named ArrayCount that automatically calculates the number of elements in the array? newArray DWORD 10,20,30,40,50

ArrayCount =($ - newArray) /4

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

Assembler

The instructions used to manipulate the ESP regieter are (select all that apply):

CALL RET PUSH POP

A program is considered portable if it

CAN BE EXECUTED ON MULTIPLE PLATFORMS

Which flag is set when an unsigned value is too large to fit into a destination operand?

CARRY

Which answer choice shows the correct values of the Carry, Zero, and Sign flags after the following instructions execute? mov al,00110011b test al,2

CF = 0, ZF = 0, SF = 0

Which answer choice shows the correct values of the Carry, Zero, and Sign flags after the following instructions execute? mov al,6 cmp al,5

CF = 0, ZF = 0, SF = 0

Match the status flags with the correct description

Carry Flag: indicates unsigned integer overflow Overflow: indicates signed integer overflow Zero Flag: indicates that the operation produced zero Sign flag: indicates that an operation produced a negative result parity flag: indicates whether or not an even number of 1 bit occurs in the least significant byte of the destination operand, immediately after an arithmetic or boolean instruction has executed auxiliary carry flag: set when 1 bit carries out of position 3 in the least significant byte of the destination operand.

After the following instruction sequence, show the values of the Carry , Zero, and Sign flags mov al,6 cmp al,5

Carry: 0 Zero: 0 Sign: 0

The ________ procedure advances the cursor to the beginning of the next line in the console window.

CrLf

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

DL

In what register will the remainder of the following instruction be found? DIV BX

DX

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

DumpRegs

After the following code has finished execution, ECX contains the initial contents of which register? mov edx, eax mov ebx, ecx mov ebx, edx mov ecx, ebx mov edx, eax

EAX

After the following MASM code is executed: mov eax,117 mov ebx,9 mov edx,0 div ebx

EAX: 13 EBX: 9 EDX: 0

After the following MASM code is executed: mov eax,19 mov ebx,18 mov ecx,17 add eax,ebx sub eax,ecx

EAX: 20 EBX: 18 ECX: 17

Which register is known as a loop counter?

ECX

In what register will the remainder of the following instruction be found? DIV EBX

EDX

Which register contains the offset of a character array when calling GetCommandTail?

EDX

Where is the result of the following operation stored? MUL EBX

EDX:EAX

Which two 32 bit registers are known as extended index registers?

ESI, EDI

A signed integer stores the sign in the least significant bit

FALSE

A stack is also called a FIFO structure (First-In, First-Out) because the last value put into the stack is always the first value taken out.

FALSE

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

FALSE

An identifier may begin with a digit

FALSE

High-level languages always pass arrays to subroutines by value

FALSE

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

FALSE

Local variables are created by adding a positive value to the stack pointer

FALSE

MASM has built-in range checking for effective addresses.

FALSE

The ASCII codes for alphabetic letters are smaller than for decimal digits

FALSE

The MUL (unsigned multiply) instruction can have operands of different sizes.

FALSE

The following instructions will set the Carry flag: mov al,0FEh sub al,2

FALSE

The following sequence of statements is INVALID? .code mov eax, edx .data myByte BYTE 10 .code mov al, myByte

FALSE

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

FALSE

Steps of the Instruction Execution Cycle:

Fetch Decode Fetch Operands Execute Store output operands

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

Which of the following is true about the PUSH instruction?

It decrements the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer.

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

LOCAL wArray[50]:SWORD

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 is NOT a valid MOV operation? Table 4-1 might be helpful. (check any/all that apply)

MOV imm,mem MOV imm,imm MOV mem,mem

Identify which of the following are allowed formats for the MUL instruction. (Check all that apply)

MUL reg MUL mem8 MUL mem32 MUL mem16

Which of the following best describes the relationship between assembly language and machine language?

ONE TO ONE

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

On the stack

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

RandomRange

Which library procedure reads a string from standard input?

ReadString

A doubleword (on x86 systems) is 32 bits

TRUE

A signed byte can be equal to +127

TRUE

A subroutine's stack frame always contains the caller's return address and the subroutine's local variables.

TRUE

A word (on x86 systems) is bits

TRUE

Arrays are passed by reference to avoid copying them onto the stack.

TRUE

By default, labels are visible only within the procedure in which they are declared.

TRUE

In the x86 Floating-Point, a decimal number contains three components: a sign, a significand, and an exponent.

TRUE

Is the expression X v (Y ^ Z) equivalent to (X v Y) ^ (X v Z) for all possible inputs of X, Y, and Z?

TRUE

Mechanically speaking, the CALL instruction pushes its return address on the stack and copies the called procedure's address into the instruction pointer.

TRUE

Passing by reference requires popping a parameter's offset from the stack 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.

TRUE

The expression (x ^ Y) is true only when X and Y are both true.

TRUE

The expression is true when - (X ^ Y) are both false.

TRUE

The following are both valid data definition: Llist1 BYTE 10,20 BYTE 30,40

TRUE

The following instructions will set the Sign flag: mov al,0FEh sub al,2

TRUE

The following instructions will set the sign flag: mov al, 0FEh sub al, 2

TRUE

The linker combines object files into an executable file.

TRUE

The listing file contains a list of program symbols

TRUE

Three hexadecimal digits can be used to represent 12 binary bits

TRUE

Unlike the MUL instruction, IMUL preserves the sign of the product.

TRUE

What is the value of the booloean expression X v (Y ^ Z) , when X=true, Y=false, and Z=false?

TRUE

A stack frame is _____

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

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

The following data segment starts at memory address 0x1700 (hexadecimal) .data printString BYTE "Assembly is fun",0 moreBytes BYTE 19 DUP(0) dateIssued DWORD ? dueDate DWORD ? elapsedTime WORD ? What is the hex address of DueDate? Ox1727

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

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

The following data segment starts at memory address 0x1000 (hexadecimal) .data printString BYTE "Assembly is fun",0 moreBytes BYTE 10 DUP(0) dateIssued DWORD ? dueDate DWORD ? elapsedTime WORD ? What is the hex address of DueDate? 0x101E

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

What general types of parameters are passed on the stack?

Value arguments Reference arguments

What are the two common types of stack parameters?

Value parameters AND Reference parameters

Which library procedure writes an unsigned 32-bit integer to standard output in hexadecimal format?

WriteHex

Which of the following are valid uses of the XCHG instruction? (check any/all that apply)

XCHG mem,reg XCHG reg,mem XCHG reg,reg

What is the largest signed integer that may be stored in 32 bits?

[2^(31)] - 1

Which action must take place inside a procedure to reserve space on the stack for two doubleword local variables?

after MOV EBP,ESP, subtract 8 from the stack pointer (ESP)

Values passed to a subroutine by a calling program are called

arguments

Assuming that a procedure contains no local variables, a stack frame is created by which sequence of actions at runtime?

arguments pushed on stack; procedure called; EBP pushed on stack; EBP set to ESP

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

call WriteInt

Suppose EAX, EBX, and ECX contained three unsigned integers. Which of the following code excerpts would display the largest of the three integers?

cmp eax,ebx jae L1 mov eax,ebx L1: cmp eax,ecx jae L2 mov eax,ecx L2: call WriteInt

Which internal bus uses binary signals to synchronize actions of all devices attached to the system bus?

control bus

List the three primary steps of the instruction execution cycle, in sequential order (even if some are missing).

fetch, decode, execute

Select the pseudo-code that most closely corresponds to the following assembly code. Assume that the variables a, b, c, and d are initialized elsewhere in the program. .data ; General purpose variables a DWORD ? b DWORD ? c BYTE ? d BYTE ? upperLevel DWORD 18 lowerLevel DWORD 3 ; Strings yes BYTE "Yes",0 no BYTE "No",0 maybe BYTE "Maybe",0 .code main PROC mov eax, 0 mov ebx, a startLoop: cmp eax, ebx jge endOfProgram mov edx, OFFSET no call WriteString inc eax jmp startLoop mov edx, OFFSET maybe call WriteString endOfProgram: exit main ENDP END main

for (k = 0; k < a; k++) print (no);

Select the answer choice that best implements the following expression. Do not permit dword1, ECX, or EDX to be modified: eax = -dword1 + (edx - ecx) + 1

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

Which of the following code sequences assigns the value 0x10 to EBX? (select all that are correct)

mov edx,20h push edx mov ecx,10h push ecx pop ebx pop edx AND: mov edx,20h push edx mov ecx,10h push ecx pop ebx pop edx

Which of the following are valid data definition statements that create an array of unsigned bytes containing decimal 10, 20, and 30

myArray BYTE 10, 20, 30

What is a single instruction that complements all bits in AL, without using the XOR instruction?

not al

The Irvine32 library call GetMseconds returns

number of system milliseconds that have elapsed since midnight

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

parameters

Select the pseudo-code that corresponds to the following assembly code. .data ; General purpose variables a DWORD ? b DWORD ? c BYTE ? d BYTE ? upperLevel DWORD 18 lowerLevel DWORD 3 ; Strings yes BYTE "Yes",0 no BYTE "No",0 maybe BYTE "Maybe",0 .code main PROC mov eax, 0 cmp eax, lowerLevel jne option1 jmp option2 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

print (yes);

Which of the following shows the procedure entry code generated by MASM when the LOCAL directive is used to declare a doubleword variable?

push ebp mov ebp,esp sub esp,4

Identify the sizes of the sign ___________ exponent _________ and significand _______ for a Single Precision x86 floating point number?

sign: 1 exponent: 8 significand: 23

According to the lectures, identify the sizes of the sign ___ exponent ____ and significand ______ for a Double Extended Precision x86 floating point number

sign: 1 exponent: 15 significand: 64

The following data segment starts at memory address 0x3600 (hexadecimal) .data printString BYTE "Do not add decimal to hex",0 someBytes WORD 19 DUP(0) moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90 questionAddr DWORD ? ignoreMe WORD ? What is the hexadecimal address of questionAddr? 0x3649

starts at memory address 0x1000 .data printString BYTE "Do not add decimal to hex",0 someBytes WORD 27 DUP(0) moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90 questionAddr DWORD ? ignoreMe WORD ? What is the hexadecimal address of questionAddr? 0x1059

starts at memory address 0x1200 .data printString BYTE "Do not add decimal to hex",0 someBytes WORD 15 DUP(0) moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90 questionAddr DWORD ? ignoreMe WORD ? What is the hexadecimal address of questionAddr? 0x1241

starts at memory address 0x4100 (hexadecimal) .data printString BYTE "Do not add decimal to hex",0 someBytes WORD 36 DUP(0) moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90 questionAddr DWORD ? ignoreMe WORD ? address of questionAddr? 0x416b

What is a single instruction that inverts bits 5 and 6 in BL without changing any other bits?

xor bl,1100000b


संबंधित स्टडी सेट्स

NCLEX/ ATI comp: Musculoskeletal (OA & RA)

View Set

Science 500 - Unit 2, Plants - TEST

View Set

Funeral Services NBE Arts Review

View Set

All BABOK Techniques - Advantages & Disadvantages

View Set

Section 9: Animal Nursing: Animal Care, Emergency Care, Pocket Pets/Laboratory Animals, Medical Nursing

View Set

APPP 3: The Autonomic Nervous System

View Set

Chapters 14-18 substance use and abuse

View Set

Pharm Chapter 49: Immunizing Drugs

View Set