Question

In: Computer Science

Please do both questions in MASM and complete these two in two separate files. 3. Summing...

Please do both questions in MASM and complete these two in two separate files.

3. Summing the Gaps between Array Values

Write a program with an indexed addressing that calculates the sum of all the gaps between successive array elements. The array elements are doublewords, sequenced in nonde- creasing order. So, for example, the array {0, 2, 5, 9, 10} has gaps of 2, 3, 4, and 1, whose sum equals 10.

     4. Copying a Word Array to a DoubleWord array

Write a program that uses a loop to copy all the elements from an unsigned Word (16-bit) array into an unsigned doubleword (32-bit) array.

Solutions

Expert Solution

Write a program with an indexed addressing that calculates the sum of all the gaps between successive array elements. The array elements are doublewords, sequenced in nonde- creasing order. So, for example, the array {0, 2, 5, 9, 10} has gaps of 2, 3, 4, and 1, whose sum equals 10.

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.data
array DWORD 0,2,5,9,10         //initializing the array
result DWORD 0          //initializing the result element
.code
main PROC      // main process starts

mov ECX, LENGTHOF array                             //store the length of array in ECX
mov ESI, OFFSET array                         //this stores the address of the array in ESI

L1:
MOV EAX,[ESI]           //move value of ESI to EAX
MOV EBX,[ESI+4]                    //add 4 to ESI and move the value to EBX
SUB EBX,EAX              //subtracting the value of EAX from EBX and storing the result in EBX
ADD result,EBX           // adding EBX with result and storing the value in result
ADD ESI, TYPE array               // moves pointer to next array element
Loop L1            //loop the whole process

INVOKE ExitProcess,0
main ENDP      //end process
END main         //end of program

Write a program that uses a loop to copy all the elements from an unsigned Word (16-bit) array into an unsigned doubleword (32-bit) array.

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.data
array WORD 0,2,5,9,10             //initializing the array
newArray DWORD LENGTHOF array DUP(?)
.code
main PROC      // main process starts

mov ECX, LENGTHOF array                              //store the length of array in ECX
mov ESI, OFFSET array                         //this stores the address of the array in ESI
mov EDI, OFFSET newArray               //this stores the address of the new array in EDI

L1:
MOV EAX,0                   //move value of 0 to EAX
MOV AX,[ESI]              //move value of ESI to EAX
MOV [EDI], EAX         //move adress of EAX to EDI
ADD ESI, TYPE array               // moves pointer to next array element
ADD EDI, TYPE newArray                     // moves pointer to next newarray element
Loop L1            //loop the whole process

INVOKE ExitProcess,0
main ENDP      //end process
END main         //end of program


Related Solutions

