Computer Science 281
Computer Organization

Denison
CS281 Homework 3


Homework 3: Assembly Language Programs I

Be sure and use good commenting practices relating the high level program to the assembly language code.

Problem 1 : Expression Evaluation

Write an assembly language program to compute:

y = (a + b) * (a - b) / c;

where a = 17, b = -3, and c = 3. The variables a, b, c, and y should all be defined in the data segment and by the end of the program, the result should be stored in memory in y and also should be written to the console with an appropriate message.

Problem 2 : Integer Array Processing

Write an assembly language program that defines an array of 20 integers initialized with values in the global data segment and then performs the following processing:

 

Problem 3 : Square Root

Write an assembly language program to find the square root of a number y=sqrt(x), say for x = 1000, using the Newton Raphson method outlined below:

do {

old = y;
dx = x - y * y;
y = y + dx / 2y;

} while ( y != old )