Difference between revisions of "Style"

From KolibriOS wiki
Jump to navigation Jump to search
m (moved Style/en to Style)
Line 1: Line 1:
Here is a quick draft of what may become a good guideline of how to format your code:
+
<b>SVN rules:</b><br><br>
 +
* No tab characters allowed.
 +
* Code labels must be on a separate line. It is not allowed to have a label and a command on the same line. Combinations of label and data in one line is allowed.
 +
* Lines with commands must start with 8 spaces. A mnemonic is short if it's length is less than 8. Arguments for short mnemonics must start in the column 16. Arguments for long mnemonics must be separated from the mnemonic by exactly one space. Arguments must be separated with a comma and exactly one space after a comma. Arguments continued in the next line must start from the same position as in the first line.
 +
* Prefixes lock/rep[z|e|nz|ne] are considered as a logical part of the command, so they start at position 8, then after exactly one space follows the main mnemonic and arguments.
 +
* The special property 'svn:eol-style' must be set to 'native'.
 +
* All code and text files should be in UTF-8 without BOM.
 +
 
 +
<br><b>Suggestions:</b><br><br>
  
* Do not place code on a the same line as a label.
 
* Use tabs before and after instructions.
 
* Place a space after comma.
 
 
* Don't place a space after a typename (byte/word/dword/..).
 
* Don't place a space after a typename (byte/word/dword/..).
 +
* place 2 spaces before a local label, this way it will 'pop out' between the subprogram name and the code
 +
* Only cast when nescessary.
 
* When you need to cast, do it on the memory location, not on the operand.
 
* When you need to cast, do it on the memory location, not on the operand.
* Only cast when nescessary.
+
* Place a space after comma.
* place 2 spaces before a local label, this way it will 'pop out' between the subprogram name and the code
 
*
 
  
 
[[Category:Coding]]
 
[[Category:Coding]]

Revision as of 13:39, 6 June 2013

SVN rules:

  • No tab characters allowed.
  • Code labels must be on a separate line. It is not allowed to have a label and a command on the same line. Combinations of label and data in one line is allowed.
  • Lines with commands must start with 8 spaces. A mnemonic is short if it's length is less than 8. Arguments for short mnemonics must start in the column 16. Arguments for long mnemonics must be separated from the mnemonic by exactly one space. Arguments must be separated with a comma and exactly one space after a comma. Arguments continued in the next line must start from the same position as in the first line.
  • Prefixes lock/rep[z|e|nz|ne] are considered as a logical part of the command, so they start at position 8, then after exactly one space follows the main mnemonic and arguments.
  • The special property 'svn:eol-style' must be set to 'native'.
  • All code and text files should be in UTF-8 without BOM.


Suggestions:

  • Don't place a space after a typename (byte/word/dword/..).
  • place 2 spaces before a local label, this way it will 'pop out' between the subprogram name and the code
  • Only cast when nescessary.
  • When you need to cast, do it on the memory location, not on the operand.
  • Place a space after comma.