We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have got this code which insert Assembly code into C code. How can the parameter of the function,tx_buffer be passed into the assembly? Also what is the value of R7 in the first line? And how can it return a unsigned char?
unsigned char DriverLoadHeader(unsigned char tx_buffer) { #pragma asm MOV A, R7 MOV R1, A INC R1 MOV R0,#HEADER_SIZE ;Reset to TX FIFO MOV A, #10 MOV DPTR, #SCR2 MOVX @DPTR, A MOV DPTR, #TX_FIFO LOAD_LOOP: MOV A, @R1 MOVX @DPTR, A INC R1 DJNZ R0,LOAD_LOOP #pragma endasm return 1; }
It is all in the manual. Start here: http://www.keil.com/support/man/docs/c51/c51_ap_parampassreg.htm Then go to here: http://www.keil.com/support/man/docs/c51/c51_ap_funcret.htm Enjoy.
by all means read about it; hoever it is so much easier to generate a skeleton function in C and use the generated assembler as a template. Erik