Motorolla MC68HC11 Microcontroller BCD to ASCII converter.

Discussion in 'Homework Help' started by NiCeBoY, Aug 26, 2008.

  1. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
    Hello..,,
    Can anyone show me how to write this program please?..

    I have programmed program for Addition,substraction,multiplication,division and branching.. but this one i dont know how to start and what to do...


    Thank you all in advance for your help..

    Regards..
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    What software programming language are you using?

    hgmjr
     
  3. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
    Hello,
    i have attached an example of a program i did before as an example(microl04.zip)

    micro04.zip contain:
    pf32.exe - i use to write codes,
    SIMF1 - i used to simulate
    AS11.exe i use to compile from dos by using the command:
    AS11 filename.asm -L

    Thx mate..
     
  4. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I have moved this thread to the Homework Section as that is clearly where it appears to belong.

    hgmjr
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Code ( (Unknown Language)):
    1.  
    2. START ORG $2050
    3. TABLE DB 32,0,50,0,72,0,86,0,104,0,125,0,176,0,212
    4. counter equ $2080 ;loop counter
    5. org $2000
    6. ldaa #8
    7. staa counter ;init counter
    8. LDY #$2050 ;Init data pointer
    9. CONVERT LDAA 0,Y
    10. SUBA #32
    11. LDAB #5
    12. MUL
    13. LDX #9
    14. IDIV
    15. STX $10,y
    16.  
    17. INY ;Increment Data Pointer
    18. INY ;Increment Data Pointer Twice
    19. dec counter
    20. BNE CONVERT
    21. bra *
    22.  
    I have reposted your source code using the CODE tags.

    hgmjr
     
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    By the way, is it safe to assume that AccA in your opening post refers to accummulator A?

    hgmjr
     
  8. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
    yes AccA refers to Accumulator A..
    thx..
     
  9. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    BCD digits represent the decimal numbers 0 through 9, using four bits. They are 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001.
    The ASCII codes for the characters '0' through '9' are 48 through 57 in decimal, or 0x30 through 0x39 in hex.
    To convert a BCD number in the lower nibble of AccA, you need to do two things:
    1. Mask off the upper nibble of AccA (by ANDing it with 0x0F).
    2. Add 0x30 to what's in AccA.
    After that, save the contents of AccA to whatever memory location you're using.

    The steps above assume that the caller to your module passes an actual BCD digit in AccA. You could add logic to guarantee that what is passed is a BCD digit by checking that the low nibble is greater than or equal to 0 and less than or equal to 9. (This test would come before step 1, above.) Since your problem statement says that the caller will pass a BCD digit, you shouldn't need to do this test, but it's something to think about.

    Hope that helps,
    Mark
     
  10. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
    hmm... I understand what we should do.. but the problem is how to code it...


    Can anyone help me out with the code plz..?

    thx
     
  11. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Another approach that is used is this one.

    1. Define a table that contains the 16 ASCII values for the digits 0 through 9 and A through F.
    2. Use a lower nibble mask and add the resulting masked value as an offset into the table to fetch the ASCII value needed. For the upper digit, use an upper nibble mask together with a right-shift four bit positions. Then use the resulting value as an offset into the table to fetch the ASCII value needed.

    hgmjr
     
  12. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    NiCeBoY,
    You produced the code above. Have you tried it out? Why are you asking for more help?
     
  13. NiCeBoY

    Thread Starter Active Member

    Aug 20, 2008
    59
    0
    Yes man i tried this code... but the LECTURER told me this is not enough.. and is nothing compare to what he is expecting...

    Then i showed his the steps that you gave me..
    he told me this is what is need.. that is you are good..
    But the problem is how to write the codes :(
     
  14. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    How to write the codes for what? You need to ask him to give you a clue about what he is expecting. There is no way to write the code if you don't know what it's supposed to do. The code I gave you should be sufficient for the requirements you gave in your first post. The only thing that might possibly be lacking is that the lecturer asked for a module, which suggests to me a subroutine or procedure, or whatever it might be called in 68HC11 assembly.
     
Loading...