nasmfmt

command module
v2.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 7 Imported by: 0

README

nasmfmt2

Automatically format your assembly sources with a simple command.

nasmfmt2 is a rewrite of yamnikov-oleg/nasmfmt. The rewrite features an overall better parser that is also reusable as a library.

The main reason for the rewrite is for ease of maintenance and for style-compatibility with Professor Floyd Holliday's CPSC-240 Assembly class.

Inspired by gofmt.

Example

global _start


section .text

   ;Starting point
_start:
mov rax,1 ;write(fd, buf, len)
mov rdi,1  ; fd
mov rsi, msg   ; buf
mov rdx,  msglen; len
  syscall

mov rax,60 ;exit(status)
mov rdi, 0
  syscall

section .data
msg    db "Hello world!",10
msglen equ $-msg

turns into

global _start

section .text

; Starting point
_start:
        mov     rax, 1                 ; write(fd, buf, len)
        mov     rdi, 1                 ; fd
        mov     rsi, msg               ; buf
        mov     rdx, msglen            ; len
        syscall 

        mov     rax, 60                ; exit(status)
        mov     rdi, 0
        syscall 

section .data

msg db "Hello world!",10

msglen equ $-msg

Installing

Requires Go 1.18+.

go install github.com/diamondburned/nasmfmt/v2@latest

Vim + ALE integration

autocmd BufRead,BufNewFile *.asm    set filetype=nasm

function! FixNasmfmt(buffer) abort
    return {
    \   'command': 'nasmfmt -'
    \}
endfunction

execute ale#fix#registry#Add('nasmfmt', 'FixNasmfmt', ['nasm'], 'nasmfmt')

let g:ale_fixers = {
	\ 'nasm': [ "nasmfmt" ],
	\ }

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL