Kunde21 / asm2plan9s

Tool to generate BYTE sequences for Go assembly as generated by YASM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

asm2plan9s

Tool to generate BYTE sequences for Go assembly as generated by YASM.

Installation

Make sure YASM is installed on your platform. Get the code and compile with go install.

usage: -h help -w write back to the file

Example

$ more example.s
                                 // @ VPADDQ  XMM0,XMM1,XMM8
$ asm2plan9s -w example.s
$ echo example.s
    LONG $0xd471c1c4; BYTE $0xc0 // @ VPADDQ  XMM0,XMM1,XMM8

Starting position of instruction

The instruction to be assembled needs to start with a // @ The preceding characters will be overwitten by the correct sequence (irrespective of its contents) so when changing the instruction, rerunning asm2plan9s will update the BYTE sequence generated. Macro definitions will be preserved, so #define macro // @ VZEROUPPER won't overwrite the #define macro portion.

Support for defines

If you are using #define for 'macros' with the back-slash delimiter to continue on the next line, this will be preserved.

For instance:

                                 \ // @ VPADDQ  XMM0,XMM1,XMM8

will be assembled into

    LONG $0xd471c1c4; BYTE $0xc0 \ // @ VPADDQ  XMM0,XMM1,XMM8

Support for Intel and GoAsm formats:

Instructions can be in Intel or GoAsm format. So, both of these lines will assemble to the same byte code:

	// @ VFMADD123PD xmm1, xmm0, [rax]
	// @ VFMADD123PD X0, (AX), X1

Becomes:

	LONG $0x98f9e2c4; BYTE $0x08 // @ VFMADD123PD xmm1, xmm0, [rax]
	LONG $0x98f9e2c4; BYTE $0x08 // @ VFMADD123PD X0, (AX), X1

asmfmt

Assembled code will be formatted with asmfmt.

emacs

To run assembler and formatter on save, add a hook in your init file:

(defun asm-mode-setup ()
  (set (make-local-variable 'gofmt-command) "asm2plan9s")
  (add-hook 'before-save-hook 'gofmt nil t)
)

(add-hook 'asm-mode-hook 'asm-mode-setup)

Extensive example

For a more extensive example see compressAvx_amd64.s

About

Tool to generate BYTE sequences for Go assembly as generated by YASM


Languages

Language:Go 97.7%Language:Assembly 2.3%