OSU CS 271 final review

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

what do you type in to get the process ID

$$

MACROS

,______arguments are substituted exactly as entered, without checking for memory, registers, or literals (macros or procedure)

32 (4*8)

- Given the following partial data segment, what value would I put in the brackets in list[n]to access the 9th element of list? MAX = 50 .data list DWORD MAX DUP(0)

400

- MAXSIZE = 100 list DWORD MAXSIZE DUP (?) How many bytes of memory are reserved by the declaration of list?

1296.0 (5*2.5*108)

- Suppose that each stage requires 2.4 nanoseconds to complete its task. How many nanoseconds would it take to complete 108.0 instructions without pipelining?

2B

- Suppose that you are given the following program (with memory addresses shown on the left). What hexadecimal value does EIP hold immediately after "inc EAX" has executed? 0x26 inc EAX 0x2B mov EBX, z

6 (3 *2 )

- Suppose that you are given the following program. Inside someProcedure, what numerical operand should be used with the RET instruction? push x push y push z

- 0*2200 = 8 | 0*2204 = 16 | 0*2208=25 | 0*220c= 35

- The address of array is 0*2200 . What's in 0*2200, 2204, 2208, 220c

How do you read and add numbers but you don't know how many numbers there are

-using loops

how do you initiate a shell script

/bin/sh ./my RadShellScript

command to run stats

/bin/sh ./stats -row test_file 2>&1

what are inodes

contains all the meta information about a file :size, permissions, content, reference count (how many hard links to the inode..), pointers to actual file data

how to get in normal mode

hit escape

what do you type in to get the process ID in C

int getpid()

whats hard link

is an entry that points to an inode. it connects a text file name to a node on disk

what does 2>&1 do

it takes any errors and dumps it to the screen. is puts the standard error in the standard outpu

what does 2> errors do?

it takes the standard error and dumbs it in a file called errors

space nastiness

mahe sure you add spaces 5\* \ ( 4 + 2 \)

what's the difference between echo "crab" > net.txt and echo "hello" >> net.txt

the second one appends and the first one overwrites

what is vi

vicious interface? a text editor, mostly used. more powerful than word in terms of editing. it evolved from ex. first visual enviroments instead of line editors

what does vim stand for

vim improved

how to copy in vim

y

F

When passing parameters to a procedure on the stack, it is usually okay to change the value of the EBP register within the procedure. (T or F)

To keep additional usage of the stack within the procedure from invalidating the stack offsets

When passing procedure parameters on the stack, push ebp mov ebp,esp are often necessary in a procedure to...

Internal Bus

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

Base address + elementSize time [(r time elementsPerRow)+c]

What is the correct addressing formula for matrix index Mr,c?

abc+de*/-

What is the postfix (RPN) form of the infix expression a - (b + c) / (d * e)

what is cat

concatenate (link things together) filr and standard output, so prints things to the screen

MACROS

the entire code is substituted for each call (macros or procedure)

1 1 2 3 5 8 13 21

;code fragment W mov eax,1 mov ebx,0 top: call WriteDec Space 2 cmp eax,13 jg quit mov ecx,ebx mov ebx,eax add eax,ecx jmp top quit: -What is the output of MASM code fragment W?

Space MACRO x LOCAL again push ECX push EAX mov AL, ' ' mov ECX,x again: call WriteChar loop again pop EAX pop ECX ENDM & Space MACRO x LOCAL again push EAX push ECX mov AL, ' ' mov ECX,x again: call WriteChar loop again pop ECX pop EAX ENDM

;code fragment W mov eax,1 mov ebx,0 top: call WriteDec Space 2 cmp eax,13 jg quit mov ecx,ebx mov ebx,eax add eax,ecx jmp top quit: WriteChar displays the ASCII character in the AL register. Which of the following correctly implements the Space macro?

1

AND?

9.5 seconds 20/(8(1+0.4*7))

An algorithm takes 20 seconds to execute on a single 2.4G processor. 40% of the algorithm is sequential. Assuming zero latency and perfect parallelism in the remaining code ...Approximately how long should the algorithm take on a parallel machine made of 8 2.4G processors?

8

An algorithm takes 20 seconds to execute on a single 2.4G processor. 40% of the algorithm is sequential. Assuming zero latency and perfect parallelism in the remaining code ...Suppose that we can add (with perfect scalability) any number of 2.4 G processors to the system. What is the fastest time that can be achieved?

Contiguous

Arrays are stored in ____ memory

