Giter Site home page Giter Site logo

iasm's Introduction

IASM -- Interactive Assembler for Go.

Dual-purpose assembly engine written in pure Golang.

The x86_64 package was ported from a Python module PeachPy, with some adaption to the Go language features.

Currently, IASM only supports x86_64, because it's the only architecture I am very familiar with.

It can be used as a dynamic assembler

This can be used to implement:

  • JIT engine
  • Compiler backend
  • And more !

See x86_64/program_test.go for more info.

It can also be used as a static assembler

For macOS:

git clone https://github.com/chenzhuoyu/iasm
cd iasm
go build ./cmd/iasm
./iasm -h
./iasm -f macho -D __Darwin__ -o helloworld example/helloworld.s
./helloworld 

It also contains an interactive REPL shell

Just run IASM without any arguments.

./iasm

iasm's People

Contributors

chenzhuoyu avatar guangmingluo avatar

Stargazers

Maple avatar Koichi Shiraishi avatar kinggo avatar

Watchers

Felix021 avatar  avatar Pure White avatar Felix avatar  avatar Wenju Gao avatar  avatar liu avatar  avatar

Forkers

felix021

iasm's Issues

Too big binary file size

mkdir binarysize
cd binarysize
go mod init binarysize

add main.go with following content:

package main

import (
	"fmt"

	"github.com/bytedance/sonic"
)

func main() {
	m := map[string]string{
		"hello": "world",
	}
	str, err := sonic.MarshalString(m)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(str)
}
go mod tidy
go build main.go

ls -lh binaryzie
# the file size is nearly ~26MB

try analyze binary size with two tools:

go install github.com/jondot/goweight@latest

goweight --tags='-s -w' main.go
#   92 MB github.com/cloudwego/iasm/x86_64
#   12 MB runtime
#  2.6 MB reflect
#  2.5 MB github.com/bytedance/sonic/internal/decoder
#  1.8 MB github.com/twitchyliquid64/golang-asm/obj
#  1.8 MB syscall
#  1.7 MB github.com/bytedance/sonic/internal/encoder
#  1.6 MB github.com/twitchyliquid64/golang-asm/obj/x86
#  1.6 MB github.com/twitchyliquid64/golang-asm/obj/arm64
#  1.4 MB encoding/json
#  1.3 MB os
#  1.3 MB github.com/twitchyliquid64/golang-asm/obj/s390x
#  1.3 MB github.com/bytedance/sonic/ast
#  1.2 MB time
#  1.1 MB github.com/twitchyliquid64/golang-asm/obj/ppc64
#  1.1 MB internal/abi
#  ......
wget https://github.com/Zxilly/go-size-analyzer/releases/download/0.1.0/gsv
chmod +x ./gsv

./gsv ./binarysize 
# Analyzing binary: binarysize
# github.com/cloudwego/iasm              : 10.78MB
# .gopclntab                             : 4.25MB
# .debug_info                            : 1.87MB
# internal/godebug                       : 1.62MB
# .debug_line                            : 1.59MB
# .debug_loc                             : 1.03MB
# github.com/twitchyliquid64/golang-asm  : 919.80KB
# github.com/bytedance/sonic             : 734.27KB
# runtime                                : 652.70KB
# .debug_ranges                          : 650.91KB
# .noptrdata                             : 626.82KB
# .text                                  : 154.76KB
# .debug_frame                           : 111.91KB
# .data                                  : 106.64KB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.