Call a subroutine  from a separate file

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Call a subroutine  from a separate file

跳至解决方案
2,443 次查看
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.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,483 次查看
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

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,484 次查看
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

0 项奖励
回复
1,483 次查看
sctang
Contributor I

Thank you, CrasyCat,

 

It works. This is what I need.

 

sctang

0 项奖励
回复