mov eax,HI sub eax,LO inc eax call RandomRange add eax,LO mov x, eax __________ mov eax,HI mov ebx,LO dec ebx sub eax,ebx call RandomRange add eax,LO mov x, eax

Assume that LO and HI have already been assigned as constants with LO < HI, and x has been declared as DWORD in the data segment. Also, Irvine's library is included, and Randomize has already been called. Write a code that will assign x a "random" integer in the range [LO .. HI]? Check all that apply.

F

Assuming that all processor clock speeds are identical, executing a given software algorithm on a multicore processor is always faster than executing the same algorithm on a single-core processor. T OR F

4

Find the integer value of the postfix (RPN) expression: 2 7 + 3 2 - + 5 / 2 *

4A(74) -> (4+2+3 = 6+68 = 74)

For this problem, suppose that you are working with the partial data segment given below. Assume that the memory address of balance is 0x44 What hexadecimal address belongs to the first item in history? HISTLIMIT = 100 .data balance DWORD 0 account WORD ? history WORD HISTLIMIT DUP(?) isValid BYTE 0

110(272)-> ((2*99)+6 = 204)

For this problem, suppose that you are working with the partial data segment given below. Assume that the memory address of balance is 0x44 What hexadecimal address belongs to the last item in history? HISTLIMIT = 100 .data balance DWORD 0 account WORD ? history WORD HISTLIMIT DUP(?) isValid BYTE 0

What does the $ hold

the pid of the current process in a shell scrip

e (1, 2, 3, 4, 5, 6)

Given the following MASM data segment declarations: .data list DWORD 50 DUP(?) matrix DWORD 20 DUP(5 DUP(?)) value DWORD 10597059 decimal string BYTE "Computer Architecture",0 The base address of list is 1000H What is the character in BYTE PTR string+6 ?

161 (3rd element is A1 = 161)

Given the following MASM data segment declarations: .data list DWORD 50 DUP(?) matrix DWORD 20 DUP(5 DUP(?)) value DWORD 10597059 decimal string BYTE "Computer Architecture",0 The base address of list is 1000H What is the decimal value in BYTE PTR value+2 ?

0x1014(4116)-> (4096+(5*4))

Given the following MASM data segment declarations: .data list DWORD 50 DUP(?) matrix DWORD 20 DUP(5 DUP(?)) value DWORD 10597059 decimal string BYTE "Computer Architecture",0 The base address of list is 1000H What is the hexadecimal address of list[5*TYPE list]

0x1138(4408)-> (4096 + (50times4)+(5times5times4)+(3times4))

Given the following MASM data segment declarations: .data list DWORD 50 DUP(?) matrix DWORD 20 DUP(5 DUP(?)) value DWORD 10597059 decimal string BYTE "Computer Architecture",0 The base address of list is 1000H What is the hexadecimal address of matrix[5][3] ?

0x10C8(4296)-> (4096+(50*4))

Given the following MASM data segment declarations: .data list DWORD 50 DUP(?) matrix DWORD 20 DUP(5 DUP(?)) value DWORD 10597059 decimal string BYTE "Computer Architecture",0 The base address of list is 1000H What is the hexadecimal base address of matrix?

810.0 ((27*15)(2))

Given the following array declaration, how many bytes of memory does array matrix require? .data matrix WORD 27.0 DUP(15.0 DUP(?))

712.0-> (17 times10 times 4)+(8*4)

Given the following array declaration: .data matrix DWORD 50 DUP(10 DUP(?)) If matrix[0][0] is the 0th sequentially stored BYTE in memory, which sequentially stored BYTE is the first byte corresponding to matrix[17.0][8.0]?

mov eax, [edx + ebx]

Given the following register states, and using Indexed Addressing, which of the following lines of code will move the 11th element of the list array (of DWORDs) to the EAX register? EDX register contains the address of the first element of list. ESI register contains the address of the eleventh element of list.

You attempt to access whatever data bytes are stored there.

If you reference a point beyond the end of an array in MASM (for example, the address of the what would be the 105th element of a 100-element array), what happens?

3 ^Z

In code fragment R, suppose that variables y and z are declared as DWORD, what is calculated and stored in memory location y? (algebraic expression) ;code fragment R mov eax,1 mov ebx,3 mov ecx,z cmp ecx,0 je store top: mul ebx loop top store: mov y,eax

no

Is this a boolean expression? A ⋅ B = A ⋅ B

yes

Is this a boolean expression? A + (B ⋅ C ) = (A + B )( A + C )

