Subject Computer Science Assembly Language Programming


1. Exercise the integration of C and ASM modules
2. Apply control and logical instructions
3. Understanding abstract specifications
4. Design and implementation schemes

A typical code implementation approach is addressed in three stages: input, processing, and output.
Input stage. In this stage, I/O code is written to access data from the user (using the keyboard), from an input file, or a database.
Procesing stage. This stage transforms data by applying a mapping procedure specified via an algorithm or a set of equations.
Output stage. Some, or all the data that is transformed, is saved back into an output file, a database, or simply displayed at the user request.

This assignment seeks to apply the three-stage implementation approach by writing the assembly code that generates the output of the mod function in two different ways in two different modules:
Use a C main program to do I/O and to call your assembly modules as needed. Design an experiment based on a loop similar to the following:
For k = 2 to k=25 {
n = 4´k
m = k
call your module for equation (1)
call your module for equation (2)
Display your results as follows: k, m, n, value v from eqn 1, value v from eqn. 2

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>

// Extern asm functions
int mod1(int m, int n);
int mod2(int m, int n);

// Main function
int main()
// Variables
int k; // loop variable
int m; // dividend
int n; // divisor
int v1; // result of mod1
int v2; // result of mod2

// Loop from 2 to 25
for (k = 2; k <= 25; k++)
n = 4 * k; // divisor is 4 times k
m = k; // dividend is k
v1 = mod1(m, n); // calculate mod1
v2 = mod2(m, n); // calculate mod2
printf("%d %d %d %d %d\n", k, m, n, v1, v2); // print the result in a line
return 0;

This is only a preview of the solution. Please use the purchase button to see the entire solution


or free if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats