Skip to content

Instantly share code, notes, and snippets.

@TACIXAT
Created September 13, 2020 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TACIXAT/b8b6b3ec671e98dc70f926c387370ec2 to your computer and use it in GitHub Desktop.
Save TACIXAT/b8b6b3ec671e98dc70f926c387370ec2 to your computer and use it in GitHub Desktop.
ASM instruction builder in Golang.
package main
/*
This legend twitchyliquid64 mirrored cmd/internal/obj as an importable package.
Use the instruction builder then assemble. More examples in their repo.
*/
import (
asm "github.com/twitchyliquid64/golang-asm"
"github.com/twitchyliquid64/golang-asm/obj"
"log"
)
func main() {
b, err := asm.NewBuilder("amd64", 64)
if err != nil {
log.Fatal(err)
}
p := b.NewProg()
p.As = obj.ARET
b.AddInstruction(p)
log.Printf("%x\n", b.Assemble())
// c3 :)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment