-
Notifications
You must be signed in to change notification settings - Fork 2
/
style-guide.txt
114 lines (97 loc) · 3.77 KB
/
style-guide.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
All_names_use_underscore_instead_of_camel_case
Sorry_camel_peeps
;=================================================
;=================================================
;
; Section
;
;-------------------------------------------------
;
; Section comments should precede most major portions of a file.
; If the section has a description, prefer placing it immediately
; after the section comment.
;
.include "library_macros_and_defines_are_in_a_header_with_an_extension_of.inc"
.include "and_included_at_the_top_of_any_file_that_needs_them.inc"
;=================================================
; Macros_have_a_header_with_their_name
; And a comment briefly describing their purpose
;-------------------------------------------------
; INPUTS: each_variable Gets a description
; [optional_params] When defining multiple macros with the same name,
; optional params are in brackets. They work like
; optional params in C++17 - to specify a particular
; param you must specify all previous ones as well.
; [another = 2] Another optional param, but with a default value
;-------------------------------------------------
; MODIFIES: A, X, Y, $And_variables_as_appropriate
.macro MACROS_ARE_ALWAYS_UPPER_CASE
.endmacro
.define DEFINES_ARE_ALSO_UPPER_CASE=1
Memory_mapped_registers_start_with_upper_case=$9F25
Global_variables_will_also_follow_this_convention=$9F26
;=================================================
; Functions_also_get_a_header_with_their_name
; And a comment briefly describing their purpose
;-------------------------------------------------
; INPUTS: A Register or Variable_as_appropriate
;
;-------------------------------------------------
; MODIFIES: A, X, Y, And_variables_as_appropriate
.proc function_names_are_lower_case:
jsr
.endproc
;=================================================
; And_yes_the_modifies_section_implies
; That I am using __cdecl() calling semantics
; and it is up to the caller to preserve anything
; they need.
;-------------------------------------------------
; INPUTS: A Register or Variable_as_appropriate
;
;-------------------------------------------------
; MODIFIES: A, X, Y, And_variables_as_appropriate
.proc sys_function_names_from_a_lib_are_prefixed_with_a_subsytem_name_or_abbreviation:
jsr ; Single-line, inline comments start on a convenient tab indentation
.endproc
; Multi-line, comments within executable code prefers to start
; on the same tab indentation as instructions. This is to differentiate
; from comments outside of an executable context.
loop:
Any
loops
that
are
more
than
12
lines
need
a
real
label
jmp loop
: short
loops
dont
jmp :-
;=================================================
; Data
;
;-------------------------------------------------
.data
Constant_data_variables_go_into_their_own_block:
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
;=================================================
; Variables
;
;-------------------------------------------------
.data
Global_variable_labels_begin_with_upper_case: .byte $00
Sys_global_variables_from_a_lib_are_prefixed_with_a_subsystem_name_or_abbreviation: .byte 00
Large_blocks_of_data_begin_on_the_following_line:
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; Avoid putting more than 16 bytes on a single line, for readability.