Add proposals for fixing STYLE.md (#941)

Fixes #939
This commit is contained in:
Colton G. Rushton 2022-06-17 23:41:16 -03:00 committed by GitHub
parent 0a1b6b4f15
commit 51b0a3fea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 17 deletions

View File

@ -8,7 +8,6 @@ When you come across an edge case that isn't referenced in this guide, please ad
## Comments ## Comments
```asm ```asm
; Use tabs for indentation, and spaces for alignment. ; Use tabs for indentation, and spaces for alignment.
; When tabs get in the way of alignment, use spaces instead. ; When tabs get in the way of alignment, use spaces instead.
@ -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. ; under 30 chars per line, including tabs.
; Comments should go above the code they're describing, not below, and not inline. ; Comments should go above the code they're describing, not below, and not inline.
ld a, [hl] ld a, [hl]
add b add b
ld [hl], a ld [hl], a
ret ret
; Avoid comments on the same line as instructions. ; Avoid comments on the same line as instructions.
cp 10 cp 10
jr c, .elsewhere ; don't do this jr c, .elsewhere ; don't do this
; If you have a larger comment and want to make ; If you have a larger comment and want to make
; a side note on a snippet of code: ; a side note on a snippet of code:
; You can indent the comment, ; You can indent the comment,
; but each line should be shorter ; but each line should be shorter
; and spaced away from the parent comment ; and spaced away from the parent comment
halt halt
nop nop
; To comment out code, put the ; before the tab indent. ; To comment out code, put the ; before the tab indent.
; nop ; nop
cp 10 cp 10
; jr c, .bye ; jr c, .bye
ret ret
``` ```
## Labels ## Labels
```asm ```asm
; ROM Labels ; ROM Labels
PascalCase: ; label PascalCase: ; label
PascalCase:: ; global label PascalCase:: ; global label
@ -84,7 +76,6 @@ DEF rBGP EQU $ff47 ; hardware register
; Most other constants should be upper case ; Most other constants should be upper case
DEF UPPER_CASE EQU 1 DEF UPPER_CASE EQU 1
; Long lists of constants should be aligned ; Long lists of constants should be aligned
DEF SHORT_CONSTANT EQU 1 DEF SHORT_CONSTANT EQU 1
DEF LONGER_CONSTANT EQU 2 DEF LONGER_CONSTANT EQU 2
@ -92,13 +83,11 @@ DEF PRETTY_LONG_CONSTANT EQU 3
DEF TINY EQU 4 DEF TINY EQU 4
DEF BUT_ONLY_RELATED_CONSTANTS EQU 5 DEF BUT_ONLY_RELATED_CONSTANTS EQU 5
``` ```
## Directives ## Directives
```asm ```asm
; meta and high-level directives should be uppercase ; meta and high-level directives should be uppercase
SECTION "section", ROMX SECTION "section", ROMX
INCLUDE "filename" INCLUDE "filename"
@ -114,7 +103,6 @@ DEF TEST EQU 2
db 1 db 1
dw 2 dw 2
my_macro SOME_CONSTANT my_macro SOME_CONSTANT
; one exception is RGB ; one exception is RGB
RGB 31, 31, 31 RGB 31, 31, 31
@ -128,17 +116,14 @@ set X, 1
rept 10 rept 10
nop nop
endr endr
``` ```
## Macros ## Macros
```asm ```asm
MACRO when_in_doubt_lowercase MACRO when_in_doubt_lowercase
; only shift if it's required or more readable ; only shift if it's required or more readable
; dont ; dont
db \1 db \1
shift shift
@ -161,7 +146,5 @@ ENDM
MACRO UPPER_CASE_IS_OK_SOMETIMES MACRO UPPER_CASE_IS_OK_SOMETIMES
; but I can't think of any examples besides ACRONYMS ; but I can't think of any examples besides ACRONYMS
ENDM ENDM
``` ```