uart to assembly language converter

Discussion in 'Embedded Systems and Microcontrollers' started by zakir waheed, Nov 5, 2014.

  1. zakir waheed

    Thread Starter New Member

    Nov 5, 2014
    4
    0
    I have a project " 8*40 LED MATRIX MARQUEE USING SHIFT REGISTERS". its source file is in 'uart'. I want to convert this program into assembly language. The source file and compiled hex file are attached.

    Kindly help me. urgent
     
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Are you urgently asking someone to rewrite your code for you?
     
  3. JWHassler

    Member

    Sep 25, 2013
    201
    33
    The C-file has been apparently been compiled and a disassembly produced. ("LED_Matrix_With_UART.asm")
    You're not going to get much more help than this disassembly provides.
    Don't know exactly why you need an assembly-file of this code, but if it is to finesse a homework assignment, you'll have to understand the code before it can be rewritten to appear to have been assembly-language from the start .
     
  4. zakir waheed

    Thread Starter New Member

    Nov 5, 2014
    4
    0
    Im using kiel and protius software in which I use assembly language. I dont understand 'uart'. I understand assembly language therefor I want to rewrite this code in assembly language.
     
  5. zakir waheed

    Thread Starter New Member

    Nov 5, 2014
    4
    0
    Im using kiel and protius software in which I use assembly language. I dont understand 'uart'. I understand assembly language therefor I want to rewrite this code in assembly language.
     
  6. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    It must be very obvious, but I am missing it.

    The .asm file looks like a typical MPASM (i.e., PIC) Assembly file, complete with comments. The comments make me think it is not a disassembly of a c file, nor does the nice formatting look like any disassembly listing I have seen -- albeit, I have seen very few.

    Have you tried compiling/building it with an appropriate header? You will have to sort out the defines and equates, but they seem obvious from the listing.

    John
     
  7. JWHassler

    Member

    Sep 25, 2013
    201
    33
    You already have 'uart' rewritten in assembly-language:' it's in the file "LED_Matrix_With_UART.asm," part of the .zip-file you originally posted.
    Here is a portion of it:
    Code (Text):
    1.  
    2. _Send_Data:
    3. [U]
    4. ;[/U]LED_Matrix_With_UART.c,35 ::         void Send_Data(unsigned short rw){
    5. ;LED_Matrix_With_UART.c,37 ::         for (num = 0; num < 5; num++) {
    6.     CLRF       Send_Data_num_L0+0
    7. L_Send_Data0:
    8.     MOVLW      5
    9.     SUBWF      Send_Data_num_L0+0, 0
    10.     BTFSC      STATUS+0, 0
    11.     GOTO       L_Send_Data1
    12. ;LED_Matrix_With_UART.c,38 ::         Mask = 0x01;
    13.     MOVLW      1
    14.     MOVWF      Send_Data_Mask_L0+0
    15. ;LED_Matrix_With_UART.c,39 ::         for (t=0; t<8; t++){
    16.     CLRF       Send_Data_t_L0+0
    17. L_Send_Data3:
    18.     MOVLW      8
    19.     SUBWF      Send_Data_t_L0+0, 0
    20.     BTFSC      STATUS+0, 0
    21.     GOTO       L_Send_Data4
    22. ;LED_Matrix_With_UART.c,40 ::         Flag = Buffer[rw][num] & Mask;
    23.     MOVLW      5
    24.     MOVWF      R0
    25.     MOVLW      0
    26.     MOVWF      R1
    27.     MOVF       FARG_Send_Data_rw+0, 0
    28.     MOVWF      R4
    29.     CLRF       R5
    30.     CALL       _Mul_16x16_U+0
    31.     MOVLW      _Buffer+0
    32.     ADDWF      R0, 1
    33.     MOVLW      hi_addr(_Buffer+0)
    34.     ADDWFC     R1, 1
    35.     MOVF       Send_Data_num_L0+0, 0
    36.     ADDWF      R0, 0
    37.     MOVWF      FSR0L
    38.     MOVLW      0
    39.     ADDWFC     R1, 0
    40.     MOVWF      FSR0H
    41.     MOVF       Send_Data_Mask_L0+0, 0
    42.     ANDWF      INDF0+0, 0
    43.     MOVWF      R1
    44. ;LED_Matrix_With_UART.c,41 ::         if(Flag==0) Serial_Data = 0;
    45.     MOVF       R1, 0
    46.     XORLW      0
    47.     BTFSS      STATUS+0, 2
    48.     GOTO       L_Send_Data6
    49.     BCF        RA0_bit+0, BitPos(RA0_bit+0)
    50.     GOTO       L_Send_Data7
    51. L_Send_Data6:
    52. ;LED_Matrix_With_UART.c,42 ::         else Serial_Data = 1;
    53.     BSF        RA0_bit+0, BitPos(RA0_bit+0)
    54. L_Send_Data7:
    55. ;LED_Matrix_With_UART.c,43 ::         SH_Clk = 1;
    56.     BSF        RA1_bit+0, BitPos(RA1_bit+0)
    57. ;LED_Matrix_With_UART.c,44 ::         SH_Clk = 0;
    58.     BCF        RA1_bit+0, BitPos(RA1_bit+0)
    59. ;LED_Matrix_With_UART.c,45 ::         Mask = Mask << 1;
    60.     LSLF       Send_Data_Mask_L0+0, 1
    61. ;LED_Matrix_With_UART.c,39 ::         for (t=0; t<8; t++){
    62.     INCF       Send_Data_t_L0+0, 1
    63. ;LED_Matrix_With_UART.c,46 ::         }
    64.     GOTO       L_Send_Data3
    That code is assembly-language: it is also interspersed with comments in the form of the C-code from which it was compiled.
    I believe that this is the best you can hope for: nobody will write this for you.
     
  8. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    What about 'uart' do you not understand?
     
  9. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Or, he could learn 'uart'.
     
  10. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    I would write it for him if he paid me enough, but I don't work cheap.
     
  11. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,542
    2,369
    I suggest you read up on what exactly a Usart/Uart (serial transmission standard) is and how it is implemented using either an output by using a 'bit-banging' method or a details of the Usart module in the processor chosen, if it has this feature.
    Max.
     
  12. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    I checked for a few things I would expect in an EUSART routine (based on the c code header), such as interrupt, RCREG, RCSTA, banksel/movlb, etc. and did not find them in that assembly code. There is a 1-second delay that works out to be about right for a 32 MHz processor, but I wonder if that assembly code is really the complete assembly for the c code that is posted?

    If that is the case, then maybe this question is really about how to convert a program in c to one in MPASM assembly.

    John

    PS: I do wish when a poster takes an extensive amount of code from somewhere else and posts it here, or any copyrighted material for that matter, that they would give the source.
     
    Last edited: Nov 6, 2014
  13. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,542
    2,369
    And either way, the bit-bang method or a included microcontroller module, the code would normally be very much shorter for either than shown?
    Max.
     
  14. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    I revisited the code and noticed something odd that might explain the lack of bank changes. For example, CLRF TRISB is actually CLRF TRISB+0. Similarly, operations on RCSTA are simply <instruction> RCSTA+0, and so forth. Suspecting that "+0" might be an assembler directive, I tested that syntax with MPLAB 8.92, and it didn't work. That is, the program compiled fine, but the simulation didn't clear or set bits in the register as one intended, unless the correct Bank was set. However, the TS is using Keil and Proteus. That may be a directive they recognize. (I don't know why my earlier search didn't find RCSTA, it is there as RCSTA+0.)

    John
     
  15. JWHassler

    Member

    Sep 25, 2013
    201
    33
    The file "LED_Matrix_With_UART.lst" has been converted into a pseudo-assembly version "LED_Matrix_With_UART.asm", but lost all 122 of its 'MOVLB' instructions in the process! It might assemble, but it won't work, as everything will happen in bank zero.

    I withdraw what I said earlier about the OP having any hope of using it: I sure wouldn't, and I've disassembled lots of code.
     
    jpanhalt likes this.
  16. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Are UARTS really that difficult to understand? I've probably done this at least once a year for the last 50.
     
    Last edited: Nov 6, 2014
  17. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
  18. zakir waheed

    Thread Starter New Member

    Nov 5, 2014
    4
    0
    My friend done it for me. And Thanks to all of you.
     
Loading...