One main file, multiple secondary source file inclusion

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

One main file, multiple secondary source file inclusion

Jump to solution
2,673 Views
Dragaoerrante
Contributor I
Hi! I'm used to organize my software projects around one main file and may other auxiliary source code files. The main one just have a main loop and some call for subroutines that are witten in the other source files. This structure works fine becouse halps me in the software development and i the documentation.

Now I'm trying to use this aproach in CW for HC(S)08 V5.7, to build a code for a 9S08GT32 controller.

I first started with an Absolute Assembly project, because it seemed to best fit my needs. Thus, I started having some problems because, as an example, no variable defined in the RAM.asm file is able to be recognized in the other source files. The same thing happens whith symbols and other labels. I'v tried to use XDEF and XREF, but the compiles shows me a message about redefinig a symbol.
I'v even tried to use a Relocatable Assmby project, but I had the same overlaping or non recognizing symbols problem.
I think I'm problaby doing something wrong in my include file definitions or label definitions. Do anyone have an idea about what can I do to solve this problem? I Attached my projec folder, so, if someone could take a quick look for me, I'd be really tahnkfull

The codes in the secondary source files are note completed and the comments are in portugeese, but I think that won't prevent you to have an idea about what is happenning.
There are also some comments in the code lines and in some directive, as a history of all things I'v tried.

Thanks so much!
Labels (1)
Tags (1)
0 Kudos
1 Solution
1,057 Views
bigmac
Specialist III
Hello,
 
I tried a couple of things with your absolute assembly code.
 
Firstly, the file RAM.asm uses some constants that are defined in main.asm.  So, for absolute assembly, these constants must be defined before INCLUDing RAM.asm.  I also swapped the order of the last two includes.
 
 NOLIST
 INCLUDE 'derivative.inc'
 LIST
 
FAST_RAM_START: EQU $0000
FAST_RAM_END:   EQU $007F
RAM_START:      EQU $0080
RAM_END:        EQU $087F
ROM_START:      EQU $8000
 
 INCLUDE 'RAM.asm'
 INCLUDE 'CPU.asm'
 INCLUDE 'IRQ_ISR.asm'
 INCLUDE 'IRQ_VEC.asm'
 
Once I had done this, I was actually able to get your main.asm code to assemble without complaint, using the CW assembler independently of the CW IDE.  (I also needed to do a couple of additional things so that the include files could be found by the assembler.)  Incidently, this is the way I would normally handle my absolute assembly projects.
 
However, with the same code handled via the CW IDE, when I attempted to Make the project, I did get a number of errors.  These included "A2333:  Forward reference not allowed" to the lines of code, within RAM.asm, that used the constants that were defined prior to the INCLUDE.
 
There was also a further error "A1104:  Undeclared user defined symbol:" pertaining to the symbols 'Sys_Sts' and 'spurious'.  The first symbol is defined within RAM.asm, and referenced within CPU.asm, whereas the second symbol is defined within IRQ_ISR.asm, and referenced within IRQ_VEC.asm.  So everything is defined before it is referenced, as it should be.
 
My understanding is that XDEF and XREF do nothing for absolute assembly.
 
I cannot explain why the assembler tool should work as anticipated, but CW IDE does not.  It would seem that  the IDE does not handle absolute assembly in an identical manner to assembler.
 
Perhaps others may be able to offer an explanation.
 
I did find other obvious errors within your code, but not that would prevent assembly.  Check that your ORG locations are what you intend, and check that you use the '$' prefix when you intend hexadecimal values.
 
Regards,
Mac
 

View solution in original post

0 Kudos
3 Replies
1,058 Views
bigmac
Specialist III
Hello,
 
I tried a couple of things with your absolute assembly code.
 
Firstly, the file RAM.asm uses some constants that are defined in main.asm.  So, for absolute assembly, these constants must be defined before INCLUDing RAM.asm.  I also swapped the order of the last two includes.
 
 NOLIST
 INCLUDE 'derivative.inc'
 LIST
 
FAST_RAM_START: EQU $0000
FAST_RAM_END:   EQU $007F
RAM_START:      EQU $0080
RAM_END:        EQU $087F
ROM_START:      EQU $8000
 
 INCLUDE 'RAM.asm'
 INCLUDE 'CPU.asm'
 INCLUDE 'IRQ_ISR.asm'
 INCLUDE 'IRQ_VEC.asm'
 
Once I had done this, I was actually able to get your main.asm code to assemble without complaint, using the CW assembler independently of the CW IDE.  (I also needed to do a couple of additional things so that the include files could be found by the assembler.)  Incidently, this is the way I would normally handle my absolute assembly projects.
 
However, with the same code handled via the CW IDE, when I attempted to Make the project, I did get a number of errors.  These included "A2333:  Forward reference not allowed" to the lines of code, within RAM.asm, that used the constants that were defined prior to the INCLUDE.
 
There was also a further error "A1104:  Undeclared user defined symbol:" pertaining to the symbols 'Sys_Sts' and 'spurious'.  The first symbol is defined within RAM.asm, and referenced within CPU.asm, whereas the second symbol is defined within IRQ_ISR.asm, and referenced within IRQ_VEC.asm.  So everything is defined before it is referenced, as it should be.
 
My understanding is that XDEF and XREF do nothing for absolute assembly.
 
I cannot explain why the assembler tool should work as anticipated, but CW IDE does not.  It would seem that  the IDE does not handle absolute assembly in an identical manner to assembler.
 
Perhaps others may be able to offer an explanation.
 
I did find other obvious errors within your code, but not that would prevent assembly.  Check that your ORG locations are what you intend, and check that you use the '$' prefix when you intend hexadecimal values.
 
Regards,
Mac
 
0 Kudos
1,057 Views
Dragaoerrante
Contributor I
Hi Bigmac!


Thanks very much for your reply! I'v seen some of your posts before in this forum explainning the use os the assembler without the IDE. I'll do the way you said. It is really curious that CW gets different responses if executed by the command line and by the IDE.
About the other errors in the code, I applogize for posting some wrong programs. I know exactally what, and where, do you mean when you mention the ORG and the $ Hex symbol. Actualy, I made this strange, and obviously wrong things, as a desperated intervention to see if a would have, at least, some change in the error messages that could help me solving the problem. In fact, I was a kind of irresponsable by keeping this mistakes without any advertisement, so other people could get confused if they look to the program.

Thanks again Bigmac!
0 Kudos
1,057 Views
Dragaoerrante
Contributor I
Hi people! I used the pure assembler program as Bigmac sugested and it really worked out. I also realised that if I remove my secondary files from the project inspector, leaving only the main file, I can build it from the IDE. It is a little hard work to remove the files every time, so now I'm using the IDE just to write codes. The code compilation I proceed outside the IDE, runing the ahc08.exe program.

Just to spread my results!
0 Kudos