Link to home
Start Free TrialLog in
Avatar of caleno
caleno

asked on

Translating from Assembly to C Assistance

Hi I need some help translating this code written in assembly to C language
This is to initialize and use a 4 digit LCD module.
Thanks
 
         sda   equ  p3.4
         scl   equ  p3.5
         ;cf    equ  p3.3
         org   0
start:
         ;clr    cf
         mov   dptr,#tab
         mov   b,#10
NEXT:    mov   a,#0ffh
         mov   p1,a
         setb   sda
         nop
         setb   scl
         call  del10ms
         clr   sda
         nop
         nop
         clr   scl
         mov   a,#70h  ;pcf8576
         ;mov   a,#07ch
          ;mov   a,#11000000b   ;pcf8566
         call  wr8
         mov   a,#0c8h
         call  wr8
         mov   a,#80h
         call  wr8
         mov   a,#0e0h
         call  wr8
         mov   a,#70h
         call  wr8
         mov   r7,#8
 start11:
          mov   r4,#20  ;Ò»¹²40¸öSEG£¬¶øÓÖÊÇ4¸öCOM,ËùÒÔÁ½¸öSEG²Å×é³ÉÒ»¸ö¶Î
tran:     mov   a,#00h
          movc  a,@a+dptr
          acall wr8
          djnz  r4,tran
          inc   dptr
          mov   r1,#15h

        SETB   SCL
          NOP
         SETB   SDA

de:      acall del10ms
         acall del10ms
         acall del10ms
         djnz  r1,de
         djnz  b,next
         mov   dptr,#tab


         ajmp  start

wr8:     mov   r5,#0
w:      clr   scl
        rlc   a
         jc    hda
         clr   sda
         sjmp  lda
hda:     setb  sda
lda:     nop
         nop
         setb  scl
         inc   r5
         cjne  r5,#8,w
         clr   scl
         setb  sda
         nop
         nop
         setb  scl
         nop
         nop
         clr   scl
         ret
del10ms: mov   r7,#010h
de1:     mov   r6,#0ffh
de2:      nop
         djnz  r6,de2
         djnz  r7,de1
         ret
T:       MOV   R5,#08fH
LOP1:    mov   r6,#08fh
t5:      nop
         ;nop
         ;nop
         djnz  r6,t5

         DJNZ  R5,LOP1
         RET


TAB:      db   0ffh,00h,0fh,0f0h,0ffh,00h,0fh,0f0h,0ffh,00h,0fh,0f0h,
         db    04h,02h,01h,80h,10h,40h,20h,08h,00h,0FFh
         ;DB    0d7h,03H,0b6H,0a7H,63H,0e5H,0F5H,07H,0F7H,0e7H,0FFH,00h
tab1:   db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh
        db  0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh

         end
Avatar of furqanchandio
furqanchandio

if the program runs fine in assembly then y change to C ?
Avatar of caleno

ASKER

furqanchandio, I understand better C than assembly. I could follow some of the steps from the program above, but not all of them. I did not write this program, it was given to me.

thanks
ASKER CERTIFIED SOLUTION
Avatar of furqanchandio
furqanchandio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of caleno

ASKER

Thanks for your help, but I already took care of it. I have it working in C.

Caleno
hi

thanx

:-)