uart to assembly language converter

Thread Starter

zakir waheed

Joined Nov 5, 2014
4
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
 

Attachments

joeyd999

Joined Jun 6, 2011
6,204
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
Are you urgently asking someone to rewrite your code for you?
 

JWHassler

Joined Sep 25, 2013
308
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
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 .
 

Thread Starter

zakir waheed

Joined Nov 5, 2014
4
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 .
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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
 

JWHassler

Joined Sep 25, 2013
308
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.
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:
_Send_Data:
[U]
;[/U]LED_Matrix_With_UART.c,35 ::         void Send_Data(unsigned short rw){
;LED_Matrix_With_UART.c,37 ::         for (num = 0; num < 5; num++) {
    CLRF       Send_Data_num_L0+0
L_Send_Data0:
    MOVLW      5
    SUBWF      Send_Data_num_L0+0, 0
    BTFSC      STATUS+0, 0
    GOTO       L_Send_Data1
;LED_Matrix_With_UART.c,38 ::         Mask = 0x01;
    MOVLW      1
    MOVWF      Send_Data_Mask_L0+0
;LED_Matrix_With_UART.c,39 ::         for (t=0; t<8; t++){
    CLRF       Send_Data_t_L0+0
L_Send_Data3:
    MOVLW      8
    SUBWF      Send_Data_t_L0+0, 0
    BTFSC      STATUS+0, 0
    GOTO       L_Send_Data4
;LED_Matrix_With_UART.c,40 ::         Flag = Buffer[rw][num] & Mask;
    MOVLW      5
    MOVWF      R0
    MOVLW      0
    MOVWF      R1
    MOVF       FARG_Send_Data_rw+0, 0
    MOVWF      R4
    CLRF       R5
    CALL       _Mul_16x16_U+0
    MOVLW      _Buffer+0
    ADDWF      R0, 1
    MOVLW      hi_addr(_Buffer+0)
    ADDWFC     R1, 1
    MOVF       Send_Data_num_L0+0, 0
    ADDWF      R0, 0
    MOVWF      FSR0L
    MOVLW      0
    ADDWFC     R1, 0
    MOVWF      FSR0H
    MOVF       Send_Data_Mask_L0+0, 0
    ANDWF      INDF0+0, 0
    MOVWF      R1
;LED_Matrix_With_UART.c,41 ::         if(Flag==0) Serial_Data = 0;
    MOVF       R1, 0
    XORLW      0
    BTFSS      STATUS+0, 2
    GOTO       L_Send_Data6
    BCF        RA0_bit+0, BitPos(RA0_bit+0)
    GOTO       L_Send_Data7
L_Send_Data6:
;LED_Matrix_With_UART.c,42 ::         else Serial_Data = 1;
    BSF        RA0_bit+0, BitPos(RA0_bit+0)
L_Send_Data7:
;LED_Matrix_With_UART.c,43 ::         SH_Clk = 1;
    BSF        RA1_bit+0, BitPos(RA1_bit+0)
;LED_Matrix_With_UART.c,44 ::         SH_Clk = 0;
    BCF        RA1_bit+0, BitPos(RA1_bit+0)
;LED_Matrix_With_UART.c,45 ::         Mask = Mask << 1;
    LSLF       Send_Data_Mask_L0+0, 1
;LED_Matrix_With_UART.c,39 ::         for (t=0; t<8; t++){
    INCF       Send_Data_t_L0+0, 1
;LED_Matrix_With_UART.c,46 ::         }
    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.
 

MaxHeadRoom

Joined Jul 18, 2013
30,558
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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:

MaxHeadRoom

Joined Jul 18, 2013
30,558
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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
 

JWHassler

Joined Sep 25, 2013
308
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
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.
 

Papabravo

Joined Feb 24, 2006
22,058
Are UARTS really that difficult to understand? I've probably done this at least once a year for the last 50.
 
Last edited:
Top