Giter Club home page Giter Club logo

micro-lzmadec's Introduction

Micro LZMA decoder

Code Golf in Assembly with the goal of writing the smallest LZMA decoder.

Includes x86_64 version for Linux and Windows, and x86/x86_64 static version for use in compressed executables (see test_static.c for an example of usage).

Needs nasm to compile.

Results

x86_64 Linux binary: 817 bytes (120 headers, 697 code)
x86_64 Windows binary: 1536 bytes (256 headers, 295 padding, 171 import table, 814 code)
x86_64 static: 483 bytes
x86 static: 480 bytes

Yet it can be improved a little, especially the static version.

Limitations

LZMA archives can have a dictionary size of up to 4 GB, your OS must be able to allocate a buffer of this size for this decoder to work.

Probability Model Map

Notes for a better understanding of the code.

Original:
IsMatch: 0, 192      # state << 4 | posState
IsRep: 192, 12       # state
IsRepG0: 204, 12     # state
IsRepG1: 216, 12     # state
IsRepG2: 228, 12     # state
IsRep0Long: 240, 192 # state << 4 | posState
PosSlot: 432, 256
SpecPos: 688, 114
Align: 802, 16
LenCoder: 818, 2 + 512
RepLenCoder: 1332, 2 + 512
Literal: 1846, 0
New:
Align: 0, 16
IsRep{,G0,G1,G2}: 16, 4*12       # state * 4
IsMatch, IsRep0Long: 64, 2*192	# (state << 4 | posState) * 2
PosSlot: 448, 256
SpecPos: 704, 114 + 1 (padding)
LenCoder: 819, 2 + 511
RepLenCoder: 1332, 2 + 511 + 203 (padding)
Literal: 2048, 0

micro-lzmadec's People

Contributors

ilyakurdyukov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

micro-lzmadec's Issues

Symbolize literal integer constants

While the small size is remarkable, there is much work to be done before some other project might be willing to use or adapt this code.

Looking at the current HEAD 9fd3a26 at Tue Jun 7 10:14:56 2022 +0700, in file lzmadec.x86_64.asm there are many many bare literal integer constants that do not have symbolic names. In contrast, the reference implementation by Igor Pavlov in LZMA SDK 4.40 and successors uses dozens of symbolic names with designated inter-relationships. This makes it hard to compare the two versions. Also, the micro-lzmadec code lacks documentation of strategy, explanation of coding tricks, and comments in general. Which specializations of parameter values has micro-lzmadec assumed? What relationships do the numeric constants in micro-lzmadec have to each other? If it becomes necessary or desirable to change one value, then how are the others affected?

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.