CS225,  Fall 2006,  Programs Hit reload!


PROGRAM 1 Assigned Friday Sept. 1, Day 4. Due Day 6 (Wednesday)   Due Day 7 (Friday) I hope.
Write a correct assembly language program which does this:  
Comments:  We are changing "types" on the data, from thinking of it as string data to thinking of it as word (2-byte) chunks.  I am deliberately trying to break down all your "type" assumptions from C++/Java, to show they don't exist at this level.
a) Uses an assembler directive  (dot command) to place the string Hi  into memory when the program is loaded.
b) On running, loads the two-bite string Hi into the A register.   Hint: two bites is a Word!  Use LD.
c)  Adds 6 to it.  (Where will you get the 6?  Store it in memory beforehand.)
d) Stores the Word result back in the location of the original string.
e) Outputs the two characters of the result.  (note, all we have for output so far is CHARO, so have to output the 2 bytes of the word separately.)
Run, Debug, Email me the source, Hand in the listing, and the output.   Tell if it worked, if not how not, who gave help on what.


Program 2, Due Monday Day 11. Wednesday Day 12. You can write it now. Write a program that will input 2 decimal numbers from the keyboard (or batch input), store them in memory locations, add them, store the result in a third location, and output the two numbers followed by their sum.
Check the flags after the Add.  Create 6 sets of legal input that will cover all the possibilities shown on p. 103; record your results and verify that the C flag detects overflow for unsigned addition, and the V flag detects overflow for signed addition.  (Note that the output will always be in signed values; to find the unsigned equivalent of a negative number, add 65536, or read the value off from the (dec) box in the CPU when the number is in the register.)   Hand in the listing, your 6 sets of input and their sums,  and the results of the C and V flag after each addition..


Program 3, Assigned Day 12,Wed. Sept. 20, Due Day 14, Monday, Sept. 25   Day 15, Wednesday, Sept. 27  Due Friday, Oct. 6 Prepare a stack frame long enough for two characters and a number, by moving the stack pointer to the top of the frame.   Input two characters followed by a decimal number,  pushing each one onto the stack, below the stack pointer.   Output the second character, then  the number, then the first character.  De-allocate the stack space by moving the stack pointer back to its original place.
Example input:  ab 100 produces output b100a.
Submit the listing with your input and output, and a memory changes template showing the changes in the stack pointer and the memory for all instructions that affect them.
Program 4, assigned day 13, Fri. Sept 22.  Due day 16,  Friday Sept 27.  Reassigned Day 19, Fri. Oct. 6.  Due Fri. Oct. 13. In program C you did integer division by 8.  What about the remainder?  (Sometimes called n mod 8; in C++ I think mod = %.  16 mod 8 = 0, 19 mod 8 = 3, 26 mod 8 = 2.   There are several ways to do this.  Here do it by being clever mathematically to begin with.   Find the remainders of some numbers on division by 8, and look at what is happening to them at the binary level. 
38D = 26H = 10 0110 Divide by 8; remainder =?  Repeat with other numbers.  Your algorithm doesn't need to work for division by anything but 8.

When you can see how to get easily from the number to the remainder, only then write the program.  (Bring the algorithm to class Wednesday.Hand in or email  code, hand in listing, hand in verbal description of the algorithm unless it's in clear comments in the program.
Remember, your algorithm doesn't have to be generalizable to any other number.  JUST good for 8.

Program 5,  assigned Day 21, Friday Oct 13, Due Wednesday Day 23, Oct 16
For loop: What will CHARO output?  Write a program.
  "Global" variable style is 0K.
    For j = 0 to 127 output j, a space, the character with that ascii number, a space, the character with that ascii number + 128, and line feed.
  Example:  for decimal 66, the output will be  66 B   <LF> 
Save your output file, open it in Word or equivalent, and print out the results for 30 up; describe any effects from values below 30 (you know hex 0A = 10D is the linefeed)
   Programming/debugging suggestions.   You should have done the output for a single j for Day 19, Problem A.  So now you just need to put it in a For loop.


Program 6, Assigned Wed. Day 23, Due Monday Day 25, Oct. 21
Create a program with procedures, no parameters, no local variables, no returned values .  Some procedure should call another (so you have calls nested 2 deep), and some  procedure should be called twice.  It should be a little different from the one at day 22.  Hand in the listing, output,  and a memory trace, showing which ops move the stack pointer, and what is on the stack inside/after each procedure call.


Program 7, Multiplication   Assigned Friday Day 24, Due Friday Day 27, Oct. 27.
Program specification:
 
The program should get 2 numbers from Batch input and multiply them, then output the result. 
  The algorithm should be the shift-and-add algorithm (multiplication).
Write the program to work for  input numbers > 0 and < 25510.   You do not need to check that the result is out of range (though it could print out as a negative number.  Why?).

You may write it with or without a function/procedure.  You may use global variables (direct addressing) or local (stack-relative), your choice. 
Create a suitable set of test data pairs, and submit the results from these as well as the listing.


Program 8, Assigned Day 27, Due Wed. Day 29, Nov. 1
Do #27, p. 323, in Warford.  Note hint on next page, which may or may not be useful, depending on how you choose to do it.

Program 9, assigned Day 28, Due Fri. Day 30, Nov. 3
 Interactive program.  Have the user input a number  0, 1, or 2, and print out a "fortune" for each case.  You may ignore the problem of screening for wrong responses.  Use a Jump table and BR with x mode.

To Sievers Home Page
CS225-Fall06/Programs.htm 
4pm, 10/2/06
This page belongs to Sally Sievers who is solely responsible for its content. Please see our statement of responsibility.