Please complete both questions in MASM. Explain code clearly, thank you. Please screenshot memory outputs. Symbolic...
Please complete both questions in MASM. Explain code clearly, thank you. Please screenshot memory outputs. Symbolic Text Constants Write a program that defines symbolic names for several string literals (characters between quotes). Use each symbolic name in a variable definition. Use this code to get started: ; Symbolic Text Constants Comment ! Description: Write a program that defines symbolic names for several string literals (characters between quotes). Use each symbolic name in a variable definition. ! .386 .model flat,stdcall .stack...
There are two programming questions for you to do. Please submit two.s or .asm files. You...
There are two programming questions for you to do. Please submit two.s or .asm files. You can use the usual settings as the previous homework. But if you want to use pseudo-instructions, you will need to uncheck "Bare Machine" and check "Accept Pseudo Instructions" (10 points) Declare an array of integers, something like: . data size : . word 8 array : . word 23 , -12 , 45 , -32 , 52 , -72 , 8 , 13 Write...
two separate questions and I need two separate answers please... 1-Separation of the fly embryo into...
two separate questions and I need two separate answers please... 1-Separation of the fly embryo into segments and separation of neuroblasts into different types are both dependent on transcriptional cascades. What is a transcriptional cascade (1 sentence)? Explain what is different (conceptually) in the transcriptional cascades in the two developmental scenarios (1 sentence). 2) In your opinion, is lateral inhibition similar or different from induction? State and support your argument in 1-2 sentences.
3. Translate the following C code to MIPS assembly code (in two separate files). int main()...
3. Translate the following C code to MIPS assembly code (in two separate files). int main() { printf(“before subroutine!\n”); Subfunc(); printf(“after subroutine!\n!”); } void Subfunc() {printf(“I am subroutine!\n”);} Submission file: Lab4_3a.asm for the main routine and Lab4_3b.asm for the sub-routine.
3. Translate the following C code to MIPS assembly code (in two separate files). int main()...
3. Translate the following C code to MIPS assembly code (in two separate files). int main() { printf(“before subroutine!\n”); Subfunc(); printf(“after subroutine!\n!”); } void Subfunc() {printf(“I am subroutine!\n”);} 4. Translate the following C code to MIPS assembly (in two separate files). Run the program step by step and observe the order of instructions being executed and the value of $sp. int main() { int x=2; z=Subfunc(x); printf(“Value of z is: %d”, z); } int Subfunc(int x) { return x+1;}
Please complete in MASM (x86 assembly language). Use the code below to get started. Use a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Use a loop with indirect or indexed addressing to reverse the elements of an integer array in place. Do not copy the elements to any other array. Use the SIZEOF, TYPE, and LENGTHOF operators to make the program as flexible as possible if the array size and type should be changed in the future. .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your...
Complete the following task in C++. Separate your class into header and cpp files. You can...
Complete the following task in C++. Separate your class into header and cpp files. You can only useiostream, string and sstream. Create a main.cpp file to test your code thoroughly. Given : commodity.h and commodity.cpp here -> https://www.chegg.com/homework-help/questions-and-answers/31-commodity-request-presented-two-diagrams-depicting-commodity-request-classes-form-basic-q39578118?trackid=uF_YZqoK Create : locomotive.h, locomotive.cpp, main.cpp Locomotive Class Hierarchy Presented here will be a class diagram depicting the nature of the class hierarchy formed between a parent locomotive class and its children, the two kinds of specic trains operated. The relationship is a...
Complete the following task in C++. Separate your class into header and cpp files. You can...
Complete the following task in C++. Separate your class into header and cpp files. You can only use iostream, string and sstream. Create a main.cpp file to test your code thoroughly. Given : commodity.h and commodity.cpp here -> https://www.chegg.com/homework-help/questions-and-answers/31-commodity-request-presented-two-diagrams-depicting-commodity-request-classes-form-basic-q39578118?trackid=uF_YZqoK Given : locomotive.h, locomotive.cpp, main.cpp -> https://www.chegg.com/homework-help/questions-and-answers/complete-following-task-c--separate-class-header-cpp-files-useiostream-string-sstream-crea-q39733428 Create : DieselElectric.cpp DieselElectric.h DieselElectric dieselElectric -fuelSupply:int --------------------------- +getSupply():int +setSupply(s:int):void +dieselElectric(f:int) +~dieselElectric() +generateID():string +calculateRange():double The class variables are as follows: fuelSuppply: The fuel supply of the train in terms of a number of kilolitres...
3. If one or both testes do not complete the migration into the scrotum and remain...
3. If one or both testes do not complete the migration into the scrotum and remain in the abdominal cavity, they must be surgically moved into the scrotum. If the testes remain in the abdominal cavity, the individual will become sterile. Explain why.
PLEASE DO IN JAVA AND USING REPL.IT Below are the two files, boysNames.txt and GirlsNames.txt Write...
PLEASE DO IN JAVA AND USING REPL.IT Below are the two files, boysNames.txt and GirlsNames.txt Write a program that reads the contents of the two files into two separate arrays, or ArrayLists. The user should be able to enter a boy’s name, a girl’s name, or both, and the application will display messages indicating whether the names were among the most popular. BoyNames: Jacob Michael Joshua Matthew Daniel Christopher Andrew Ethan Joseph William Anthony David Alexander Nicholas Ryan Tyler James...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT