In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Rodney, in Assembly, I use some naming conventions that help to keep the banks in order. Here is an example of how I declare banks and registers: org $10 Ser = $ Ser_TxHighPC ds 1 Ser_TxLowPC ds 1 Ser_TxCountPC ds 1 Ser_TxDividePC ds 1 Ser_RxBytePC ds 1 Ser_RxCountPC ds 1 Ser_RxDividePC ds 1 As you can see, I assign a name to each bank, like "Ser" in this example. I then prefix the names of all registers in this bank with the bank name, followed by an underscore. In the code, something like bank Timer mov Ser_TxHighPC, #'?' should look really suspicious, as a register in bank "Ser" is referred to after bank "Timer" has been selected. It is getting more problematic when you need to copy from a register in one bank to a register in another bank. In simple cases, you may use the W register as temporary storage, as in bank Timer mov w, Timer_Count bank Serial mov Serial_TxLow, w Always be aware that the W register is used as temporary storage by almost all comopund statements, so this code will fail: bank Timer mov w, Timer_Count mov Timer_Count, #200 ; w is used as temporary storage ! bank Serial mov Serial_TxLow, w When you replace the compound statement by what the assembler generates, you will immediately notice the problem: bank Timer mov w, Timer_Count ;------------------------- ; mov Timer_Count, #200 ; mov w, #200 ; This overwrites the value of Timer_Count in w mov Timer_Count, w ;------------------------- bank Serial mov Serial_TxLow, w ; 200 is written to Serial_TxLow but not Timer_Count For such cases, it is a good idea to have a temporary register defined in the global area, as such registers can always be accessed, no matter which bank is selcted. Here is an example: bank Timer mov Temp, Timer_Count mov w, #200 mov Timer_Count, w bank Serial mov Serial_TxLow, Temp Enough for now.... :-) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=421700#m423371 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2010 (http://www.dotNetBB.com)