Pulled from the way back machine. For the most part I have adhered to this convention all these years and its served me well.
Samuel Igwe
Last Modified: April 6,2001
REVISION OF CODING STYLE
************************
C language and ASM
******************
HEADER (header and function):
*****************************
all source files (.asm,.c etc) must have a header that defines its purpose
all functions must have a header that defines its purpose as well.
this header takes the following form
source module header
/************************************************************************
module: ...
date: ...
description: ...
************************************************************************/
function header
/************************************************************************
description: ...
input: ...
output: ...
************************************************************************/
FOR .asm replase /* with ;* or ;-
note header top and bottom must start from one end of the screen and end in
the other sort of enclosing the function/procedure or header
VARIABLES:
**********
variables must begin with the following prefixes then the first char capital
by=char,byte
sb=char array
wd=short int,word
sw=short int array
dw=long,double word
sd=long array
qw=quad word
ptr=pointer
str=structure
un=union
examples of variable names are byChar,wdCount,dwValue,ptrToken, etc
FUNCTION and PROCEDURES (definitions):
**************************************
function names must begin with the prefix "func" followed by an underbar and
then the name of the function.
examples of function names are func_get_key, func_init_registers
FOR .asm this convention maybe broken in the case of modules that serve as
library files (cg=color graphics module). the keyboard library procedures
would begin with kb_ the video vga_ etc etc
#DEFINE and #EQUATES:
*********************
the name of constants defined using the #define prefix must be capitalized
for asm, macro names must be capitalized along with equates defined with the
.equ directive.
examples are #define MAX_STRING_LENGTH 256
.equ BOOTSTART 0
POINTERS (definitions):
***********************
all pointer definitions must begin with the prefix "ptr" followed by the name
of the pointer. values passed to functions as pointers must be named
ptrVariable name even if the original definition was not of a pointer but of
an array or variable.
examples are ptrToken, ptrChar
AESTETHICS:
***********
it is far easier to modify code when its appearance pleases the eye and is
found understandable. in keeping with this belief, code must be formatted
and indented well.
examples
if=the STATEMENT portion for "if" and "else" MUST be indented (tab)
while=same as above
do while etc etc
this rule applied double to ASM -- blocks of code and loops MUST be indented
well -- this rule is sacrosant!!!
No comments:
Post a Comment