CSCI 463 Marie Assembler assignment 100 Points

Due 21 Oct 2005 Friday in drop box at start of class

Write a program that takes 8 one word unsigned integer numbers of 15-bit word size and sums them up. The programmer must handle the carry when the sum exceeds the size of the 15 bit number size.

The numbers will be stored in memory as an array of word values. Use the Jump to subroutine to set up a pointer to the start of the table. Then use the pointer to index through the table. I will provide examples on how to do this. Store and manipulate the values as hex values to more easily see what is happening.

Marie uses signed words and tests the high bit of a word to recognize a signed number. If you consider a word as a 15 bit unsigned number, you can use the high (sign) bit of the number as a carry flag.

This limits the value range of each word to 0 - 7fff or 0 - 32767. However, several words can be used together to store very large values.

 7FFF    0111 1111 1111 1111 b
+7FFF    0111 1111 1111 1111 b
-----    1111 1111 1111 1110 b or bit 15 = 1 and bits 14-0 = 7FFE 
 FFFE  

Using the sign bit as an indicator to increment the next significant word and then zeroing out the sign(carry) bit, the result can be represented in two words as

0001 7FFE

Data areas should contain :

Hard code the 8 15-bit word values into the program's data table area. Also set the 2 words of sum storage to zero and initialize a word to hold a counter (set to 8) to track how far through the table you are.

Algorithm:

Jump over data area and initialize pointer to table.

While table counter indicates more values in table
  Fetch and sum a value from table  (use add indirect)
  Test sum for overflow (negative value)
  If overflow
    Call overflow subroutine.

  Increment table pointer.
  Decrement table counter.
End

Terminate program

Overflow routine
   Add 1 to high sum word
   Clear high bit of current low sum word.
Return

Remember that there is only one work register, so it may be neccessary
to store the current contents before taking a new action.
DO doc your code. Also, show the work of converting your zid to the 15 bit binary and hex values on a separate piece of paper. Hand calculate the math on the numbers you have generated to confirm your progrm is functioning. You may find that summing the 1st 2 15-bit numbers in binary then adding each additional binary representation to the preceeding sum is the easiest.

Hand in your paperwork, a hard copy of the program along with the source code on floppy, and a printed dump of memory in Marie after execution. Circle and label the high and low words containing the sum.