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

Calling Assembly Function From Another File

Hi,
I have two files in my project, that are as follows;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////// File 1 //////////////////////////////
///////////////////////////////////////////////////////////////////////////
$NOMOD51
$INCLUDE (REG952.H)

PUBLIC HI_DATA
PUBLIC LO_DATA
PUBLIC LED_PORT
PUBLIC RAM_LOCATION
EXTRN CODE (init_CAM)
;==============================================================
; EQUATES COMMON
;==============================================================
LED_PORT EQU P5

USING 0 ;using register bank0 USING 1 ;using register bank1

C_DATA SEGMENT DATA

RSEG C_DATA

HI_DATA: DS 1;
LO_DATA: DS 1;
RAM_LOCATION: DS 1;
STACKPTR: DS 1; ; START OF STACK

;==============================================================
; INTERRUPT VECTORS
;==============================================================
C_TEXT SEGMENT CODE RSEG C_TEXT

ORG 000H ; RESET VECTOR JMP INIT_MAIN

;==============================================================
; INITIALIZATION ROUTINE COMMON
;==============================================================
INIT_MAIN:

;---------- added for NXP -----------------

MOV DIVM,#2

MOV DPTR,#0FFB8H ; P4M1 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFB9H ; P4M2 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFBAH ; P5M1 MOV A,#00H MOVX @DPTR,A MOV DPTR,#0FFBBH ; P5M2 MOV A,#00H MOVX @DPTR,A

MOV P2M1,#00H ; for NXP MOV P2M2,#00H ; for NXP MOV P1M1,#00H ; for NXP MOV P1M2,#00H ; for NXP MOV P0M1,#00H ; for NXP MOV P0M2,#00H ; for NXP MOV P3M1,#00H ; for NXP MOV P3M2,#00H ; for NXP

MOV SP,#STACKPTR MOV LED_PORT,#05H

MOV HI_DATA,#0 MOV LO_DATA,#0 MOV RAM_LOCATION,#0

;==============================================================
; BACKGROUND PROCESS
;==============================================================
BKGR:

call init_CAM

JMP BKGR
;==============================================================
; BACKGROUND PROCESS ends
;==============================================================
END

whereas file 2 is

///////////////////////////////////////////////////////////////////////////
///////////////////////////////////// File 2 //////////////////////////////
///////////////////////////////////////////////////////////////////////////
$NOMOD51

EXTRN DATA (HI_DATA)
EXTRN DATA (LO_DATA)
EXTRN NUMBER (LED_PORT)
EXTRN DATA (RAM_LOCATION)
PUBLIC init_CAM

LIB_TEXT SEGMENT CODE

RSEG LIB_TEXT

init_CAM: MOV LED_PORT,#0AH

RET
END

Note: When I declare the function init_CAM directly in file 1, the LED_PORT works. However if I call the same init_CAM function created in file 2, the LED_PORT does not work. The code compiles without error. Kindly provide the solution to this problem. I am using uVision 3 VER3.30 and the target controller is NXP P89LPC952.

Regards,
Nick

0