I wrote a very long routine and and hence i want to put it in seperate files for cleaner view,Im using an 8051 ,coding in assembler ,does any one know how for example do you seperate your file and include it in your main file , so that at the time of call it can go to that file ,inside the routine, do its job and come back where it was going to execute the next instruction , I have tried it but as it goes in the other file and comes back to the main file ,it goes to the first instruction in my code instead of basically continuing where it left off ?
Thanks Owais Ahmed ,
You're completely mixing up to completely separate issues there: splitting the flow of your code into properly structured subroutines, and splitting source text into reasonably-sized compilable source files.
You have to separate these concepts before you have any chance of implementing either successfully.
You should not include entire source code files into others. And if a routine has become very long, that means it's doing too many things in a single routine. Learn what CALL and RET machine instructions are for. Then learn what PUBLIC and EXTERN are for. Then combine these two to understand how to properly put some of the code in a separate routine in a separate file, and how to use the linker and assembler to translate each file on its own, and then combine them.
All of the documentation is available online: https://www.keil.com/support/man_c51.htm
In particular, study the Assembler manual: https://www.keil.com/support/man/docs/a51/
Here's some books on the subject: https://www.keil.com/books/8051books.asp
However, if your code is getting so large to be hard to manage, that strongly suggests that you would be better writing in a higher-level language - so why are you not doing this in 'C' ?
View all questions in Keil forum