Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE COPY THE QUESTIONS AND ANSWER NEXT TO THE QUESTION ______________________

ID: 3547863 • Letter: P

Question

PLEASE COPY THE QUESTIONS AND ANSWER NEXT TO THE QUESTION

_______________________________________________________________________________________


1. The REPE  prefix does which of the following ?

a. Repeats an instruction while the zero flag is clear

b. Repeats an instruction while the zero flag is set

c. Repeats an instruction while the carry flag is clear

d. Repeats an instruction while the carry flag is set

_____________________________________________________

2. Which instruction causes the ESI and EDI registers to be incremented by the MOVSB instruction?

a. CLC

b. REP

c. STD

d. CLD

____________________________________________

3. The MOVSB instruction uses which register as the source operand ?

a. ESI

b. EDI

c. EAX

d. ECX

_____________________________________________________

4. Select the two choices that are true regarding the ADDR operator?

a. ADDR makes a possible to pass arguments by reference

b. ADDR passes a pointer onto the stack

c. ADDR always passes parametets by value

d. ADDR is not permitted in Real-mode programming

___________________________________________

5.Which of the following PROC statements are INVALID ( select 2 choices )

a. MySub PROC WORD,  val1

DWORD,  val2

b. MySub PROC WORD,  val1

DWORD PTR,  val2

c. MySub PROC  val1,  BYTE

val2,  SDWORD

d. MySub PROC  val1, PTR

WORD, val2: DWORD

_________________________________________________________

6.What will be the hexadecimal value of DX and AX after the following  instructions have been executed? (EXPLAINATION NEEDED)

mov  ax, 3456h

mov  dx, 12h

mov  bx, 10h

div bx

AX= ?  DX= ?

______________________________________________

7. What are recrusive functions. explain?

_________________________________________________________

8. The logical shift fills the newly created bit position with zero ? ( TRUE/FALSE )

_____________________________________________

9. The arithmetic shift fills the newly created bit position with one ? ( TRUE/FALSE )

_________________________________________________________

10. SAL and SAR preserve number's sign ? ( TRUE/FALSE )

____________________________________________

11. LFA is required when obtaing offset of stack parameters and local variables. ( TRUE/FALSE )

___________________________________________

12. The declaration LOC AL flagVals[20] BYTE detects a local variable containng of 20 BYTES ( TRUE/FALSE )

_____________________________________________

13.  fill in the following missing code : code that use MOVSB to copy all the bytes from source to target.

.data

source BYTE 50 DUP(?)

target BYTE 100DUP(?)

.code

mov esi ____________,_____________

mov edi ____________,_____________

mov ecx____________,_____________

___________

rep _______________

________________________________________

14. what does cld  and std stand for ?

______________________________________________________________________________________

15. Determine the value of AX after each instruction

mov ah, 0

mov al, ______    ; AX= 0038h

mov al,  '2'   ;AX=_________  

aaa              ; AX=_________

or ax,3030h  ; AX=_________

____________________________________________________

16. determine the value of AX after each marked instruction

mov al, 62h        

aub al,35h         ; AL = ____,  CF= _______

das                   ; AL = ____,  CF= ________

___________________________________________________

17. given that EAX contains FFFF80C0H, Determine the value of ax and dx after executing CWD instruction? and tell what cwd stand for ?

AX= ____________________,dx=_____________________

_______________________________________________________________________

18. Suppose we define the following procedure

Example2 PROC,

one:DWORD, two:DWORD

mov eax,one

mov ebx, [ebp+12]

call DumpRegs

ret

Example2 ENDP

IF we called Example2 using the following statement, what would be displayed in EAX and EBX?

INVOKE Example2,  10h,  20h

EAX=____________, ebx=_____________







Explanation / Answer

1. The REPE prefix does which of the following ?

b. Repeats an instruction while the zero flag is set

_____________________________________________________

2. Which instruction causes the ESI and EDI registers to be incremented by the MOVSB instruction?

c. ST

___________________________________________

3. The MOVSB instruction uses which register as the source operand ?

a. ESI

_____________________________________________________

4. Select the two choices that are true regarding the ADDR operator?

b. ADDR passes a pointer onto the stack

c. ADDR always passes parametets by value

___________________________________________

5.Which of the following PROC statements are INVALID ( select 2 choices )

a. MySub PROC WORD, val1

DWORD, val2

d. MySub PROC val1, PTR

WORD, val2: DWORD

_________________________________________________________

7. What are recrusive functions. explain?

_ A recursive function (DEF) is a function which either calls itself or is in a potential cycle of function calls. As the definition specifies, there are two types of recursive functions. Consider a function which calls itself: we call this type of recursion immediate recursion.

One can view this mathematically in a directed call graph.

   A ---|
   ^    |
   |    |
   |----|

void A() {
A();
return;
}

A() is a recursive function since it directly calls itself.

The second part of the defintion refers to a cycle (or potential cycle if we use conditional statements) which involves other functions.

Consider the following directed call graph

   A ---------> B
   ^            |
   |            |
   |            |
   |---- C <----|

This can be viewed in the following three functions:

void C() {
A();
return;
}

void B() {
C();
return;
}

void A() {
B();
return;
}

Recursive functions are an inefficient means of solving problems in terms of run times but are interesting to study nonetheless. For our purposes we will only consider immediate recursion since this will cause enough difficulty.

A recursive function has the following general form (it is simply a specification of the general function we have seen many times):

ReturnType Function( Pass appropriate arguments ) {

if a simple case, return the simple value   // base case / stopping condition

else call function with simpler version of problem
}

For a recursive function to stop calling itself we require some type of stopping condition. If it is not the base case, then we simplify our computation using the general formula.

Compute n! Recursively.

We are given the mathematical function for computing the factorial:

n! = n * (n - 1)!

Why this is a recursive function? To compute n! we are required to compute (n - 1)!.

We are also given the simple case. We define mathematically 0!

0! = 1

To undersatnd factorial in a recursive sense, consider a few simple cases:

1! = 1 * 0! = 1 * 1 = 1

2! = 2 * 1! = 2 * 1 = 2

3! = 3 * 2! = 3 * 2 = 6

4! = 4 * (3 * 2 * 1) = 4 * 3! = 24

Consider a more complicated instance:

12! = 12 * 11! = 12 * (11 * 10 * ... * 1) = = ?

Now let us write the C++ function which will calculate the factorial of a given integer. Apply the simple case and the general factorial function to the general recursive function established previously.

int Factorial(int n) {
if (n == 0) return 1;           // Simple case: 0! = 1
return (n * Factorial(n - 1)); // General function: n! = n * (n - 1)!
}

Here, 0! = 1 is the base case and our general recursive function forms the simplification of the original problem.
________________________________________________________

8. The logical shift fills the newly created bit position with zero ?)

__True___________________________________________

9. The arithmetic shift fills the newly created bit position with one ?

False

_________________________________________________________

10. SAL and SAR preserve number's sign ?

TRUE

____________________________________________

11. LFA is required when obtaing offset of stack parameters and local variables.

(FALSE )

___________________________________________

12. The declaration LOC AL flagVals[20] BYTE detects a local variable containng of 20 BYTES

(FALSE )

_____________________________________________

13. fill in the following missing code : code that use MOVSB to copy all the bytes from source to target.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote