Giter Club home page Giter Club logo

aoc2019-intcode's Introduction

This is the actual Intcode compiler used during puzzle creation for Advent of Code 2019 as specified by days 2, 5, and 9.

It is not meant to provide a general-purpose assembly language, and many features are tedious or overzealous for actual use as an assembly language. Its design constraints are based on the use cases and overabundance of caution required when hand-crafting bytecode for puzzle inputs. In particular, it requires many obvious or auto-detectable things to be defined explicitly anyway, it prioritizes control over the output over comfort, its warnings are overly sensitive, and so on.

Some sample programs, including assembly versions of fresh inputs for various Advent of Code 2019 puzzles, can be found in the samples directory. Hopefully, some combination of the samples and my crude notes below will provide enough information to get started. Note that the puzzle inputs are intentionally not the best, cleanest way to achieve the apparent goal of the program; for example, various obfuscation techniques are employed throughout the puzzles to try to make solving the puzzle the intended way faster than solving it with reverse-engineering.

== invocation ==
./compile.pl [--trace] [--labels] <file>
  - '--trace' dumps assembly to stderr, including macro expansions
  - '--labels' dumps addresses of labels

== instructions ==
names: hlt add mul in out jt jf lt eq rbo
params:
  - '123' is immediate mode
  - '*123' is position mode
  - '~123' is relative mode
  - 'label' is position mode
  - '&label' is immediate mode

== macros ==
@fn <retvals> <fnname>([<arg>,...]) [local(<local>,...)] [global(<global>,...)]
  - declares a function
  - retvals is number of values to return
  - local(...) is local variables
  - global(...) is allowed labels from global scope
@endfn
  - ends a function declaration
@call <addr>
  - invokes a function
@cpy <src> <dst>
  - copies values by randomly generating 'add 0' and 'mul 1' instructions
@jmp <addr>
  - jumps unconditionally by randomly generating 'jt 1' and 'jf 0' instructions
@str [<label>:]"...."
  - converts a string into @raw syntax
@raw <val> ...
  - injects values directly into the program at this point

== other notes ==
- label 'auto__end' points to the end of the compiled data; useful for 'rbo &auto__end' to set up stack

aoc2019-intcode's People

Contributors

topaz avatar

Watchers

 avatar

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.