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

inline assembly help linker error

#include <reg5000.h>
#include <stdio.h>

void main(void);
void writebyte (unsigned char ch);


void main()
{
	unsigned char ch;
	ch=0x0A;
	writebyte(ch);
}

void writebyte (unsigned char ch)
{
	ACC=ch;

#pragma ASM
	PUSH	MCON
	ORL	MCON,	#4
	MOVX	@R0,	A
	DEC	R0
	POP	MCON
#pragma ENDASM

}

When compiling I get the following linker warning.

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_STARTUP
    MODULE:  rtc-func.obj (RTC_FUNC)

I followed the directions in the manual about in-line assembly and the ASM/ENDASM directives which stated

Right click on the file in the Project Window - Files Tab
Choose Options for... to open Options - Properties page
Enable Generate Assembler SRC file
Enable Assemble SRC file.

I also tried adding the STARTINIT.A51 file and get the same linker warnings except that the warnings are in the STARTINIT.A51 file instead.

Any help out there? I know it has to be something simple...

  • s/STARTINIT.A51/STARTUP.A51/g
    (meant STARTUP.a51 not STARTINIT.a51)

    sorry (coffee depletion imminent)

  • Doh!!

    Just to follow up...

    I found the answer here:

    http://www.keil.com/support/docs/1980.htm

    and for those too lazy to look above, here it is...

    CAUSE

    When you compile all your C modules with the SRC directive and the assembler, the linker does not detect the required C run-time libraries (because the files were assembled). In this case, you must add the libraries to your project manually.

    RESOLUTION

    For a project in the SMALL memory model that uses no floating point arithmetic, C51S.LIB is required.

    For a project in the LARGE memory model that uses floating-point, C51FPL.LIB and C51L.LIB are required.

    If a project uses floating arithmetic, it is important that C51FPx.LIB is included before the standard library file C51x.LIB. Otherwise printf and scanf will not work with floating-point numbers.

  • Just included a dummy C file into your project. Right now it thinks you are compiling a pure assemble routine, and it does not include the C runtime modules.