A mini x86-64 assembler for fun

Related tags

Miscellaneous minias
Overview

minias

A mini assembler for x86-64, written for fun and learning.

Minias can assemble itself and many/most things compiled with the cproc C compiler i.e., large amounts of real world software.

Project Goals:

  • A simple, tiny, fast implementation (in that order).
  • Assemble the output of cproc/qbe and chibicc.
  • Relocatable elf output.

Non Goals:

  • Assemble every assembly instruction.
  • Assemble other architectures.
  • Work as a library.

Building

Install the peg/leg parser generator, make and a C compiler and run:

make

or

leg asm.peg > asm.peg.inc
cc -O2 *.c -o minias

Roadmap

Essential features:

  • Self host with cproc.
  • Self host with chibicc.

Bonus features:

  • Two pass jump relaxing.
  • Immediate relaxing.
  • Simple immediate expressions.
  • Assemble a libc.
  • Test every opcode with all variants in our test suite.
  • Parser that doesn't depend on peg/leg.

Notes

  • Minias deliberately does not free allocated memory as it all is freed by the OS at the end of execution. Memory usage is still quite light as it uses string and value interning. In the future we could use an arena allocator for minias and still avoid manual calls to free.

  • Minias deliberately keeps the peg grammar quite repetitive and simple, please keep it this way.

  • Performance is limited by the parser, it would be interesting to see if we can improve the parser generator upstream. That being said, performance is often better than gnu as and much better than the clang assembler,

  • One day it would be nice to write a 'minipeg' in a single .c file that can be bundled in projects.

Contact

Ask questions on the mailing list. Submit bugs to the ticket system.

Resources

You might also like...
funky fun fuzzer

FunkyFunFuzzer / fffz FunkyFunFuzzer / fffz is an attempt at a file fuzzer prioritising usability while striving for real-world performance. It is a m

A basic example of IoT for fun
A basic example of IoT for fun

esp32 simple led IoT A basic example of IoT for fun about Im using platformio for upload this project so u should be used that if you want to use this

A fast and fun layout manager for FLTK
A fast and fun layout manager for FLTK

Fl_Flow A fast and fun layout manager for FLTK Fl_Flow is a layout manager for FLTK which works in a largely different manner to existing systems you

Having some fun with the C++ programming language.
Having some fun with the C++ programming language.

Having some fun with the C++ programming language. Coding Environment Text editor. Visual Studio Code for Windows Compiler. MingW GCC 6.3.0 Coding sty

Just a password tool that I make for fun and the sake of my fascination

Note I made this in 1 day and I only have 1 years of experience, feel free to critique my spaghetti of a code. And if 15 chars of password isn't enoug

MasterPlan is a project management software / visual idea board software. It attempts to be easy to use, lightweight, and fun.
MasterPlan is a project management software / visual idea board software. It attempts to be easy to use, lightweight, and fun.

MasterPlan is a customizeable graphical project management software for independent users or small teams. If you need to share plans across a whole co

A fun Snowfall/Rainfall Project with Interactions

snowfall Snowfall Project Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is yo

nn - a toy operating system, designed for fun

nn is a toy operating system, designed for fun (and from a position of general naïveté). i'm not sure how far it'll go, but one thing's for sure: it'll probably implement nearly nothing.

A Coding some basic rpg systems in C++ for practice and fun

demo_rpg A Coding some basic rpg systems in C++ for practice and fun. YT Playlist Designs Ideas Some quick theoretical lists that we will iterate on.

Comments
  • Use smaller encodings in a few more cases.

    Use smaller encodings in a few more cases.

    None of these are bugs, but they showed up when comparing disassembly between gas and minias.

    I'm less confident about the imul change than the other two. Please double-check that it looks correct to you.

    opened by michaelforney 0
  • Use void * for functions that access bytes of object representation.

    Use void * for functions that access bytes of object representation.

    Although out() and secaddbytes() only use their argument to call fwrite()/memcpy(), using the type uint8_t * suggests that it might be dereferenced as uint8_t. In general, it is undefined behavior to access an object through a uint8_t pointer, since uint8_t is not necessarily a character type.

    So, just use void * to avoid some casts and implication of possible undefined behavior.

    opened by michaelforney 0
  • Use Elf64_Rela for relocations.

    Use Elf64_Rela for relocations.

    I needed this to run hello world on my system (otherwise I get a segfault). I'm not sure exactly why Elf64_Rel worked for you but not for me, but since the spec says to always use explicit addends, this seems like the right thing to do.

    opened by michaelforney 0
Owner
null
x86 Assembler used for generating shellcode

Intel x86 assembler [email protected] syntax: Decimal “integers begin with a non-zero digit followed by zero or more decimal digits (0–9)” B

thescientist 1 Dec 28, 2022
x86-64 Assembler based on Zydis

Zasm : x86-64 Assembler based on Zydis Why? Some of my projects were using Zydis and AsmJit where instructions where were first decoded with Zydis and

ζeh Matt 178 Dec 29, 2022
This is a prank windows malware, is only for fun, it's just for fun, it's not harmful

DBUSTER-PRO (C) 2021-2022 DioBrando This is a prank windows malware, just for fun, nothing harmful. I will teach you how to compile, and remove malwar

Dio brando 8 Apr 15, 2022
A port of the Linux x86 IOLI crackme challenges to x86-64

This is a port of the original Linux x86 IOLI crackme binaries to x86-64. The original set of IOLI crackmes can be found here: https://github.com/Maij

Julian Daeumer 4 Mar 19, 2022
Commodore 6502ASM, the original 6502/65C02/65CE02 Assembler used by Commodore for C65 project

Commodore 6502ASM This is the source code of the 6502/65C02/65CE02 assembler developed and used by Commodore for the C65 project. It aims to be compat

Michael Steil 17 Nov 29, 2022
ASMotor is a portable and generic assembler engine and development system written in ANSI C99

ASMotor is a portable and generic assembler engine and development system written in ANSI C99 and licensed under the GNU Public License v3. The package consists of the assembler, the librarian and the linker. It can be used as either a cross or native development system.

null 42 Nov 18, 2022
A simple assembler, made primarily for assembling output from my compiler.

Assembler This assembler is not currently meant for general use. It supports only the instructions and features emitted (and used) in my C compiler. I

null 2 Nov 14, 2021
Toy 8 bit CPU with a real assembler

neko8 neko8 is a 8 bit CPU emulator designed to be easy to learn written in C. It uses its own simple architecture and can be programmed in its own fo

rem 4 Jan 4, 2022
A basic assembler

Assembler ASSEMBLER DERLEYİCİSİ Programlama Dilleri (derleyiciler) giriş olarak yazılan bir programın kaynak kodunu alır (kodun doğru yazıldığı varsay

Batuhan Tomo 1 Nov 22, 2021
A fully customisable assembler for your own instruction sets

CASM A fully customisable assembler for your own instruction sets! What Is CASM? ?? Documentation ?? Command-Line Usage ?? How To Install CASM ?? Buil

Sjoerd Vermeulen 2 May 7, 2022