Created
September 13, 2020 07:01
-
-
Save TACIXAT/b8b6b3ec671e98dc70f926c387370ec2 to your computer and use it in GitHub Desktop.
ASM instruction builder in Golang.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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