Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Change assembly code to C for PIC 16F877A

Status
Not open for further replies.

avais20

Newbie level 4
Joined
Sep 16, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,339
Hi,
i trying to drive a holtek 1621 based lcd.

Can some one help change this code to c for PIC16f877A or assembly .


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
void ht1621_setNum(uchar value, uchar num) {
        // Write on LCD the digit VALUE at position NUM 
        // VALUE should be a digit [0-9] or a bitmask (corresponding to A,b,C,c,...)
        if (value<=9) {
                romchar=ht1621_charTable[value];
        } else {
                romchar=value;
        }
        //ptr=ht1621_data+ht1621_addrNumBC[num];
        //*ptr&=~3;
        //*ptr|=(romchar&3);
#asm
        clr __bp
        mov a,ht1621_setNum1;  num
        add a,OFFSET _ht1621_addrNumBC
        call OFFSET _ht1621_addrNumBC-1
        add a,OFFSET _ht1621_data
        mov __mp0,a
        mov a,__iar0
        and a,0ch
        mov __iar0,a
        mov a,_romchar
        and a,3
        orm a,__iar0
#endasm
 
        _rr(&romchar);
        _rr(&romchar);
        //ptr=ht1621_data+ht1621_addrNumADG[num];
        //*ptr&=~7;
        //*ptr|=romchar&7;
#asm
        mov a,ht1621_setNum1;  num
        add a,OFFSET _ht1621_addrNumADG
        call OFFSET _ht1621_addrNumADG-1
        add a,OFFSET _ht1621_data
        mov __mp0,a
        mov a,__iar0
        and a,8
        mov __iar0,a
        mov a,_romchar
        and a,7
        orm a,__iar0
#endasm
 
        _rr(&romchar);
        _rr(&romchar);
        _rr(&romchar);
        //ptr=ht1621_data+ht1621_addrNumEF[num];
        //*ptr&=~3;
        //*ptr|=(romchar&3);
#asm
        mov a,ht1621_setNum1;  num
        add a,OFFSET _ht1621_addrNumEF
        call OFFSET _ht1621_addrNumEF-1
        add a,OFFSET _ht1621_data
        mov __mp0,a
        mov a,__iar0
        and a,0ch
        mov __iar0,a
        mov a,_romchar
        and a,3
        orm a,__iar0
#endasm
}

 
Last edited by a moderator:

I think the answer to that is NO!
It isn't complete assembly language, it looks like a disassembly of existing 'C' code but without knowing what the other label addresses are and what they refer to in real life, it isn't possible to convert it back again.

Why not use generic 'C' code to drive the LCD, I think the 1621 uses a standard HD44780 interface IC. There are thousands of examples on the internet.

Brian.
 

I am sure from the code in post #1 that it uses inline assembly for PIC and is written in old IAR EW PIC Compiler. That compiler is not available anymore and there are no documents related to that Compiler to study about its inline asm coding method to port your code to a different Compiler.
 

I am sure from the code in post #1 that it uses inline assembly for PIC and is written in old IAR EW PIC Compile
Looks more like high level code passed through a disassembler to me. The labels have no meaning outside of the disassembler so it isn't possible to tell what they refer to. If you compile any 'C' code and look at the listing file it looks like that because all the listing shows is a mix of current instructions, allocated addresses and library routines.

I can't understand why a generic LCD code isn't used, as far as I can tell that module uses an industry standard controller IC. Why re-invent the wheel?

Brian.
 

I am sure from the code in post #1 that it uses inline assembly for PIC and is written in old IAR EW PIC Compiler.
Neither the registers nor the instruction syntax matches a PIC processor.
 

That wasn't the question, they want PIC 'C' code that performs the same function. What it was originally written for is unknown but regardless of that, doesn't have the necessary label allocations to be able to write equivalent instructions.

Brian.
 

That wasn't the question, they want PIC 'C' code that performs the same function.
Sure, I just wanted to clarify that it isn't some unusual PIC code as assumed by baileychic. You can review the full code from the old thread, but I guess you still don't understand how it works. Rather odd. One point is that you need to decode the instruction set.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top