All Projects → tgtakaoka → libasm

tgtakaoka / libasm

Licence: other
C++ library of assembler / disassembler that can run on embedded system

Programming Languages

assembly
5116 projects
Pawn
127 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to libasm

apultra
Free open-source compressor for apLib with 5-7% better ratios
Stars: ✭ 84 (+265.22%)
Mutual labels:  z80, 6502, 6809
appler
Apple ][ emulator for MS-DOS, written in 8088 assembly
Stars: ✭ 193 (+739.13%)
Mutual labels:  6502, 8086
8086-cheatsheet
8086 Microprocessor Cheat sheet with Programs
Stars: ✭ 81 (+252.17%)
Mutual labels:  8085, 8086
blog
retrohunblog
Stars: ✭ 46 (+100%)
Mutual labels:  8085, 8086
awesome-list
Awesome Lists of retrocomputing resources (6502, Apple 2, Atari, ...)
Stars: ✭ 38 (+65.22%)
Mutual labels:  z80, 6502
kernal64
A Scala Commodore 64, 128, VIC20, CBM2 and SuperCPU emulator
Stars: ✭ 87 (+278.26%)
Mutual labels:  z80, 6502
6502.Net
A .Net-based Cross-Assembler for Several 8-Bit Microprocessors
Stars: ✭ 44 (+91.3%)
Mutual labels:  z80, 6502
The-MSX-Red-Book
The MSX Red Book in Markdown format.
Stars: ✭ 85 (+269.57%)
Mutual labels:  z80
zx-spec
A unit testing framework for Sinclair ZX Spectrum assembly
Stars: ✭ 32 (+39.13%)
Mutual labels:  z80
techdocs
Reference documents for z88dk
Stars: ✭ 23 (+0%)
Mutual labels:  z80
gorilla-cpm
GORILLA.BAS port to CP/M in Turbo Modula-2. Supported terminals: VT52, VT100, ANSI, ADM-31, KayPro, C128, Memotech monochrome, CPC / Zenith Z19
Stars: ✭ 45 (+95.65%)
Mutual labels:  z80
CH552
L1 R1:WCH 24MHz MCS-51 USB MCU (CH552T/CH552P/CH552E/CH552G/CH551G)
Stars: ✭ 32 (+39.13%)
Mutual labels:  8051
rygar-emu
An emulator for the Rygar arcade game
Stars: ✭ 18 (-21.74%)
Mutual labels:  z80
zasm
Z80 / 8080 / Z180 assembler (for unix-style OS)
Stars: ✭ 47 (+104.35%)
Mutual labels:  z80
msx diagnostics
Tool written in Z80 assembler to test the MSX hardware basics.
Stars: ✭ 34 (+47.83%)
Mutual labels:  z80
pac-man-emulator
🕹 An emulator for the Pac-Man arcade machine (Zilog Z80 CPU) for Win/Mac/*nix and Xbox One.
Stars: ✭ 20 (-13.04%)
Mutual labels:  z80
mos
An assembler, code formatter, language server and debug adapter for the MOS 6502 CPU.
Stars: ✭ 27 (+17.39%)
Mutual labels:  6502
zx-spectrum-games
Collection of ZX Spectrum annotated game source code dissasemblies as .skool files
Stars: ✭ 35 (+52.17%)
Mutual labels:  z80
zx-sizif-512
ZX Spectrum CPLD-based clone for rubber case
Stars: ✭ 92 (+300%)
Mutual labels:  z80
Awesome Cpus
All CPU and MCU documentation in one place
Stars: ✭ 1,602 (+6865.22%)
Mutual labels:  z80

https://github.com/tgtakaoka/libasm/releases https://github.com/tgtakaoka/libasm/blob/main/LICENSE.md badge https://github.com/tgtakaoka/libasm/actions/workflows/arduino-ci.yml https://github.com/tgtakaoka/libasm/actions/workflows/platformio-ci.yml

libasm: cross assemble/disassemble library

The libasm allows assembling and disassembling supported retro CPUs on a small environment (less than 9kB-17kB Flash and 350B RAM on AVR Arduino).

Assembler library interface

Assembling MC68HC11 instruction in string to binary can be done in a minutes. You can also add symbol table lookup via SymbolTable interface.

#include <asm_mc6800.h>
libasm::mc6800::AsmMc6800 asm6800;
asm6800.setCpu("68HC11");

const char *text = "SUBD $90";
libasm::Insn insn(0x1000);

asm6800.encode(text, insn);
assert(insn.address()  == 0x1000);
assert(insn.length()   == 2);    // direct addressing
assert(insn.bytes()[0] == 0x93); // SUBD
assert(insn.bytes()[1] == 0x90); // $90

Disassembler library interface

To disassemble MC68000 binaries, you need to wrap memory by ArrayMemory or implements your own DisMemory interface to feed binaries. You can also add symbol table lookup via SymbolTable interface.

#include <dis_mc68000.h>
libasm::mc68000::DisMc68000 dis68k;
dis68k.setOption("relative", "true");

const uint16_t words[] = {0047372, 0x1232};
const libasm::ArrayMemory memory(0x100, words, sizeof(words));
libasm::DisMemory dismem = memory.iterator();
libasm::Insn insn(dismem.address());
char opr[80];

dis68k.decode(dismem, insn, opr, sizeof(opr));
assert(insn.address() == 0x100);
assert(std::string(insn.name()) == "jmp");
assert(std::string(opr) == "(*+$1234,pc)");

Arduino sketch examples

There are assembler and disassembler example sketches you can try to run on actual Arduino board at examples.

Assembler command line interface

On POSIX environment, assembler command line interface is provided. It can generate Intel HEX or Motorola S-Record output.

libasm assembler (version 1.6.29)
usage: asm [-o <output>] [-l <list>] <input>
  -C <CPU>    : target CPU
                MC6800 MB8861 MC6801 HD6301 MC68HC11 MC6805 MC146805
                MC68HC05 MC6809 HD6309 MOS6502 R65C02 G65SC02 W65C02S
                W65C816S i8039 i8048 i80C39 i80C48 MSM80C39 MSM80C48 i8051
                i8080 i8085 V30EMU Z80 Z8 Z86C Z88 TLCS90 INS8060 INS8070
                CDP1802 CDP1804 CDP1804A SCN2650 F3850 TMS32010 TMS32015
                i8086 i80186 V30 i8096 MC68000 TMS9900 TMS9995 TMS99105
                Z8001 Z8002 NS32032 MN1610 MN1613 MN1613A
  -o <output> : output file
  -l <list>   : list file
  -S[<bytes>] : output Motorola S-Record format
  -H[<bytes>] : output Intel HEX format
              : optional <bytes> specifies data record length (max 32)
  -h          : use lowe case letter for hexadecimal
  -n          : output line number to list file
  -v          : print progress verbosely
  -X<name>=<vale>
              : extra options (<type> [, <CPU>])
  comment-char    : line comment starting letter  (char)
  pc-bits         : program counter width in bit, default 13  (int, 6805)
  setdp           : set direct page register  (int, 6809)
  longa           : enable 16-bit accumulator  (bool, 6502)
  longi           : enable 16-bit index registers  (bool, 6502)
  setrp           : set register pointer  (int, Z8)
  setrp0          : set register pointer 0  (int, Z8)
  setrp1          : set register pointer 1  (int, Z8)
  use-register    : enable register name Rn  (bool, 1802)
  smart-branch    : enable optimizing to short branch  (bool, 1802)
  optimize-segment: enable optimizing segment override  (bool, 8086)
  alias           : accept An as destination operand  (bool, 68000)
  short-direct    : enable optimizing direct addressing  (bool, Z8001)
  fpu             : floating point co-processor  (text, 32032)
  pmmu            : memory management unit  (text, 32032)

Disassembler command line interface

On POSIX environment, disassembler command line interface is provided. It can read Intel HEX or Motorola S-Record input.

libasm disassembler (version 1.6.29)
usage: dis -C <CPU> [-o <output>] [-l <list>] <input>
  -C <CPU>    : target CPU
                MC6800 MB8861 MC6801 HD6301 MC68HC11 MC6805 MC146805
                MC68HC05 MC6809 HD6309 MOS6502 R65C02 G65SC02 W65C02S
                W65C816S i8039 i8048 i80C39 i80C48 MSM80C39 MSM80C48 i8051
                i8080 i8085 V30EMU Z80 Z8 Z86C Z88 TLCS90 INS8060 INS8070
                CDP1802 CDP1804 CDP1804A SCN2650 F3850 TMS32010 TMS32015
                i8086 i80186 V30 i8096 MC68000 TMS9900 TMS9995 TMS99105
                Z8001 Z8002 NS32032 MN1610 MN1613 MN1613A
  -o <output> : output file
  -l <list>   : list file
  <input>     : file can be Motorola S-Record or Intel HEX format
  -A start[,end]
              : disassemble start address and optional end address
  -r          : use program counter relative notation
  -h          : use lower case letter for hexadecimal
  -u          : use upper case letter for output
  -v          : print progress verbosely
  -X<name>=<vale>
              : extra options (<type> [, <CPU>])
  relative        : program counter relative branch target  (bool)
  uppercase       : uppercase instruction and register name  (bool)
  c-style         : C language style number constant  (bool)
  origin-char     : letter for origin symbol  (char)
  pc-bits         : program counter width in bit, default 13  (int, 6805)
  longa           : enable 16-bit accumulator  (bool, 6502)
  longi           : enable 16-bit index registers  (bool, 6502)
  indirect-long   : [] for indirect long operand  (bool, 6502)
  work-register   : prefer work register name than alias address  (bool, Z8)
  imm-prefix      : immediate prefix # (default =)  (bool, 8070)
  use-register    : use register name Rn  (bool, 1802)
  use-scratchpad  : use name for scratchpad  (bool, 3850)
  segment-insn    : segment override as instruction  (bool, 8086)
  string-insn     : string instruction as repeat operand  (bool, 8086)
  absolute        : zero register indexing as absolute addressing  (bool, 8096)
  short-direct    : short direct addressing as ||  (bool, Z8001)
  ioaddr-prefix   : I/O address prefix # (default none)  (bool, Z8001)
  pcrel-paren     : addr(pc) as program counter relative  (bool, 32032)
  external-paren  : disp2(disp(ext)) as extenal addressing  (bool, 32032)
  stropt-bracket  : string instruction operand in []  (bool, 32032)
  float-prefix    : float constant prefix 0f (default none)  (bool, 32032)

Supported host environment

  • Arduino (avr, megaavr, samd, teensy)

  • PlatformIO (atmelavr, atmelmegaavr, atmelsam, teensy)

  • Linux, macOS (C++14)

Note
More information about this library can be found at GitHub
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].