This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C8051F020

Hello everyone!

I've a problem...

I wrote a program which transmit a text to LCD in assembler...but I must rewrite this code into C language...

And that's my problem cause don't know so much C language to rewrite this code...:/

Please help me...

P4 DATA 84H
P5 DATA 85H
P6 DATA 86H
P7 DATA 96H
WDTCN DATA 0FFH



ADRES_1 DATA 22H
ADRES_2 DATA 23H
ADRES_3 DATA 24H
LCDDA_CLK_1 EQU 08H
LCDDA_CLK_2 EQU 00H
LCDDA_CLK_3 EQU 00H
LCDCTR_CLK_1 EQU 09H
LCDCTR_CLK_2 EQU 00H
LCDCTR_CLK_3 EQU 00H

ORG 00H
LJMP START

ORG 100H

DELAY:
	NOP
	RET

STERRING_LCD:
	MOV ADRES_1,#LCDCTR_CLK_1
	MOV ADRES_2,#LCDCTR_CLK_2
	MOV ADRES_3,#LCDCTR_CLK_3
    	RET

DATA_LCD:
	MOV ADRES_1,#LCDDA_CLK_1
	MOV ADRES_2,#LCDDA_CLK_2
	MOV ADRES_3,#LCDDA_CLK_3
	RET

INFLAM:
	MOV ADRES_1,#0AH
	MOV ADRES_2,#00H
	MOV ADRES_3,#00H
	ORL P4,#80H
	ANL P4,#0FBH
	ANL P4,#0BFH
	CALL SEND_ADRES
	RET

SEND_ADRES:
	ANL P4,#0C7H
	MOV P7,ADRES_1
	ORL P4,#08H
	CALL DELAY
	MOV P7,ADRES_2
	ORL P4,#10H
	CALL DELAY
	MOV P7,ADRES_3
	ORL P4,#20H
	CALL DELAY
	ANL P4,#0FBH
	RET

ENABLE:
	MOV P6,#20H
	CALL STERRING_LCD
	CALL SEND_ADRES
	NOP
	NOP
	MOV P6,#00H
	CALL STERRING_LCD
	CALL SEND_ADRES
	RET

WRITE_STER_LCD:
	MOV P6,#00H
	CALL STERRING_LCD
	CALL SEND_ADRES
	MOV P5,A
	CALL DATA_LCD
	CALL SEND_ADRES
	CALL ENABLE
	RET

WRITE_DATA_LCD:
	MOV P6,#10H
	CALL STERRING_LCD
	CALL
SEND_ADRES
	MOV P5,A
	CALL DATA_LCD
	CALL SEND_ADRES
	CALL ENABLE
	RET

START:
	CLR EA
	MOV WDTCN,#0DEh
	MOV WDTCN,#0ADh
	SETB EA

	CALL INFLAM

	MOV A,#0FH		;WLACZENIE WYSWIETLACZA
	CALL WRITE_STER_LCD
	MOV A,#14H		;PRZESUWANIE KURSORA
	CALL WRITE_STER_LCD
	MOV A,#38H		;USTAWIENIE PARAMETROW PRACY
	CALL WRITE_STER_LCD
	MOV A,#01H		;CZYSZCZENIE EKRANU I ZEROWANIE ADRESU KURSORA
	CALL WRITE_STER_LCD
	MOV A,#06H		;USTAWIENIE TRYBU WPROWADZANIA ZNAKOW
	CALL WRITE_STER_LCD

	MOV A,#52H		;R
	CALL WRITE_DATA_LCD
	MOV A,#61H		;a
	CALL WRITE_DATA_LCD
	MOV A,#66H		;f
	CALL WRITE_DATA_LCD
	MOV A,#61H		;a
	CALL WRITE_DATA_LCD
	MOV A,#6CH		;l
	CALL WRITE_DATA_LCD

	SJMP $
END

Parents
  • "my teacher wants me to do it in ... C language"

    Presumably because you are doing a 'C' programming course?
    So the object of the exercise is for you to apply what you have learned so far in your 'C' programming course.

    Therefore, to do this for you would defeat the object of the exercise - and could get you in trouble for cheating.

    So, have a go at it yourself; if you have any specific questions, after studying your course notes, textbooks, and the tool Manuals, come back and ask - but don't expect it all to be done for you!

    Having done it in assembler, you must already understand what has to be done - this is merely an exercise in expressing that in the 'C' language.

Reply
  • "my teacher wants me to do it in ... C language"

    Presumably because you are doing a 'C' programming course?
    So the object of the exercise is for you to apply what you have learned so far in your 'C' programming course.

    Therefore, to do this for you would defeat the object of the exercise - and could get you in trouble for cheating.

    So, have a go at it yourself; if you have any specific questions, after studying your course notes, textbooks, and the tool Manuals, come back and ask - but don't expect it all to be done for you!

    Having done it in assembler, you must already understand what has to be done - this is merely an exercise in expressing that in the 'C' language.

Children
No data