Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - assign-02-asm.docx CS 5463/ XXXXXXXXXX CS 5463: Fundamentals of Systems – Programming Assignment 1 (50 points) Description and Requirements: This assignment has two parts. In Part I,...

1 answer below »
Microsoft Word - assign-02-asm.docx
CS 5463/ XXXXXXXXXX

CS 5463: Fundamentals of Systems – Programming Assignment 1 (50 points)

Description and Requirements: This assignment has two parts.

In Part I, you will write two functions in C, void swap (int*, int*) and int sum (int, int),
in separate files cSwap.c and cSum.c, respectively. The main function in another C file cAssign2.c will
declare and initialize necessary variables and call these two functions. You need to compile the two functions
into assembly codes and study them by adding necessary comments at the end of each line of code.

In Part II: you will need to implement the following two functions using IA32 assembly language (as we
discussed in classes) in two different assembly files.
1) In asmMagicSum.s file, write a function that will take two integers as parameters and return the
sum of 2*v1 and v2/2, where the function prototype in C will be: int magicSum (int v1,
int v2);
2) In asmMajicSwap.s file, write a function that will take two integer pointers as parameters and
swap their modified values where the first value plus 1 and second value minus 1. The function
prototype in C will be: void magicSwap (int *p1, int *p2).

You should add comments for each line of assembly code in the .s file, using #comment or /* comment */

In addition, the main function in a C file asmAssign2.c needs to be implemented, which should declare a
few variables with initial values, and call the above two functions and print out messages to show the affects of
the function calls.

Here, you will need to separately compile the two functions and the main program in object codes first as
elow, before link them together to be an executable program.

as -c asmMagicSum.s -o asmMagicSum.o
as -c asmMagicSwap.s -o asmMagicSwap.o
gcc -c asmAssign2.c -o asmAssign2.o
gcc main.o asmMagicSum.o asmMagicSwap.o -o asmAssign2

Note: you need to work out this assignment on henXX.cs.utsa
.net ; where XX can be 01, 02, 03, or 04

What and how to submit:

First, you should write a text Readme file to describe the status of this assignment (completed, or partial done
etc.), and clearly show the steps to compile and run the program.

Then, you should compress all files (.s and .c) and Readme into a zip file, which should have the name as:
LastName-FirstName-abc123-assignment02.zip (or tar.gz).

You need to submit the above compressed file on Blackboard.

Dakai Zhu
You need to use direct IPs to access hen machines: XXXXXXXXXX214
Answered 1 days After Mar 18, 2021

Solution

Vinayak answered on Mar 19 2021
137 Votes
Assignment/cswap.c
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
popl %ebp
et
Assignment/asmAssign2.c

int a, b;
a = 10;
b = 8;
printf("%d %d\n", a, b);
cswap(&a, &b);
swap the values stored in a and
printf("%d %d\n", a, b);
int sum = csum(&a,&b)
printf("%d",sum)
Assignment/csum.c
suma:
push %esi
push %edi
xor %esi, %esi ;Clear %edi:%esi
xor %edi, %edi
sub $1, %ecx ;Start at last element in a
ay
jl ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here