• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

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
0
caleno
Asked:
caleno
  • 3
  • 2
1 Solution
 
furqanchandioCommented:
if the program runs fine in assembly then y change to C ?
0
 
calenoAuthor Commented:
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
0
 
furqanchandioCommented:
hi

what platform r u using

windows, linux, Mac os ?
0
 
calenoAuthor Commented:
Thanks for your help, but I already took care of it. I have it working in C.

Caleno
0
 
furqanchandioCommented:
hi

thanx

:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get Certified for a Job in Cybersecurity

Want an exciting career in an emerging field? Earn your MS in Cybersecurity and get certified in ethical hacking or computer forensic investigation. WGU’s MSCSIA degree program was designed to meet the most recent U.S. Department of Homeland Security (DHS) and NSA guidelines.  

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now