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

C calling to Assembly routine

Hi,

I'm trying to call an assembly (.a51) function from a C file.

I had it working, but then now it refuses to work. I get an error

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?_WAIT_MS?DELAY
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: __WAIT_MS MODULE: main.obj (MAIN)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL: __WAIT_MS MODULE: main.obj (MAIN) ADDRESS: 0030H

My code is the following:
For the C file it is:

#include <t89c51ac2.h>

void _wait_ms(unsigned int length_delay);
void init(void);

int main(void)
{
        init();
        _wait_ms(300);

        return 0;
}

/*init()
/****************************************************************************************/
/*Purpose: This routine initializes interrupts, and A/D                                                                 */
/*Input: none                                                                                                                                                   */
/*Outputs: none                                                                                                                                                 */
/*Registers Modified: ADCON - A/D Control Register                                                                              */
/*                    ADCF  - A/D Configuration Register                                                                */
/****************************************************************************************/
void init(void)
{
        /*A/D Configuration*/
        ADCF |= 0x80;                                                                           //Select CH7 as Analog In
        ADCON |= 0x47;                                                                          //Enable CH7 for conversion
                                                                                                                //and Enable ADC

        return;
}

And for the assembly file it is

; delay.SRC generated from: delay.c
; COMPILER INVOKED BY:
;        C:\Keil\C51\BIN\C51.EXE delay.c BROWSE DEBUG OBJECTEXTEND
; Modified by Roque Obusan 02/09/2009
; Reason - add delay


NAME    DELAY

?PR?_wait_ms?DELAY   SEGMENT CODE
        PUBLIC  _wait_ms
; #pragma SRC
; void wait_ms(unsigned int length_delay)

        RSEG  ?PR?_wait_ms?DELAY
_wait_ms:
        USING   0
;---- Variable 'length_delay?040' assigned to Register 'R6/R7' ----
;---- Variable 'i?041' assigned to Register 'R5' ----
        ;check for 0 ms delay, exit if found
        MOV A, R7
        JNZ ?MLOOP
        MOV A, R6
        JNZ ?MLOOP
        JMP ?EXIT_WAIT_MS

?MLOOP:

        ;loop constant to cause the delay of 1 ms
        MOV R5, #0xff
        ;delay loop to cause the 1 ms delay
?SLOOP:
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        MOV A, R5
        SUBB A, #0x01
        MOV R5, A
        JNZ ?SLOOP

        ;checks if delay is complete
        ;MSB first w/ carry
        MOV A, R7
        CLR C
        SUBB A, #0x01
        MOV R7, A
        JNZ ?MLOOP
        ;LSB secondly w/ carry
        MOV A, R6
        SUBB A, #0x00
        MOV R6, A
        JNZ ?MLOOP

?EXIT_WAIT_MS:
        RET
; END OF _wait_ms

        END

Parents Reply Children