no

Is this a boolean expression? A + B = A ⊕ B

yes

Is this a boolean expression? A + B = A ⋅ B

yes

Is this a boolean expression? A = A

False

MASM will throw an error when assembling the following data segment: .data myChecker BYTE 12h BYTE 34h BYTE 56h BYTE 78h BYTE 90h T or F

5738

MAXSIZE = 10 .data string BYTE MAXSIZE DUP (?) val DWORD ? mov ecx,eax ;number of ; digits entered mov val,0 ;initialize val mov esi,OFFSET string cld top: mov eax,0 lodsb sub eax,48 mov ebx,eax mov eax,val mov edx,10 mul edx add eax,ebx mov val,eax loop top done: mov eax,val call WriteDec Suppose that the user enters the string "5738" (without the quotes) when the ReadString procedure is called. - What is displayed?

0x6A 0x16 0x0 0x0

MAXSIZE = 10 .data string BYTE MAXSIZE DUP (?) val DWORD ? mov ecx,eax ;number of ; digits entered mov val,0 ;initialize val mov esi,OFFSET string cld top: mov eax,0 lodsb sub eax,48 mov ebx,eax mov eax,val mov edx,10 mul edx add eax,ebx mov val,eax loop top done: mov eax,val call WriteDec Suppose that the user enters the string "5738" (without the quotes) when the ReadString procedure is called. - What is stored in memory at val?

mov [edi+36],42

MAXSIZE = 100 .data list DWORD MAXSIZE DUP (?) Recall that DWORD specifies 4 bytes (32 bits). After the "program" is loaded and relocated, the label list is equivalent to absolute address 1000h. I.E., during program execution, the list array starts at memory address 1000h. All addresses are given in hexadecimal; other values are in decimal. After the statement mov edi,OFFSET list is executed, how would you correctly assigns the value 42 to the 10th element of the list array?

100 99 98 97 96 95

MAXSIZE = 100 .data list DWORD MAXSIZE DUP (?) - ;code fragment S mov edi,OFFSET list mov eax,MAXSIZE top: cmp eax,0 jle quit mov [edi],eax dec eax add edi,TYPE list jmp top quit: ;code fragment T mov edi,0 mov eax,1 mov ecx,MAXSIZE top: mov list[edi],eax add eax,2 add edi,4 loop top code fragment U mov edi,OFFSET list mov ebx,0 mov eax,1 mov ecx,MAXSIZE top: mov [edi+ebx],eax inc eax add ebx,TYPE list loop top After code fragment S is executed, what are the contents of the first 6 elements of the list array.

1 3 5 7 9 11

MAXSIZE = 100 .data list DWORD MAXSIZE DUP (?) - ;code fragment S mov edi,OFFSET list mov eax,MAXSIZE top: cmp eax,0 jle quit mov [edi],eax dec eax add edi,TYPE list jmp top quit: ;code fragment T mov edi,0 mov eax,1 mov ecx,MAXSIZE top: mov list[edi],eax add eax,2 add edi,4 loop top code fragment U mov edi,OFFSET list mov ebx,0 mov eax,1 mov ecx,MAXSIZE top: mov [edi+ebx],eax inc eax add ebx,TYPE list loop top After code fragment T is executed, what are the contents of the first 6 elements of the list array

1 2 3 4 5

MAXSIZE = 100 .data list DWORD MAXSIZE DUP (?) - ;code fragment S mov edi,OFFSET list mov eax,MAXSIZE top: cmp eax,0 jle quit mov [edi],eax dec eax add edi,TYPE list jmp top quit: ;code fragment T mov edi,0 mov eax,1 mov ecx,MAXSIZE top: mov list[edi],eax add eax,2 add edi,4 loop top code fragment U mov edi,OFFSET list mov ebx,0 mov eax,1 mov ecx,MAXSIZE top: mov [edi+ebx],eax inc eax add ebx,TYPE list loop top After code fragment U is executed, what are the contents of the first 6 elements of the list array

F

Most existing algorithms are readily parallelizable. (T or F)

T

Multiprocessor Parallelism (shared memory) usually has lower coordination overhead than Multicomputer Parallelism (distributed memory). (T or F)

4

NOR

3

NOT?

1 Fetch the instruction at the instruction pointer into the instruction register 2 Update the instruction pointer to point to the next instruction 3 Decode the instruction in the instruction register 4 Fetch the instruction operand(s) if necessary 5 Execute the instruction 6 Go back to the beginning of the instruction execution cycle

