Question

In: Computer Science

1. Explain what the loop is doing and what is the final value of AX after...

1. Explain what the loop is doing and what is the final value of AX after this code has been executed?

.data

word1 WORD 100h, 200h, 300h, 400h, 500h

.code

mov ESI, OFFSET [word1+8]

mov ECX, 2

mov EAX, 0

L1:

mov AX, [ESI]

add AX, 20h

sub ESI, 4

LOOP L1

2. Use the XCHG instruction to reorder the array from [134Fh, 2EA6H, 1234h, F0F0h] to [2EA6H, F0F0h, 1234h, 134Fh]: (Direct Addressing)

.data

array1 WORD 134Fh, 2EA6H, 1234h, F0F0h

.code

Solutions

Expert Solution

ANSWER:--

GIVEN THAT:--

1)

mov EDX,OFFSET word1+8

mov ECX,2

mov EAX,0

L1:

mov AX,[EDX]

add AX,20h

sub EDX,4

Loop L1

and

word1 WORD 100h,200h,300h,400h,500h

SO Value of Register AX would be 320h

METHOD--2:--

Step 1: Given program has two sections: data and code.

In data section, an array word1 of WORD type declared with 5 elements.

WORD is of 16-bit size, so each element of the array requires 2-bytes.

Step 2: In the code section,

ESI initialised with address of last element of the array word1. ( each element requires 2-bytes, so word1 is address of first element, word1+8 is address of last element).

ECX, which controls the loop initialised with 2. It means the loop will execute for 2 times.

EAX initialised with zero.

Step 3: Inside loop L1, AX initialised with element at ESI i.e. last element of word1, 500h.

add 20h to AX. AX = 500h + 20h = 520h

subtract 4 from ESI. ESI = ESI - 4 = points to third element of array word1.

goto loop L1 if ECX not zero.

Step 4: loop L1 executes as ECX is one.

mov AX, [ESI] will move 3rd element of array word1, 300h to AX.

add 20h to AX. AX = 300h + 20h = 320h

subtract 4 from ESI. ESI = points to first element of array word1

goto loop L1 if ECX in non-zero.

Step 5: As ECX is zero. Exit from the loop.

Hence the loop is accessing 5th element and adding 20h, updating ESI and then accessing 3rd element, adding 20h to it, updating ESI.

Final content of AX is 320h.


Related Solutions

What are the contents of the array after the for-loop in the following code?
(IN C)What are the contents of the array after the for-loop in the following code?int array[ SIZE ][ SIZE ] = { { 4, 5, 6, 7, 8 },{ 1, 2, 3, 4, 5 },{ 3, 6, 7, 8, 9 },{ 2, 3, 4, 5, 6 },{ 5, 6, 7, 8, 9 } };int i;int *ptr = array[ 0 ];for( i = 0; i < SIZE * SIZE; i++ ) {if( i % SIZE < 2 ) {*( ptr +...
Suppose 8086 microprocessor perform the following task: ADD AX, 3FF2H Where the value of AX is...
Suppose 8086 microprocessor perform the following task: ADD AX, 3FF2H Where the value of AX is 1D56H and ADD is opcode for addition (summation) Draw the flag register and calculate the values of status flags?
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project....
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project. The equipment originally cost $26 million, of which 90% has been depreciated. Karsted can sell the used equipment today for $6.5 million, and its tax rate is 35%. What is the equipment's after-tax salvage value? Round your answer to the nearest dollar. Write out your answer completely. For example, 13 million should be entered as 13,000,000.
After tax salvage value Kennedy Air Services is now in the final year of a project....
After tax salvage value Kennedy Air Services is now in the final year of a project. The equipment originally cost $25 million, of which 85% has been depreciated. Kennedy can sell the used equipment today for $6.25 million, and its tax rate is 35%. What is the equipment's after-tax salvage value? Round your answer to the nearest cent. Write out your answer completely. For example, 13 million should be entered as 13,000,000.
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project....
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project. The equipment originally cost $23 million, of which 80% has been depreciated. Karsted can sell the used equipment today for $5.75 million, and its tax rate is 40%. What is the equipment's after-tax salvage value? Round your answer to the nearest dollar. Write out your answer completely. For example, 13 million should be entered as 13,000,000. $ ________ 4. REPLACEMENT ANALYSIS The Oviedo Company...
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project....
AFTER TAX SALVAGE VALUE Karsted Air Services is now in the final year of a project. The equipment originally cost $27 million, of which 80% has been depreciated. Karsted can sell the used equipment today for $6.75 million, and its tax rate is 40%. What is the equipment's after-tax salvage value? Round your answer to the nearest dollar. Write out your answer completely. For example, 13 million should be entered as 13,000,000.
after doing ddb and finding that the book value of year five doesn't equal zero, how...
after doing ddb and finding that the book value of year five doesn't equal zero, how to switch to SL method? show all work
Re-write following while loop into Java statements that use a Do-while loop. Your final code should...
Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same output as the original code below. int total = 0; while(total<100) { System.out.println("you can still buy for"+(100-total)+"Dollars"); total=total+5; }
1. What will be the value of numbers[1] after the following code is executed? int[] numbers...
1. What will be the value of numbers[1] after the following code is executed? int[] numbers = {22, 33, 44}; for(int k = 0; k < 3; k++) { numbers[k] = numbers[k] + 5; } } 2. What will be the results of the following code? final int ARRAY_SIZE = 5; double[] x = new double[ARRAY_SIZE]; for(int i = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0; } 3.What is the value of numbers [3] after the following line...
Question 1: What is For Loop? Explain with 2 Examples. You can write code in any...
Question 1: What is For Loop? Explain with 2 Examples. You can write code in any programming language.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT