Call a subroutine  from a separate file

cancel
Showing results for 
Search instead for 
Did you mean: 

Call a subroutine  from a separate file

Jump to solution
1,061 Views
sctang
Contributor I

Hello,

It is my first time to write an application with a main program in a file and several subroutines in different files for a HCS08QE MCU. Attached is a program for testing. After compling it, I got the following message:

 

A13003: Value is truncated to one byte

SR_Test.asm line 3

A13003: Value is truncated to one byte

SR_Test.asm line 4

A1104: Undeclared user defined symbol:  PTCD

SR_Test.asm line 3

Compile failed

 

The compiler regards the command  "BSET 7,PTCD" in the main program as a direct addressing instruction since the address of PTCD is 0x04. However, it is not the case for the same command in the subroutine.

I tried many times by adding XDEF, XREF, XREF.B to the .asm files, and the object code file to Project.prm, but I got other error messages.

Please give me advice because I have spend a long time to learn this which should be a straightforward issue.

Thanks.

Labels (1)
Tags (1)
0 Kudos
1 Solution
101 Views
CrasyCat
Specialist III

Hello

 

I assume you want to build the 2 .asm file separately and then link them together.

Am I right?

 

Then you should

  1- Create a file SR_Test.inc, where you have declaration for all symbols from SR_Test.asm

       that are visible from outside of the file.

  2- Include that .inc file in main.asm and remove include from SR_Test.asm

  3. In SR_Test.asm, include directive.inc and make label SR_Test_Function visible from

      outside of the module (using directive XDEF)

 

CrasyCat

View solution in original post

0 Kudos
2 Replies
102 Views
CrasyCat
Specialist III

Hello

 

I assume you want to build the 2 .asm file separately and then link them together.

Am I right?

 

Then you should

  1- Create a file SR_Test.inc, where you have declaration for all symbols from SR_Test.asm

       that are visible from outside of the file.

  2- Include that .inc file in main.asm and remove include from SR_Test.asm

  3. In SR_Test.asm, include directive.inc and make label SR_Test_Function visible from

      outside of the module (using directive XDEF)

 

CrasyCat

View solution in original post

0 Kudos
101 Views
sctang
Contributor I

Thank you, CrasyCat,

 

It works. This is what I need.

 

sctang

0 Kudos