CS 271 Week 2 Summary - #2

Ace your homework & exams now with Quizwiz!

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.

33 23 7

After the following MASM code is executed: mov eax,17 mov ebx,23 mov ecx,7 add eax,ebx sub eax,ecx 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 ecx register (in decimal)?

12 17 8

After the following MASM code is executed: mov eax,212 mov ebx,17 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 ecx register (in decimal)?

Assembly

Convert the following ASCII hex representation into its string. The hex 31 2B 7A is the string 1+z 41 73 73 65 6D 62 6C 79

Electric

Convert the following ASCII hex representation into its string. The hex 31 2B 7A is the string 1+z 45 6C 65 63 74 72 69 63

-24471

Convert the following binary number into a signed decimal value. 1010 0000 0110 1001

-19371

Convert the following binary number into a signed decimal value. 1011 0100 0101 0101

44890

Convert the following binary number into an unsigned decimal value. 1010 1111 0101 1010

62740

Convert the following binary number into an unsigned decimal value. 1111 0101 0001 0100

47 6F 6F 67 6C 65

Convert the following string into its ASCII hex representation. Don't use 0x or h with the hex values. The hex for "1+z" is 31 2B 7A Google

4F 72 65 67 6F 6E

Convert the following string into its ASCII hex representation. Don't use 0x or h with the hex values. The hex for "1+z" is 31 2B 7A Oregon

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

ESP always points to the

False

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

True

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

Fetch, Decode, Execute

Place the 3 major steps of the Instruction Execution Cycle in the correct order.

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

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 neg dword1 mov ebx,edx sub ebx,ecx add eax,ebx inc eax mov eax,dword1 neg eax 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

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

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 while (a > 0) print (no); while (a < 18) print (no); else print (maybe); if (a < b) print (no); else print (maybe); for (k = 0; k < a; k++) print (no);

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?

True

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

True

The MOVZX instruction is only used with unsigned integers.

CrLf

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

0x1936

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

0x202C

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

0x3649

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?

False

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

True

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

PUSH CALL RET POP

The instructions used to manipulate the ESP regieter are (select all that apply): INC PUSH CALL DEC RET JNE POP

1, 2, 3, 4

There are several important uses of runtime stacks in programs (select all that apply): 1. When the CALL instruction executes, the CPU saves the current subroutine's return address on the stack. 2. When calling a subroutine, you pass input values called arguments by pushing them on the stack. 3. 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. 4. The stack provides temporary storage for local variables inside subroutines.

5

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

20

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

keyboard

Which I/O device is used for standard input?

GetMseconds

Which library procedure returns the number of milliseconds elapsed since midnight?

WriteChar

Which library procedure writes a single character to standard output?

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

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

2. 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.

Which of the following is true about the PUSH instruction? 1. It increments the stack pointer by 1 and copies the operand into the stack at the location pointed to by the stack pointer. 2. 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. 3. It copies the operand into the stack at the location pointed to by the stack pointer, and then decrements the stack pointer (by 2 or 4). 4. It increments the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer.

ESI

Which register contains the starting address of data when calling DumpMem?


Related study sets

Course Point Ch 20: Assessment of Respiratory

View Set

Nurs 114 Exam 1 Chapter 14 (assessing skin, hair and nails) prepU

View Set