adding a assembly file to project

Hi all

I want to add Asm file to a 'C' project.
Project has one '.c'and one '.h' file.

Assmbly file to be added is with '.a51' extension.only one routine is added to a51 file,which is called from main.A51 file is getting assembled successfully,but project is not getting compiled as whole.

decleration in main file is :

extern void delay_asm(unsigned char);

void main()
{
   .
   delay_asm(2);
   .
}


Assembly file is as given below

PR?delay_asm?delay_asm SEGMENT CODE

PUBLIC delay_asm

delay_asm:
   USING 0
   mov a,R7
rv:dec A
   Jnz rv
   RET

END

on project compilation:

warning L5:Code space overlap
From:0000H
To:0004H
warning L2:Refrence made to unresolved
external _delay_asm
Target not created.

This warnings where not generated before adding a51 file to project.

i am missing some thing small here,but any help would be appreciated.

Regards
Naresh

Parents
  • For such a simple loop why don't you stay in "C"

    void Delay (unsigned char Cycles)
    {
        while (--Cycles);
    }
    

    This function generates super efficient code:

    DELAY1: DJNZ R7,DELAY1
    

    If your real question is interfacing to assembler code, be aware of the register passing convention and function naming.

    Unless you state that your function is "alien", the actual assembly must be coded with an "_" (underscore) character preceeding the function name.

Reply
  • For such a simple loop why don't you stay in "C"

    void Delay (unsigned char Cycles)
    {
        while (--Cycles);
    }
    

    This function generates super efficient code:

    DELAY1: DJNZ R7,DELAY1
    

    If your real question is interfacing to assembler code, be aware of the register passing convention and function naming.

    Unless you state that your function is "alien", the actual assembly must be coded with an "_" (underscore) character preceeding the function name.

Children
More questions in this forum