I am having a problem getting my Pep/8 assembly program to produce the correct output. The goal is to input a number n followed by n numbers and then have the output place the first number at the end of the array. An example of input and correct output is as follows:
"Three numbers of which 1,2, and 3 are in the array." Input: 3 1 2 3
"The first number in the array, 1, is placed at the end of the array." Correct Output: 2 3 1
My input and output are:
Input: 3 1 2 3 Incorrect Output: 2 2 1 Desired Output: 2 3 1
Input: 4 1 2 3 4 Incorrect Output: 2 3 3 1 Desired Output: 2 3 4 1
Input: 5 1 2 3 4 5 Incorrect Output: 2 3 3 4 1 Desired Output: 2 3 4 5 1
The three parts of my assembly code can be seen at: http://militarystudents.files.wordpress.com/2009/11/pic1of3.png http://militarystudents.files.wordpress.com/2009/11/pic2of3.png http://militarystudents.files.wordpress.com/2009/11/pic3of3.png
The output for n = 1 and n = 2 comes out correctly. For n > 2 the output seems to repeat a portion of my input. I am using a global array list. Any information will be greatly appreciated.