Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an assembly language program in x86?64 assembly language. Add comments to code. PROBLEM: Write an assembly language program with four procedures or functions using

Write an assembly language program in x86?64 assembly language. Add comments to code.

PROBLEM:

Write an assembly language program with four procedures or functions using x86?64.

The program should have 2 64?bit arrays, defined in the data section of the program,

QArray1 and QArray2 both of which have a maximum size of 10 elements.

A C?type declaration of these arrays would be:

long QArray1[10];

long QArray2[10];

These arrays should be set up as static variables which are stored on the heap. This

means that they are initialized to zero. Do not change any of these labels in the data

section (case matters!).

Required data section:

.data

QArray1:

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

QArray2:

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

.quad 0

PROGRAMS:

Your program must have four procedures/functions, with the labels main, readArrays,

printQArray, and printIntSquares (Do not change these: case matters!).

You need to write the main procedure to call the other three procedures at

appropriate points, and with the appropriate parameters in registers to pass to the

procedures, so that they do what is described below. You are allowed to do other work in

main to get parameter values to pass to the procedures before you call them, but NO OUTPUT SHOULD BE PRINTED FROM main.

The readArrays procedure will populate QArray1 and QArray2 with values:

To populate values in each of these arrays, using the readArrays() function, you will

open a local file named Lab_5_Input which will contain the following information:

Line 1 will indicate the number of array values (some number between 1

and 10, inclusive) that should be put in each array. (i.e.count)

Lines 2 through 2+ will contain the values to save in QArray1

Lines 2+ through 2* +1 will contain the values to save in

QArray2

The readArrays() function will return count to main().

readArrays will have to use fopen(), fscanf() and fclose() to complete its job.

The printQArray procedure will be called twice from main(): the first time with the size

of the arrays, the address to QArray1 and an address to a string literal that says

Elements in QArray1 . The function should then print each 8?byte value in the array

in order on a separate line with a blank line following all of the values in the array. The

second time that the function is called, it should be passed the size of the arrays, the

address to QArray2 and an address to a string literal that says Elements in QArray2 ,

then printing each of the values in QArray2.

The printIntSquares() function will also be called twice from main(): the first time with

the size of the arrays, the address to QArray1 and an address to a string literal that says 2?

byte Squares in QArray1 ; the second time with the size of the arrays, the address of

QArray2 and an address to a string literal that says 2?byte Squares in QArray2 .

The printIntSquares() function will read an 8?byte element from an array, then multiply the

value by itself. After the multiplication, printIntSquares() will determine whether or not

the product will fit in a 2?byte integer value. If so, then printIntSquares() should print out

the value. If the product will not fit in a 2?byte integer, printIntSquares() should print out

the string overflow rather than a number.

CONSTRAINTS:

To pass values to procedures, you must use registers. You cannot pass parameters on

the stack.

You should also follow the x86?64 conventions as specified in the X86 slides, conventions

related to caller and callee save registers, caller cleanup, and returning values from

procedures in register rax.

Remember that you need to put format strings in read only memory in order to call

printf to print output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

an element of formality in the workplace between different levels;

Answered: 1 week ago