From c595562343d2d064d95f82425b64de738fa85d42 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 29 Sep 2015 13:25:42 +1000 Subject: [PATCH] Add assembly code style to README & emacs dir-locals --- .dir-locals.el | 16 ++++++++++++++++ README.md | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index d14fc88..6eccfa9 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -6,4 +6,20 @@ (c-file-style . "bsd") (c-basic-offset . 4) ) + (asm-mode + (indent-tabs-mode . nil) + ; this is basically a hack so asm-mode indents with spaces not tabs + ; taken from http://stackoverflow.com/questions/2668563/emacs-indentation-in-asm-mode + ; (moving to gas-mode may be a better choice) + (tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))) + (asm-comment-char . "#") + ) ) + +; IMPORTANT: If you want to write assembly and have indenting to not be infuriating, +; you probably also want this in your .emacs file: +; +; (add-hook 'asm-mode-hook '(lambda () (setq indent-line-function 'indent-relative))) +; +; This is not safe to set as a local variable. + diff --git a/README.md b/README.md index 144ea33..fc2c70b 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,17 @@ The best way to write suitable code is to first add documentation somewhere like ## Coding Style -For new contributions, please use BSD style and indent using 4 spaces. If you're an emacs user then there is a .dir-locals.el file in the root which configures cc-mode. +For new contributions in C, please use BSD style and indent using 4 spaces. + +For assembly, please use the following: +* Instructions indented using 8 spaces. +* Inline comments use `#` as a comment delimiter. +* Comments on their own line(s) use `/*`..`*/`. +* First operand of each instruction should be vertically aligned where possible. +* For xtensa special registers, prefer `wsr aX, SR` over `wsr.SR aX` + +If you're an emacs user then there is a .dir-locals.el file in the root which configures cc-mode and asm-mode (you will need to approve some variable values as safe). See also +the additional comments in .dir-locals.el, if you're editing assembly code. Upstream code is left with the indentation and style of the upstream project.