{"id":37160574,"url":"https://github.com/anonymouse64/asm2go","last_synced_at":"2026-01-14T19:04:53.036Z","repository":{"id":88918755,"uuid":"131162088","full_name":"anonymouse64/asm2go","owner":"anonymouse64","description":"Automatically generate golang assembly files from native assembly code","archived":false,"fork":false,"pushed_at":"2018-06-06T20:18:09.000Z","size":146,"stargazers_count":14,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T06:21:50.130Z","etag":null,"topics":["assembly","golang","golang-assembly"],"latest_commit_sha":null,"homepage":null,"language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anonymouse64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-26T13:45:14.000Z","updated_at":"2024-02-12T03:34:48.000Z","dependencies_parsed_at":"2023-06-13T03:45:14.898Z","dependency_job_id":null,"html_url":"https://github.com/anonymouse64/asm2go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anonymouse64/asm2go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonymouse64%2Fasm2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonymouse64%2Fasm2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonymouse64%2Fasm2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonymouse64%2Fasm2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anonymouse64","download_url":"https://codeload.github.com/anonymouse64/asm2go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonymouse64%2Fasm2go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28431221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","golang","golang-assembly"],"created_at":"2026-01-14T19:04:52.210Z","updated_at":"2026-01-14T19:04:53.026Z","avatar_url":"https://github.com/anonymouse64.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asm2go\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/anonymouse64/asm2go)](https://goreportcard.com/report/github.com/anonymouse64/asm2go)\n[![license](https://img.shields.io/badge/license-GPLv3-blue.svg)](LICENSE)\n[![Build Status](https://travis-ci.com/anonymouse64/asm2go.svg?branch=master)](https://travis-ci.com/anonymouse64/asm2go)\n[![codecov](https://codecov.io/gh/anonymouse64/asm2go/branch/master/graph/badge.svg)](https://codecov.io/gh/anonymouse64/asm2go)\n[![Snap Status](https://build.snapcraft.io/badge/anonymouse64/asm2go.svg)](https://build.snapcraft.io/user/anonymouse64/asm2go)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fanonymouse64%2Fasm2go.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fanonymouse64%2Fasm2go?ref=badge_shield)\n\n\nThis project aims to automatically generate working Golang assembly from native assembly and a golang declaration file, mainly used for implementing performance-intensive complex functions in assembly. \n\n## Usage\n\n`asm2go` requires 2 files, a native assembly file that assembles properly using `as` (the GNU assembler), and a Golang declaration file that contains signatures for the functions implemented in assembly. These names must match exactly, if a symbol in the assembly doesn't have a corresponding go function declaration the generation fails (this restriction is somewhat arbitrary right now and may be lifted in the future). \n\nAs to writing the actual assembly code to be translated, there are a few caveats. \n\n0. Argument calling convention in Go places arguments on the stack, so you should write the assembly code to reference the stack for accessing arguments provided to functions. This may or may not match what is normally done, for example registers are sometimes used instead for passing arguments, but referencing the stack seems to be the best way to do this.\n1. Data symbols are not yet supported. For example, defining an array of data with a symbol referring to the start of the array isn't supported. This is due to the fact that this tool translates the compiled object code into Golang assembly, at which point most data symbol references in the code have been translated into addresses, which means that simply including the array won't work as it will likely be repositioned in the final binary by go. This translation could be made to work, but it would be quite difficult.\n2. The produced Golang assembly currently includes a RET at the end, which means that you shouldn't also include returning instructions (such as `bx lr` for ARM) as the Golang assembler will already insert this information.\n3. Supported instructions are translated from native assembly into Golang's supported syntax. For example `mov r2 lr` in native ARM is translated to `MOVW R14, R2` in native plan9 assembly. Currently this is only supported for ARM, but it would be easy to support this on other architecture's using `golang.org/x/arch`.\n4. No assembly function flags are currently supported. I eventually hope to solve this by annotating the function's declaration in the go source file. For example to insert the `NOPTR` flag, I think eventually a comment like `// asm2go:noptr` would be included above the function's declaration. Specifying the frame sizes should also probably be supported this way. It would be nice for `asm2go` to dynamically determine the size of the arguments, but this isn't currently implemented.\n\nFurthermore, the assembler must either be specified with the `-as` option, which can be a absolute path or a name on `$PATH`. In the same folder as the assembler must be the executables `strip` and `objdump` must also be available (note that assemblers specified with a prefix such as `arm-linux-gnueabihf-as` works properly; the prefix is resolved to find `arm-linux-gnueabihf-objdump`, etc - this allows cross compiling to work as expected). `strip` is used to remove debugging information from the compiled object file, and `objdump` is used to parse the actual hex instructions that are associated with instructions.\n\nAssembler options may be specified with `as-opts`, as many times as needed. For example to use the options `-march=armv7-a` and the option `-mfpu=neon-vfpv4`, you would invoke `asm2go` as follows:\n\n```\nasm2go -file somefile.s -gofile somefile.go -as-opts -march=armv7-a -as-opts -mfpu=neon-vfpv4\n```\n\nThe output can either be a file specified with the `-out` option, or if not specified the output is dumped to stdout.\n\n#### Usage message\n\n```\n$ asm2go --help\nUsage of asm2go:\n  -as string\n    \tassembler to use (default \"gas\")\n  -as-opts value\n    \tAssembler options to use\n  -file string\n    \tfile to assemble\n  -gofile string\n    \tgo file with function declarations\n  -out string\n    \toutput file to place data in (empty uses stdout)\n```\n\n## Examples\n\n### Keccak\n\nThis example uses the assembly file from the KeccakCodePackage here : https://github.com/gvanas/KeccakCodePackage. Specifically, the ARMv7A implementation here: https://github.com/gvanas/KeccakCodePackage/blob/master/lib/low/KeccakP-1600/OptimizedAsmARM/KeccakP-1600-armv7a-le-neon-gcc.s was modified to only contain the KeccakF-1600 function (it was also modified to use some constants passed in as an argument instead of hard-coded into the assembly as a symbol). \n\nTo generate the native go assembly from the native ARM assembly copied here run:\n\n\t$ git clone github.com/anonymouse64/asm2go\n\t$ cd asm2go\n\t$ go install\n\t$ export PATH=\"$GOPATH/bin:$PATH\"\n\t$ cd tests/keccak_arm\n\t$ go generate\n\t$ go build keccak_check.go\n\t$ ./keccak_check\n\tSuccess!\n\t$\n\nThis uses the go:generate comment inside `keccak_check.go`\n\nThe assembly generated uses the WORD feature of Plan9 assembly to translate all unsupported native instructions like such:\n\n```\nTEXT ·KeccakF1600(SB), 0, $0-8\n    MOVW 0x4(R13), R0  // ldr      r0        [sp #4] \n    MOVW 0x8(R13), R1  // ldr      r1        [sp #8] \n    WORD $0xed2d8b10;  // vpush    {d8-d15}  \n    WORD $0xf42007dd;  // vld1.64  {d0}      [r0 :64]!  \n    WORD $0xf42027dd;  // vld1.64  {d2}      [r0 :64]!  \n    WORD $0xf42047dd;  // vld1.64  {d4}      [r0 :64]!  \n...\n```\n\nThe only required parts are the ARM assembly file (`keccak.s`) and the go declaration file which declares the assembly-implemented function in go. The go file doesn't need anything extra, just the function declaration:\n\n```\npackage keccak\n\n// go:noescape\n// This function is implemented in keccak.s\nfunc KeccakF1600(state *[25]uint64, constants *[24]uint64)\n\n```\n\n## License\n\nThis project is licensed under the GPLv3. See LICENSE file for full license.\nCopyright 2018 Canonical Ltd.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonymouse64%2Fasm2go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanonymouse64%2Fasm2go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonymouse64%2Fasm2go/lists"}