1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with SDK6800 program

Discussion in 'Assembly Language Programming (ALP) Forum' started by ezioduong77, Jan 22, 2016.

  1. ezioduong77

    ezioduong77 New Member

    Jan 22, 2016
    Likes Received:
    Trophy Points:
    So my teacher gave this question on class today. Anyone have any idea how to do it?

    Create a 6800 program which removes all duplicate values in an array (in place).
    For example, suppose your program stores the following (zero terminated) array:
    dataArr .byte 1,1,2,3,4,5,1,2,3,4,5,6,7,0
    In this example, after your program executes, it should remove all duplicates.
    Therefore the output array will look like this: dataArr2 .byte 1,2,3,4,5,6,7,0 You are allowed to use a second array to store the output.
    Your program should work for all arbitrary arrays. :D:D
  2. xpi0t0s

    xpi0t0s Mentor

    Aug 6, 2004
    Likes Received:
    Trophy Points:
    Senior Support Engineer
    A fairly simple approach is to check each entry of the array in order, then to check all entries after that for a duplicate, and if you find one to remove the duplicate and close up the gap.

    So we would start with 1,1,2,3,4,5,1,2,3,4,5,6,7,0 and look at the first entry, which is 1. Loop from the 2nd to the end, and we find another 1 in the 2nd place, so remove it and close the gap, giving 1,2,3,4,5,1,2,3,4,5,6,7,0. Remember not to increment the inner loop if you have removed a duplicate.

    Continuing the inner loop we find another 1 a bit later, so remove it and the array becomes 1,2,3,4,5,2,3,4,5,6,7,0.

    The inner loop thus ends and the outer loop moves onto the next one which is the first 2. Inner loop starts again and again we find a duplicate 2, so the array now becomes 1,2,3,4,5,3,4,5,6,7,0. No more 2's and the inner loop completes.

Share This Page