Asm Code conventions
From S1MP3 Wiki
Contents |
Labels
There are two styles of labels:
- .labelName
- labelName:
In which styles are different types of labels written:
- Labels that specify function names will be written with a colon at their end.
- Labels that point to variables in memory will be written with a colon at their end.
- Labels that point to pieces of code inside a function will be written staring with a period.
Labels that are used only internally by the function should use a prefix that is either made of the function name, or an abbreviation of the function name to prevent name clashes.
Ports, and Memory
- Accessing ports with their numeric address is not allowed. All ports must be defined with DEFC somewhere else.
- Setting and clearing bits should be done with bit masks also defined somewhere with DEFC.
- The same applies to possible memory mapped registers.
Comments
- Short comments should go after the code line being commented on.
- These comments should be verically aligned for a given group of instructions, like a function.
- If the comment is too long then it can be continued on the next line, but the comments should still align.
- Comments for commenting-out instructions should be placed in column 0.
Function header is:
;///***************************************************************************
group_Function:
;/// function signature if can be called from C
;///
;/// ...description...
;///
;/// In: register_name description
;/// ... ... ...
;/// register_name description
;/// (SP+2) description
;///
;/// Out: register_name description
;///
;/// Trashes: AF, BC, D, DE'
;///
;/// Notes: ...
;///
;///***************************************************************************
(some asm code)
.gpfun_label
(some asm code)
ret
Obfuscation
If the code-moderator deems the code to be deliberately obfuscated, then the code WILL be changed or rejected.
Human Language
All comments will be in English.
Comments in American are also valid.
File Headers
EVERY ASM and INC file will contain the following header:
; *============================================================================== ; * ; * _____ ; * / ___| ; * \ `--.__ ____ _ _ ___ ; * `--. \ \ /\ / / _` | '_ \ ; * /\__/ /\ V V / (_| | | | | ; * \____/ \_/\_/ \__,_|_| |_| ; * ; * ; * ; * All files in this archive are under the FreeBSD license. ; * ; * This software is distributed on an "AS IS" basis, ; * WITHOUT WARRANTY OF ANYKIND, either express or implied. ; * ; *============================================================================== ;/// ;/// $Id$ ;/// ;/// brief description: bla bla bla ;/// ;/// revision history ;/// ;/// When Who What ;/// ------------- ----- -------------------------------------------------------- ;/// 2005/oct/31 BOB Changed stuff ;/// ;/// ;///=============================================================================