Spell Checker with HC11

Discussion in 'Programmer's Corner' started by FearTheNoFear, Mar 25, 2010.

  1. FearTheNoFear

    Thread Starter New Member

    Oct 28, 2009
    2
    0
    The title says it all. There are 10, 3 letter words in the dictionary. The recommended way is to use fcb directives to set up the dictionary and then set up a fcb for the word that needs to be checked. Use a rmb to allocate the return value (1 for a match, 0 for no match). There is going to be a subroutine with a loop. The subroutine will check the words letter by letter. If the first letter of the checkword isn't the same as the first letter in the dictionary, it will move on to the next word. If a letter matches with the checkword, move on to the next letter until you reach the end of the word. If the words match, return a 1. If there is a mismatch, then start over at the first letter of the next dictionary word.

    I'm not really sure how to start. How do I start it off with fcb directives? Would it need to be: fcb "bat",0 or should I just put the list in an array? There'll be other questions once I get to that part of the program. The assembler program that is being used is the THRSim11. It's for a class. If it was a calculator, I would understand what all is going on.
     
  2. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    fcb is Form Constant Byte -- it gets put into ROM. An array is not really needed, and because the words are all the same length, you do not need the terminal NUL (0). And because you are dealing with only 10 words, they do not need to be alphabetized -- you can do a simple sequential scan rather than a binary search.

    Write out what you want the program to do in pseudo-code -- which could be a high level language. Think of what you would do if you were given the problem in first or second grade. As adults we can scan and compare a lot faster, and would not really realize what we were doing.

    We would probably start by pointing one finger at the first word, and another at the first letter of the word to compare. Then we'd go letter by letter, comparing each of the letters. If there was a mismatch, we would go on to the next word, starting at the first letters, and repeat the comparison.

    You will also need to figure out what to do if a match occurs, or if no match occurs.

    Good luck,
    --Rich
     
  3. FearTheNoFear

    Thread Starter New Member

    Oct 28, 2009
    2
    0
    Ok, so I realize how to put the words in the dictionary and have it run through it. Now the question is how do I compare the letter while just changing one line? I could change all three "cmpa" like ops but it would be nice to change it in one line. I did find a list of what the letters mean in Hex, Dec and Oct as well as other characters (/ : ', etc.) at: www.asciitable.com .
     
    Last edited: Mar 28, 2010
  4. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    Check the assembler's manual. Rather than typing in "FCB $43, $41, $54" you should be able to type in "FCB 'CAT'".

    Next, create some pseudo-code, and post it here. Something like

    Code ( (Unknown Language)):
    1.  
    2. *  X = Dictionary
    3. *  Y = TestWord
    4. *  if X[0] == Y[0] then
    5. *    :
    6. *    :
    7.  
    The pseudo-code will allow you to think about your implementation, make it easier to see any logical errors, and makes dandy comments for your code.

    --Rich
     
Loading...