Question: Overview Develop an x86_64 assembly language program that uses a function and a loop to calculate values across an array. Procedure For this assignment you

Overview

Develop an x86_64 assembly language program that uses a function and a loop to calculate values across an array.

Procedure

For this assignment you must write all code in x86_64 assembly (but you may use/call C functions in your assembly code).

All code should be in one source file only (asm_program.asm)

Create a function which takes four 64-bit integer arguments (eg. W, X, Y, Z).

Your function should compute (W + X) * (Y - Z), and leave the result in RAX when it returns.

Your function should accept the four arguments using appropriate conventions (see registers listed in the lecture slides).

Your function should NOT print anything - it should ONLY perform the math, and return the result.

Use a loop to compute the above function over an array of size 16 (A[0], A[1], ..., A[15])

Declare an array (in memory) containing 16 reasonable 64-bit integer values (of your choosing).

Use a loop to iterate over the elements of the array, and use your function (above) to calculate the value of every four consecutivearray values.

For example, rax = (A[0] + A[1]) * (A[2] - A[3]), then rax = (A[1] + A[2]) * (A[3] - A[4]), etc.

For each iteration, print out the calculation, the result, and start a newline (exactly like this): (5 + 2) * (3 - 4) = -7

The last iteration should compute rax = (A[12] + A[13]) * (A[14] - A[15]) ... (i.e. don't calculate past the end of the array!)

Compile and link your code to make an executable (asm_program)

Use insightful comments in the code to illustrate what is happening at each step

Include a header with the relevant information for assignments as defined in the syllabus

Read the submission requirements in the syllabus before submitting your work for grading

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!