Question

In: Computer Science

Draw the stack (use, word/pdf) before every instruction that is marked red is executed to show...

Draw the stack (use, word/pdf) before every instruction that is marked red is executed to show your understanding of the call and return functions.   Use N/A to represent unpredictable values.

            
            Main Proc
            4040018          mov ecx, 0000000Ch
            404001C          mov ebx, 0000000Bh
            4040020          call FADD
            4040026          mov eax, ebx
                      …
                      …                    

            Main EndP

            FADD  PROC
            4041040          Push ecx
            4041044          Push ebx
            4041048          mov eax, edx
                      …
                      …
            404A060         Pop ebx
            404A062         Pop ecx
            404A064         ret
            FADD EndP

Solutions

Expert Solution

1). ANSWER :

GIVENTHAT :

Main program start at location 4040018

1)CALL FADD

Call sub procedure at location 4040020

The CALL instruction is used whenever we need to make a call to some procedure or a subprogram. Whenever a CALL is made, the following process takes place inside the microprocessor:

  • The address of the next instruction that exists in the caller program (after the program CALL instruction) is stored in the stack.
  • The instruction queue is emptied for accommodating the instructions of the procedure.
  • Then, the contents of the instruction pointer (IP) is changed with the address of the first instruction of the procedure.
  • The subsequent instructions of the procedure are stored in the instruction queue for execution.

The Syntax for the CALL instruction is as follows:

    CALL subprogram_name

FADD/FADDP/FIADD — Add

Adds the destination and source operands and stores the sum in the destination location. The destination operand is always an FPU register; the source operand can be a register or a memory location. Source operands in memory can be in single-precision or double-precision floating-point format or in word or doubleword integer format.

  • FADD, given one operand, adds the operand to ST0 and stores the result back in ST0. If the operand has the TO modifier, the result is stored in the register given rather than in ST0.

FADDP performs the same function as FADD TO, but pops the register stack after storing the result.

2)move eax,ebx

Mov instruction:

· mov — Move (Opcodes: 88, 89, 8A, 8B, 8C, 8E, ...)

· The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory). While register-to-register moves are possible, direct memory-to-memory moves are not. In cases where memory transfers are desired, the source memory contents must first be loaded into a register, then can be stored to the destination memory address.

Syntax
mov <reg>,<reg>
mov <reg>,<mem>
after execution of this instruction copy the value in ebx into eax

ebx=0000000bh

After execution eax=0000000bh

3)push ecx

ecx contain 0000000Ch

PUSH - stores 16 bit value in the stack.

Syntax for PUSH instruction:

PUSH REG
• A push operation decrements the stack pointer by 2 or 4 (depending on operands) and copies a value into the location pointed to by the stack pointer.

After execution of push ecx

contain 0000000Ch goes to location 4041040

4) push ebx

ebx contain 0000000Bh

After execution of push ebx

contain 0000000Bh goes to location 4041044

5)move eax,edx

after execution of this instruction copy the value in edx into eax

edx is N/A

6)POP ebx

POP - gets 16 bit value from the stack.

Syntax for POP instruction:

POP REG

  • Store original value of the register in stack (using PUSH).
  • Use the register for any purpose.
  • Restore the original value of the register from stack (using POP).

· pop — Pop stack

· The pop instruction removes the 4-byte data element from the top of the hardware-supported stack into the specified operand (i.e. register or memory location). It first moves the 4 bytes located at memory location [SP] into the specified register or memory location, and then increments SP by 4.

POP ebx:

After execution of POP ebx pop contain 0000000Bh at location 4041044

    7)POP ecx

After execution of POP ecx ,pop contain 0000000Ch at location 4041040

8)RET

The RET instruction stands for return. This instruction is used at the end of the procedures or the subprograms. This instruction transfers the execution to the caller program. Whenever the RET instruction is called, the following process takes place inside the microprocessor:

  • The address of the next instruction in the mainline program which was previously stored inside the stack is now again fetched and is placed inside the instruction pointer (IP).
  • The instruction queue will now again be filled with the subsequent instructions of the mainline program.

The Syntax for the RET instruction is as follows:

            RET

After execution of RET instruction The address of the next instruction in the mainline program that is 4040026 which was previously stored inside the stack is now again fetched and is placed inside the instruction pointer (IP).


Related Solutions

