Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yamnikov-oleg/nasmfmt
Formatter for NASM source files
https://github.com/yamnikov-oleg/nasmfmt
Last synced: about 5 hours ago
JSON representation
Formatter for NASM source files
- Host: GitHub
- URL: https://github.com/yamnikov-oleg/nasmfmt
- Owner: yamnikov-oleg
- License: mit
- Created: 2016-02-19T16:38:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T08:22:39.000Z (about 1 year ago)
- Last Synced: 2024-08-04T01:10:12.218Z (3 months ago)
- Language: Go
- Size: 19.5 KB
- Stars: 60
- Watchers: 4
- Forks: 12
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nasmfmt
Automatically format your assembly sources with a simple command.
Inspired by gofmt.
## What it does?
__In one example.__ This source:
```asm
global _startsection .text
;Starting point
_start:
mov rax,1 ;write(fd, buf, len)
mov rdi,1 ; fd
mov rsi, msg ; buf
mov rdx, msglen; len
syscallmov rax,60 ;exit(status)
mov rdi, 0
syscallsection .data
msg db "Hello world!",10
msglen equ $-msg
```Would be formatted into:
```asm
global _startsection .text
; Starting point
_start:
mov rax, 1 ; write(fd, buf, len)
mov rdi, 1 ; fd
mov rsi, msg ; buf
mov rdx, msglen ; len
syscallmov rax, 60 ; exit(status)
mov rdi, 0
syscallsection .data
msg:
db "Hello world!", 10
msglen equ $-msg```
## Features
* __Labels and instructions indentation.__
```asm
label:
add rax, rbx
```
Becomes:
```asm
label:
add rax, rbx
```* __Comments indentation.__
```asm
; Start of the cycle
cycle:
inc rcx ; Make it bigger
jmp cycle ; Because why not?
; Here's no cycle
```
Becomes:
```asm
; Start of the cycle
cycle:
inc rcx ; Make it bigger
jmp cycle ; Because why not?
; Here's no cycle
```* __Consistent labels style.__
```asm
one_style: test rax, rbx
another_style:
test rax, rbxone_style:
db "Message"
another_style db "Message"
```
Becomes:
```asm
one_style:
test rax, rbx
another_style:
test rax, rbxone_style:
db "Message"
another_style:
db "Message"```
* __Consistent commas style.__
```asm
add rax,rbx
add rax, rbx
add rax, rbx```
Becomes:
```asm
add rax, rbx
add rax, rbx
add rax, rbx
```* __No extra spaces and empty lines.__
```asm
add_func:
mov rax, rdi
add rax, rsi
retsub_func:
mov rax, rdi
sub rax, rsi
ret
```
Becomes:
```asm
add_func:
mov rax, rdi
add rax, rsi
retsub_func:
mov rax, rdi
sub rax, rsi
ret
```## Issues
There might be some issues since I have not tested it on all nasm functionality.
Please, [report](https://github.com/yamnikov-oleg/nasmfmt/issues/new), if you found some._Would it work with other assemblers?_ May be, since most assembly syntaxes are similar.
## Usage
```
Usage: nasmfmt [params] [file1 [file2 ...]]
Parameters:
-ci int
Indentation for comments in spaces (default 40)
-ii int
Indentation for instructions in spaces (default 8)
```Examples:
* `nasmfmt main.asm funcs1.asm funcs2.asm`
* `nasmfmt -ii 4 main.asm`
* `nasmfmt -ii 4 -ci 36 main.asm`## Installing
Visit [Releases](https://github.com/yamnikov-oleg/nasmfmt/releases) to download a binary for your platform.
## Building
Building requires latest version of golang from [golang.org](https://golang.org/).
If you installed one, run `go install github.com/yamnikov-oleg/nasmfmt@latest`. Built binary will be located in your $GOPATH/bin.