Order of steps in the instruction execution cycle? -Execute the instruction -Fetch the instruction at the instruction pointer into the instruction register - Fetch the instruction operand(s) if necessary -Decode the instruction in the instruction register -Go back to the beginning of the instruction execution cycle - Update the instruction pointer to point to the next instruction

Accessing memory through an address stored in a register.

Register Indirect addressing is defined as

= a * (b - (c + d)) / e

Show the infix form of the postfix (RPN) expression a b c d + - e / *

EDI

Storing a string byte using string primitives increments/decrements which register?

AB907856 (contains 4 because it's DWORD)

Suppose that you are given the following partial data segment: .data myPtrCheck BYTE 12h, 34h, 56h, 78h, 90h, ABh, CDh, EFh .code mov eax, DWORD PTR myPtrCheck mov eax, DWORD PTR [myPtrCheck+2] EAX contains what value, in hexadecimal?

9088 (1024+(84*96))

Suppose that a program's data and executable code require 1024.0 bytes of memory. A new section of code must be added; it will be used with various values 84.0 times during the execution of a program. When implemented as a macro, the macro code requires 96.0 bytes of memory. When implemented as a procedure, the procedure code requires 175.0 bytes (including parameter-passing, etc.), and each procedure call requires 13.0 bytes. How many bytes of memory will the entire program require if the new code is added as a macro?

2291 (1024+(84*13)+175)

Suppose that a program's data and executable code require 1024.0 bytes of memory. A new section of code must be added; it will be used with various values 84.0 times during the execution of a program. When implemented as a macro, the macro code requires 96.0 bytes of memory. When implemented as a procedure, the procedure code requires 175.0 bytes (including parameter-passing, etc.), and each procedure call requires 13.0 bytes.How many bytes of memory will the entire program require if the new code is added as a procedure?

701.0 (5*139+4.9)

Suppose that each stage requires 4.9 nanoseconds to complete its task. How many nanoseconds will it take to complete 139.0 instructions with pipelining?

4EAB(20139)-> -> (19968 + 171) (1+2+4*42)

Suppose that you are given the following MASM data segment declarations: .data idNumber BYTE ? status WORD 0 list DWORD 42 DUP(?) count DWORD ? The address of idNumber is 0x4E00 What is the hexadecimal address of count?

4E37 (20023) -> (19968 + 55) (1+2+4*13)

Suppose that you are given the following MASM data segment declarations: .data idNumber BYTE ? status WORD 0 list DWORD 42 DUP(?) count DWORD ? The address of idNumber is 0x4E00 What is the hexadecimal address of the 14th element of list?

1638.0 (0, 1, 2)

Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719, 1638, 1557, 1476, 1395, 1314, 1233, 1152, 1071, 990 u DWORD LENGTHOF idArray v DWORD SIZEOF idArray What value does EAX contain after the following code has executed? mov esi, OFFSET idArray mov eax, [esi+2.0*TYPE idArray]

1004 (word(2) * 2 (12 is the 2nd, 0, 1, 2) = 4

Suppose that you are given the following partial data segment, which starts at address offset 0x1000 : .data idArray WORD 3546, 1534, 12, 3481, 154, 6423 x DWORD LENGTHOF idArray y DWORD SIZEOF idArray z DWORD TYPE idArray What is the hexadecimal OFFSET of the number "12" in idArray?

12.0 (word(2) *6 (elements total)

Suppose that you are given the following partial data segment, which starts at address offset 0x1000 : .data idArray WORD 3546, 1534, 12, 3481, 154, 6423 x DWORD LENGTHOF idArray y DWORD SIZEOF idArray z DWORD TYPE idArray y contains what value, in decimal

4th one(DWORD) is 78, then 56 ect.. 78563412

Suppose that you are given the following partial data segment: .data myPtrCheck BYTE 12h, 34h, 56h, 78h, 90h, ABh, CDh, EFh .code mov eax, DWORD PTR myPtrCheck EAX contains what value, in hexadecimal?

[ebp]- previous value of ebp, [ebp + 4] - The return address from someProcedure. ,[ebp + 6]-none, [ebp + 8] -90, [ebp + 10] -37, [ebp + 12] -153461

Suppose that you are given the following program. After the instruction "mov ebp, esp", which of the following is referenced by each of the following? .data x DWORD 153461 y WORD 37 z WORD 90 .code main PROC push x push y push z call someProcedure someProcedure PROC push ebp mov ebp, esp pop ebp [ebp]? [ebp + 4] ? ,[ebp + 6]? [ebp + 8] ? [ebp + 12] ?

((1700000/(7+3+5))*3.5 = 396666

Suppose you have a RISC machine with a 1.7 GHz add reg, mem 7.0 clock cycles add reg, immed 3.0 clock cycles loop label 5.0 clock cycles how many array elements can be processed in 3.5 ms? (ESI)

((2000000/(5+1+4+4))*2.4 = 342857

Suppose you have a RISC machine with a 2.0 GHz loop label 5.0 clock cycles add reg, immed 1.0 clock cycle add reg, reg 4.0 clock cycles load r4, [3]) how many array elements can be processed in 2.4 ms? (NO ESI)

a single program is running on a multi-processor or a multi-computer system & two or more programs are running simultaneously on a single processor & a program implements an algorithm that uses threads

Synchronization of parallel processes may be required when

4

The RET instruction (without operands) will pop how many bytes off the stack?

EPI

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

PTR

The ______ operator overrides the default type of a label (variable), and can also be used to combine elements of a smaller data type and move them into a larger operand.

TYPE

The _______ operator returns the size, in bytes, of a single element of a data declaration.

LENGTHOF

The ___________ operator returns a count of the number of elements in a single data declaration.

OFFSET

The ___________ operator returns the distance in bytes, of a label from the beginning of its enclosing segment, added to the segment register.

120__24__6__2__

The code below uses the Space macro defined previously. What output is generated by the MASM "program"? main PROC push 1 push 1 push 5 call rfinal exit main ENDP rfinal PROC push ebp mov ebp,esp mov eax,[ebp+16] mov ebx,[ebp+12] mov ecx,[ebp+8] mul ebx mov [ebp+16],eax cmp ebx,ecx jge unwind inc ebx push eax push ebx push ecx call rfinal unwind: mov eax,[ebp+16] call WriteDec Space 2 pop ebp ret 12 rfinal ENDP

11

The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the first number printed to the screen after this code executes? main PROC push 4.0 push 12.0

8

The following instruction will increment the stack pointer (ESP) by how many bytes? ret 4

F

The following two instructions are equivalent. ret & ret 4 (T or F)

what is expr

The result of some given command

speed of individual processors & the I/O speed of individual processors & the speed of the interconnection network & scalability of the parallel architecture

The speed of processor-level parallelism as implemented in hardware depends on the CPU's

the parallelizability of algorithms & features of parallel application programming languages & parallel operating system software & efficiency of parallel system libraries

The speed of processor-level parallelism as implemented in software depends on

Full adder Circuit

This circuit is called?

A [ebp+8] - B[ebp+12]- C [edi] -D (4*2)

Which corresponds to A, B, C, D?

Initialize the FPU | Push a, Push b, Push c | Pop two values ,add, push result | Pop two values, multiply, and push result onto register stack | Push d, Push e | Pop two values from register stack, subtract first popped from second popped | Pop two values from register stack, add, and push result onto register stack | Pop value from register stack into var z

Which of the following correctly implements the assignment statement: z = a * (b + c) + (d - e)

PROCEDURES

_____ are translated only once, and can be called many times.(macros or procedure)

PROCEDURES

______have a calling mechanism involving the EIP.(macros or procedure)

PROCEDURES

______have a return mechanism involving the system stack.(macros or procedure)

MACROS & PROCEDURES

______may have parameters(macros or procedure)

Pipelining

_____is a form of instruction-level parallelism that is implemented by running multiple instruction execution cycles so that sequential instructions can be in different stages of the cycle at the same time

whats the normal mode

moving around the documents and perform edit commands - cursor movement h (left), j, (down) , k(up), l (right) [rogue key set] - $- end of line - 0- beginning line - w- beginning of next word - ^d- move screen down half a screen -^u- move screen up half a screen

how to past in vim

p

what's a pid

process id, each process has one of those

what will echo "FISH"> text.txt do

puts fish into the file

How do you read and add 2 numbers

readx1 x2 sum = 'expr $X1 + X2' echo $sum (dump out sum)

what does ZZ do in vim

save and exit current file

what is echo

show me some text

what does >> output 2>*1 do?

takes standard output and the standard error and appends to a file called output 2>&1


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

Chapter 11: Attitudes and Influencing Attitudes

View Set

Unit Circle - Set 3 (sin & cos for odd multiples of pi/4).

View Set

Econ 490 Incentive compensation final

View Set

Part 3: Text Structure in an Informational Text

View Set