2. Given the following data declarations:
.DATA Alpha WORD 1Ah, 2Bh, 3Ch, 4CH, 5C00, 6D03, 7F1A SUM WORD ?
.CODE
;Write instructions that sum the odd elements of the array into AX and then save the resultant sum in the location SUM.
Alpha:
dw 1Ah, 2Bh, 3Ch, 4CH,
5C00h, 6D03h, 7F1Ah
SUM:
dw 0
s(dw*):
push
rbp
mov rbp, rsp
mov QWORD PTR [rbp-24], rdi
mov WORD PTR [rbp-2], 0
.L3:
cmp WORD PTR [rbp-2], 6
ja .L2
movzx eax,
WORD PTR [rbp-2]
lea rdx, [rax+rax]
mov rax, QWORD PTR [rbp-24]
add rax, rdx
movzx edx,
WORD PTR [rax]
movzx eax,
WORD PTR SUM[rip]
add eax, edx
mov WORD PTR SUM[rip], ax
add WORD PTR [rbp-2], 2
jmp .L3
.L2:
movzx eax,
WORD PTR SUM[rip]
pop rbp
ret
main:
push
rbp
mov rbp, rsp
sub rsp, 16
mov edi, OFFSET FLAT:Alpha
call
s(unsigned short*)
mov WORD PTR [rbp-2], ax
movzx eax,
WORD PTR [rbp-2]
mov WORD PTR SUM[rip], ax
mov eax, 0
leave
ret
2. Given the following data declarations: .DATA Alpha WORD 1Ah, 2Bh, 3Ch, 4CH, 5C00, 6D03, 7F1A...
QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...
using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...
Can someone solve number 5 using Matlab? In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1....
Assume the following declarations have been made in main(): int howmany; Scanner kb = new Scanner(System.in); Random r = new Random(); Write code to do the following: Use a while loop to prompt the user for how many numbers are to be entered. If the user does not enter a positive number (a number greater than 0), display a message saying the number must be positive and to try again. Store this value in the howmany variable. Declare an integer...
All solutions must have both code and data segments Write a sequence of assembly language instructions to subtract each entry of an array B of five two’s complement 16-bit binary integers from the corresponding entry of an array A of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4,...
csc 220 assembly 2. Use the following code below as a template and follow the instructions written in the comments Assume I have the following data segment written: data val1 BYTE 10h val2 WORD 8000h val3 DWORD OFFFFh val4 WORD 7FFFh :1. Write an instruction that increments val2. ;2. Write an instruction that subtracts val3 from EAX. ;3. Write instructions that subtract val4 from val2. .code ;Write your instructions here
Please help me! For Problem 1, 2 and 3: You are required to submit three .c files that contain the instructions that you have written to solve the following problems. Place the C source code to solve the first problem in a file called lab5a.c. Place the C source code to solve the second problem in a file called lab5b.c. And place the C source code to solve the third problem in a file called lab5c.c. Remember to include your...
Step 1. Write a program in assembly language (using macros) to print out the following messages on the screen [20 marks]: Hello, programmers! Welcome to the world of, Linux assembly programming! Step 2. Write a C function to passed two numbers to the function and calculate the sum of all the numbers between them (both inclusive). [50 marks] a. Make a version with for loop b. Make a version with while loop c. Make a version with do.. while loop...
The MIPS assembly program given here is expected to find the sum of elements in array "myArr. Even though the code is syntactically correct, there are four bugs because of which the program is not glving the required output. With the help of the line numbers given identify the bug. Write the line number where you find the bug and give how the correct statement to eliminate the corresponding logical error (10 points partial points given for partial correct answers)...
Question 2 In this question, you will read two data files that include integers into two different arrays – the same way we did in class (but we are doing to arrays here). Duplicates are ok. 1- After you read the data into the array (use one function that takes an int array and a dsize by reference just like we did in class, and call that from main to fill both arrays). 2- Include a printArray function so that...