Homework Assignments for CSC 325

Spring 2005

 

 

 

Homework 1: See document CSC325-Homework1.doc

Write and test a program that outputs “This is my first assembly language program.” to the monitor.  Name it first.asm and place it in your class account in subfolder hw1.

 

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: Write a program naming it hw3.asm that does the following:

a.       Contains definitions for data types BYTE, WORD, and DWORD.

b.      Defines symbolic constants for the days of the week and initialize the constants to the days Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

c.       Displays all the variables created to the monitor with the appropriate message indicating the meaning of the data.

 

Homework 4:

Write a program to input x and output 2x2 - 3x + 9.  Name it hw4.asm.

 

Homework 5:

Write a program to input a, b, c, x and output ax2 + bx + c.  Name it hw5.asm.

 

Homework 6: Insert the following into your program (named hw6.asm):

            .data

            Uarray WORD 1000h, 2000h, 3000h, 4000h

            Sarray SWORD –1, -2, -3, -4

 

a.       Write instructions that use direct-offset addressing to display the four values in Uarray on the monitor with appropriate messages identifying the data.

b.      Write instructions that use direct-offset addressing to display the four values in Sarray on the monitor with appropriate messages identifying the data.

 

Homework 7:

Write a program (named hw7.asm) that uses a loop to input ten numbers from the keyboard into an array.  Use a loop to display the ten numbers with appropriate messages identifying the data.  Add the ten numbers and display the result with appropriate message.  Subtract the first five from the second five and display the result with the appropriate message.

 

Homework 8:

Write a program (named hw8.asm) that uses a loop to calculate the first seven values in the Fibonacci number sequence { 1,1,2,3,5,8,13 }.  Display the numbers on the monitor with the appropriate message.

 

Homework 9:

Write a program (named hw9.asm) that displays a single character in all possible combinations of foreground and background colors (16 * 16 = 256).  The colors are numbered 0 to 15, so you can use a nested loop to generate all possible combinations.

 

Homework 10:

Copy a String Backwards: Write a program (named hw10.asm) using the LOOP instruction with indirect addressing that inputs a string into source and copies the string from source to target, reversing the character order in the process.

 

Homework 11:

Simple Addition: Write a program (named hw11.asm) 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 12:

Write a program (named hw12.asm) that functions as a single Boolean calculator for 32-bit integers.  It should display a menu that asks the user to make a selection form the following list:

1.      x AND y

2.      x OR y

3.      NOT x

4.      x XOR y

5.      Exit program

 

Each selection should do the following:

1.      AND_op: Prompt the user for two hexadecimal integers.  AND them together and display the result in hexadecimal.

2.      OR_op: Prompt the user for two hexadecimal integers.  OR them together and display the result in hexadecimal.

3.      NOT_op: Prompt the user for a hexadecimal integer.  NOT the integer and display the results in hexadecimal.

4.      XOR_op: Prompt the user for two hexadecimal integers.  Exclusive-OR them together and display the result in hexadecimal.

5.      EXIT-op: Exit the program.