Homework Assignments for CSC 325

Spring 2003

 

 

 

Homework 1: See document CSC325-Homework1.doc

See document poly.htm for solution to poly.asm and another equation (quad.asm) to complete.

See document QUAD.txt for a template to do quad.asm.

 

Homework 2:

1.      The CPU contains registers and what other basic elements?

2.      Why does memory access take more machine cycles than register access?

3.      What are the three basic steps in the instruction execution cycle?

4.      During which stage of the instruction execution cycle is the program counter incremented?

5.      In a 5-stage single-pipeline processor, how many clock cycles would it take to execute 8 instructions?

6.      Which flag is set when an arithmetic or logical operation generates a negative result?

7.      Which part of the CPU performs floating-point arithmetic?

8.      Describe external cache memory.

9.      Of the three levels of input/output in a computer system, which is the most universal and portable?

10.  At which level(s) can an assembly language program manipulate input/output?

 

Homework 3:

 

Homework 4:

Subtracting Three Integers: Using the AddSub program from Section 3.2 as a reference, write a program that subtracts three 16-bit integers using only registers.  Insert a call DumpRegs statement to display the register values.

 

Homework 5:

 

Homework 6:

Copy a String Backwards: Write a program using the LOOP instruction with indirect addressing that copies a string from source to target, reversing the character order in the process.

 

Homework 7:

 

Homework 8:

Integer Array Input: Write a program that uses a loop to input ten signed 16-bit integers from the user, stores the integers in an array, and redisplays the integers.

 

Homework 9:

Simple Addition: Write a program that clears the screen, locates the cursor near the middle of the screen, prompts the user for two integers, adds the integers, and displays their sum.

 

Homework 10:

Test Score Evaluation: Using the following table as a guide, write a program that asks the user to enter an integer test score between 0 and 100.  The program should display the appropriate letter grade.

 

Score Range

Letter Grade

90 to 100

A

80 to 89

B

70 to 79

C

60 to 69

D

0 to 59

F

 

Homework 11:

Fast Multiplication: Write a procedure named FastMultiply that multiplies any unsigned 16-bit integer by EAX, using only shifting and addition.  Pass the integer to the procedure in the EBX register, and return the product in the EAX register.  Write a short test program that calls the procedure and displays the product.  Assume that the product is never larger than 16 bits.

 

Homework 12:

Nonrecursive Factorial: Write a nonrecursive version of Factorial procedure in Section 8.5.2 that uses a loop.  Write a short program that interactively tests your Factorial procedure.  Let the user ea value of n.  Display the calculated factorial.

 

Homework 13:

Sieve of Eratosthenes: The Sieve of Eratosthenes, invented by the Greek mathematician having the same name, provides a way to find all the prime numbers within a given range.  The algorithm involves creating an array of bytes in which positions are “marked” by inserting 1’s in the following manner:  Beginning with position 2 (which is a prime number), insert a 1 in each array position that is a multiple of 2.  Then do the same thing for multiples of 3, the next rime number.  Find the next prime number after 3, which is 5, and mark all positions that are multiples of 5.  Proceed in the same manner until all multiples of primes have been found.  The remaining positions of the array that are unmarked indicate which number s are prime.  For this program, crate a 31,000-element array and display all primes between 2 and 31,000.