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

Issues
  • 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
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 4 Aug 5, 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 141 Aug 10, 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 15 May 4, 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 40 Jul 28, 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
Repo for the DSA Mini-project Directory Manager

Directory Manager Repo for the DSA Mini-project Directory Manager Installation and Setup To setup the program on your desktop, do the following. git c

Pramod Rao Budramane 5 Oct 16, 2021
Unofficial Firmware for the Prusa Mini

Llama Mini Unofficial Firmware for the Prusa Mini and Mini+ One of Prusa's llamas escaped from HQ ( ?? ??‍♂️ ) and decided to make his own version of

Matthew Lloyd 60 Aug 3, 2022
ESP32 + Arducam Mini 2MP Plus Edge Impulse Example

Minimal example code for running an Edge Impulse image classification network with the ESP32, ArduCAM, and PlatformIO

David Schwarz 6 Apr 23, 2022
mini-plugin host as plugin

DISTRHO Ildaeil DISTRHO Ildaeil is mini-plugin host working as a plugin, allowing one-to-one plugin format reusage. Load a VST2 plugin inside a LV2 ho

DISTRHO 41 Jul 28, 2022
Lo-Fi SAMD21 based mini chip tune synthesizer - Seeed Studio - Seeeduino XIAO arduino project

samd21_mini_synth Lo-Fi SAMD21 based mini chip tune synthesizer Seeed Studio - Seeeduino XIAO arduino project link to the video Description This time

Marcel 5 Jun 14, 2022
Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele

Wortuhr_ESP8266 Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele, Webzugriff So

null 24 Jul 11, 2022
Dummy-Robot my super mini robot arm robot items

Dummy-Robot 我的超迷你机械臂机器人项目。 资料待整理 已添加3D模型设计源文件。 已添加夹爪硬件设计文件和LED灯环PCB 已添加无线空间定位控制器PCB文件 已添加无线示教器Peak软硬件工程(作为submodule) 已添加REF的硬件设计文件 已添加DummyStudio上位机 已

稚晖 8k Aug 10, 2022
ESP8266 (Wemos D1 Mini) NeoPixel controller for RepRapFirmware (BLV printers)

Overview This project is designed to handle NeoPixel control on an ESP8266 (Wemos D1 mini) and offload it from RepRapFirmware. Features WiFi-enabled W

Perry 2 Dec 6, 2021
A "mini" implementation of vim :3

minivim info A "mini" implementation of vim :3 It uses VT100 escape characters (I will implement ncurses in the future probably). P.S. I know they are

izenynn 7 Jun 9, 2022