Skip to content

Commit

Permalink
Add proposals for fixing STYLE.md (#941)
Browse files Browse the repository at this point in the history
Fixes #939
  • Loading branch information
rawr51919 committed Jun 18, 2022
1 parent 0a1b6b4 commit 51b0a3f
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions STYLE.md
Expand Up @@ -8,7 +8,6 @@ When you come across an edge case that isn't referenced in this guide, please ad
## Comments

```asm
; Use tabs for indentation, and spaces for alignment.
; When tabs get in the way of alignment, use spaces instead.
Expand All @@ -30,40 +29,33 @@ When you come across an edge case that isn't referenced in this guide, please ad
; under 30 chars per line, including tabs.
; Comments should go above the code they're describing, not below, and not inline.
ld a, [hl]
add b
ld [hl], a
ret
; Avoid comments on the same line as instructions.
cp 10
jr c, .elsewhere ; don't do this
; If you have a larger comment and want to make
; a side note on a snippet of code:
; You can indent the comment,
; but each line should be shorter
; and spaced away from the parent comment
halt
nop
; To comment out code, put the ; before the tab indent.
; nop
cp 10
; jr c, .bye
ret
```

## Labels

```asm
; ROM Labels
PascalCase: ; label
PascalCase:: ; global label
Expand All @@ -84,21 +76,18 @@ DEF rBGP EQU $ff47 ; hardware register
; Most other constants should be upper case
DEF UPPER_CASE EQU 1
; Long lists of constants should be aligned
DEF SHORT_CONSTANT EQU 1
DEF LONGER_CONSTANT EQU 2
DEF PRETTY_LONG_CONSTANT EQU 3
DEF TINY EQU 4
DEF BUT_ONLY_RELATED_CONSTANTS EQU 5
```

## Directives

```asm
; meta and high-level directives should be uppercase
SECTION "section", ROMX
INCLUDE "filename"
Expand All @@ -114,7 +103,6 @@ DEF TEST EQU 2
db 1
dw 2
my_macro SOME_CONSTANT
; one exception is RGB
RGB 31, 31, 31
Expand All @@ -128,17 +116,14 @@ set X, 1
rept 10
nop
endr
```

## Macros

```asm
MACRO when_in_doubt_lowercase
; only shift if it's required or more readable
; dont
db \1
shift
Expand All @@ -161,7 +146,5 @@ ENDM
MACRO UPPER_CASE_IS_OK_SOMETIMES
; but I can't think of any examples besides ACRONYMS
ENDM
```

0 comments on commit 51b0a3f

Please sign in to comment.