I am using a uVision2 and C51 compiler. I want to use code banking as my code exceeds 64K limit. how do I specify which part of the code will be in which bank(means which files to assign what bank) and which will go into the common area. Suppose I have assigned two files of the code to be in bank0. How will I know the size occupied by the files in that bank? Does the linker take care of the function calls if we specify some files in one bank and some files in another bank randomly?
In uVision, a file group has a pulldown list that lets you set a bank for all files in that group. So, if you have no other structure in your project, you might just create groups "Common", "Bank 1", etc. The SEGMENTS directive is the corresponding directive for the linker. You can specify a bank without specifying a specific address. E.g., SEGMENTS (?PR?MyModule (B1:)) puts MyModule someplace in bank 1, while SEGMENTS (?PR?MyModule (B1:A000H)) puts MyModule exactly at address A000. The map file shows the actual locations of all the segments once they've been located. You can scan down the lists of segments located in CODE, CODE/B1, etc, to find the highest address used. Unfortunately, there's no handy summary of this information. It would be a nice feature if the linker summarized bank usage along with the other memory usage generated by the compiler (data/xdata/const/code, but with "code" being broken down by banks when building a banked application.) A little work with perl or awk to process the map file can get you by, though. The linker will create the inter-bank calls correctly if you randomly scatter files around. Keep in mind, though, that any inter-bank call requires a stub to exist in the common bank, so the flow of control can jump down to common, flip in a new bank, jump up to the new bank, and return the same way. In addition to being slow, these stubs take up space in the common bank. I'd recommend considering your program call tree, and trying to group modules with high interdependence together in the same bank.