multiple asm files in a 8051 keil project

Status
Not open for further replies.

tariq7868

New Member
Hello.
I have a very long code written for 8051 in assembly using Keil, all in a single file. And i want to organize and distribute the functions in multiple files, but can't seem to be able to do it. I tried adding assembly code files using $include but there were errors in compiling it. Like, memory overlapping error was produced even defining 'org' in the included files. so is it done in Keil with assembly?

Thanks.
 
For example:

code is:

;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG 00h

RESET:

CALL TOGGLE_LED

SJMP RESET


TOGGLE_LED:
CPL P1.0
RET

END
;;;;;;;;;;;;;;;;;;;;;;;;;;

And i want to put the function "TOGGLE_LED" routing
i.e. the part:

TOGGLE_LED:
CPL P1.0
RET

into a separate .asm source file. So how can it be done?

Thanks.
 
You do it with .INC files, not .ASM files.

Example, place your TOGGLELED routine into a separate file, then save it as something like TOGGLELED.INC.

Then, where you want this function code to appear in the main code file, you do -

Code:
		#include		"TOGGLELED.INC"

You will also need to set the path to the directory where you save your .INC files. You can set it under the "C51" tab of "Flash--->Configure Flash Tools" menu in Keil.
 
Last edited:
There should be no code in anything but .asm files.
You need to declare functions as externs and let the linker sort it out.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…