Draw the stack (use, word/pdf) before every instruction that is marked red is executed to show...
Draw the stack (use, word/pdf) before every instruction that is marked red is executed to show your understanding of the call and return functions.   Use N/A to represent unpredictable values. Main Proc 4040018 mov ecx, 0000000Ch 404001C mov ebx, 0000000Bh 4040020 call FADD 4040026 mov eax, ebx … … Main EndP FADD PROC 4041040 Push ecx 4041044 Push ebx 4041048 mov eax, edx … … 404A060 Pop ebx 404A062 Pop ecx 404A064 ret FADD EndP
1 Draw a stack diagram to show how the following code is executed and write the...
1 Draw a stack diagram to show how the following code is executed and write the generated output. def sequence(a, b, c): if a < b < c: return a + b + c if a >= b: return sequence(a - 1, b, c) if a >= c: return sequence(c, b, a) if b >= c: return sequence(c, b, a + 2) return 0 print(sequence(10, 10, 10)) 2 Draw a stack diagram to show how the following code is executed...
Instruction: Use Microsoft Visio to draw a use case diagram and a sequence diagram for the...
Instruction: Use Microsoft Visio to draw a use case diagram and a sequence diagram for the following business requirements. Online Recruiting System (website) 1) The Online Interview System: The search committee usually selects 3 to 5 candidates for a Skype interview. When the search committee starts a Skype interview, they connect their web browsers to an interview module developed by the company’s IT team (we call this type of software as home-developed software). The interview module then connects to Skype....
Instruction: Answer in a Word file and submit. Show the formula and all corresponding numbers you...
Instruction: Answer in a Word file and submit. Show the formula and all corresponding numbers you use in the formula. Do NOT use spreadsheet and submit. 1. (3 points)     You deposit your $10,000 in a new savings account that earn 4 % annually. You don’t take the interest out and keep it in the savings account so that you can earn interest on interest (compounding!). What would be the value of the $10,000 after 40 years? (Show your calculation) 2....
Instruction: when you do the frequency distribution use 10 classes. You can attach a pdf or...
Instruction: when you do the frequency distribution use 10 classes. You can attach a pdf or word document file. This is another similar question in determining normality (section 6.2). Each part worth 4 points. Question: The numbers of branches of the 50 top banks are shown below:    67 84 80 77 97 59 62 37 33 42 36 54 18 12 19 33 49 24 25 22 24 29 9 21    21 24 31 17 15 21 13...
Answer the following questions and upload to Canvas. Submit in Word or PDF format.  Show your work...
Answer the following questions and upload to Canvas. Submit in Word or PDF format.  Show your work and upload the Excel sheet as well. All the writing parts must be your original writing, don't quote, write in your own words. The following table presents the orders of Samson Company for the last 36 months (3 years). Month Order Year 1 Order Year 2 Order Year 3 January 502 614 712 February 408 592 698 March 491 584 686 April 456 532...
GIVEN THE FOLLOWING PSOSTFIX EXPRESSION, SHOW TO USE A STACK TO EVALUATE ITS FINAL VALUE. SHOW...
GIVEN THE FOLLOWING PSOSTFIX EXPRESSION, SHOW TO USE A STACK TO EVALUATE ITS FINAL VALUE. SHOW STACK CONFIGURATION DETAILS 20 3 18 8 - * 10 + +10 12 - /
. You must use Excel (submit either a pdf, word or Excel file only). . You...
. You must use Excel (submit either a pdf, word or Excel file only). . You must identify the 5 steps (you must address each in detail). Problem: Use the given data to complete a t-test using Excel. Question: Is there a difference in group means between the number of words spelled correctly for two groups of fourth graders? Group Assignment Score 1 3 1 4 1 10 2 14 2 7 2 8 2 10 2 15 2 9...
For the following molecules draw their lewis structure, show their orbital diagrams before and after hybridization,...
For the following molecules draw their lewis structure, show their orbital diagrams before and after hybridization, determine what hybrid orbitals are formed in the molecule, and label the bonds in the lewis structure as sigma or pi bonds CF2O CH3(CH)2CH3 C2N2 CH3CCH CHONH2
For the following molecules, draw their lewis structure,show their orbital diagrams before and after hybridization, determine...
For the following molecules, draw their lewis structure,show their orbital diagrams before and after hybridization, determine what hybrid orbitals are formed in the molecule, and label the bonds in the lewis structure as sigma or pi bonds SiH4 SF4 XeF4 C2H4 C2H2
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT