All Projects → DQNEO → goas

DQNEO / goas

Licence: MIT license
port of GNU Assembler written in go

Programming Languages

assembly
5116 projects

Labels

Projects that are alternatives of or similar to goas

Tengine
Tengine is a lite, high performance, modular inference engine for embedded device
Stars: ✭ 4,012 (+7615.38%)
Mutual labels:  x86-64
jsix
A hobby operating system for x86_64, boots with UEFI.
Stars: ✭ 60 (+15.38%)
Mutual labels:  x86-64
SDA
SDA is a rich cross-platform tool for reverse engineering that focused firstly on analysis of computer games. I'm trying to create a mix of the Ghidra, Cheat Engine and x64dbg. My tool will combine static and dynamic analysis of programs. Now SDA is being developed.
Stars: ✭ 98 (+88.46%)
Mutual labels:  x86-64
Asmjit
Machine code generation for C++
Stars: ✭ 2,874 (+5426.92%)
Mutual labels:  x86-64
kwast
Rust operating system running WebAssembly as userspace in ring 0
Stars: ✭ 83 (+59.62%)
Mutual labels:  x86-64
Bazel bin
Bazel's pre-built binaries for armv7l / aarch64 / x86_64.
Stars: ✭ 23 (-55.77%)
Mutual labels:  x86-64
Asm Cli
Interactive shell of assembly language(X86/X64) based on unicorn and keystone
Stars: ✭ 211 (+305.77%)
Mutual labels:  x86-64
vox
Vox language compiler. AOT / JIT / Linker. Zero dependencies
Stars: ✭ 288 (+453.85%)
Mutual labels:  x86-64
bf256
Brainfuck compiler under 256 bytes in size.
Stars: ✭ 21 (-59.62%)
Mutual labels:  x86-64
bmod
bmod parses binaries for modification/patching and disassembles machine code sections.
Stars: ✭ 12 (-76.92%)
Mutual labels:  x86-64
Funchook
Hook function calls by inserting jump instructions at runtime
Stars: ✭ 253 (+386.54%)
Mutual labels:  x86-64
oberon-07-compiler
Oberon-07 compiler for x64 (Windows, Linux), x86 (Windows, Linux, KolibriOS), MSP430x{1,2}xx, STM32 Cortex-M3
Stars: ✭ 45 (-13.46%)
Mutual labels:  x86-64
saturn
A microkernel based operating system developed from scratch. This repository also includes all Saturn services and applications.
Stars: ✭ 21 (-59.62%)
Mutual labels:  x86-64
Bdvl
LD_PRELOAD Linux rootkit (x86 & ARM)
Stars: ✭ 232 (+346.15%)
Mutual labels:  x86-64
kasm
Assembler library for Kotlin
Stars: ✭ 40 (-23.08%)
Mutual labels:  x86-64
Mlibc
Portable C standard library
Stars: ✭ 225 (+332.69%)
Mutual labels:  x86-64
asmrepl
A REPL for x86-64 assembly language
Stars: ✭ 852 (+1538.46%)
Mutual labels:  x86-64
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (+94.23%)
Mutual labels:  x86-64
libcluon
libcluon is a small and efficient, single-file and header-only library written in modern C++ to power microservices.
Stars: ✭ 81 (+55.77%)
Mutual labels:  x86-64
asm2cfg
Python command-line tool and GDB extension to view and save x86, ARM and objdump assembly files as control-flow graph (CFG) pdf files
Stars: ✭ 42 (-19.23%)
Mutual labels:  x86-64

goas - a port of GNU Assembler written in go

goas is an assembler that behaves like as, GNU Assembler.

This is just a toy program to illustrate how an assembler works. Actually I learned how an assembler works by writing this program :).

It does not mean to support all syntax or instructions, but Linux x86-64 AT&T syntax only. However, for any input it supports, it behaves exactly the same as as, which means it produces the very same binary files (*.o) as as does.

The most interesting thing is that it can assemble my Go compiler babygo. (You can see it by running make babygo.)

Requirements

You need a linux with gcc installed. If you are using MacOS or Windows, you can use my docker image to run goas.

docker run --rm -it -v `pwd`:/mnt/goas -w /mnt/goas dqneo/ubuntu-build-essential:go bash 

How to build

$ go build

How to use

Prepare a small assembly file test.s

.text
.global _start
_start:
  movq $42, %rdi # status
  movq $60, %rax # sys_exit
  syscall

And you can assemble it

$ ./goas -o test.o test.s
$ ld -o test test.o
$ ./test; echo $?
42

Demo

goas-min-demo

Supported Instructions

See test files under /t and /t2 directory to know what syntax it can assemble.

Design

goas is composed of 4 files.

File Role
parser.go parser
encoder.go instruction encoder
elf_writer.go ELF format writer
main.go miscellaneous tasks

Parser

parser.go is a simple recursive descent parser. The boundary between lexer nd parser are not clearly separated.

Each line of source code is converted into a statement object.

It produces a list of statements in the end.

Instruction encoder

encoder.go translates an instruction with operands into a piece of x86-64 binary machine code.

ELF format Writer

elf_writer.go composes an object which represents ELF file format and write it into a binary object file.

Test

$ make test

References

ELF

GNU Asssembler

X86-64 Instruction set and encoding

License

MIT

Author

@DQNEO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].