From dedicated to promoting white hat, EULA-compliant Inner Space and LavishScript mods
Revision as of 22:02, 24 November 2012 by Whiteslax (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

LS2IL is the custom IL used the current LavishScript 2 assembler, as built into ls2il.exe with the standard LavishScript 2 execution environment.

Here's the basics:

  • The text of a LS2IL file or buffer defines a Chunk of code.
  • Chunks have Values (i.e. script-scope data) and Functions.
  • IL-definable Values currently can be:
    • null
    • signed integer in 8, 16, 32 or 64 bits of bytecode storage, e.g. .value i8 -1 to add an integer -1 stored in 8 bits or simply .value -1 to let the assembler decide
    • unsigned integer the same as signed, but e.g. .value u8 255 to add an integer 255 stored in 8 bits or simply .value 255 to let the assembler decide
    • floating point (32 or 64 bits)
    • binary denoted by || and given in hex pairs
    • string denoted by ""
    • arrays (0-based ordered list of Values) denoted by {}, e.g. {1, 2.0, | 03 |, "4"}
    • tables (Values keyed by string) denoted by [key=value], e.g. [ "apples"=2 , "oranges"=3.0 , "ducks"={"all","in","a","row"} ]
  • Functions have up to 256 Registers, any number of Values (i.e. static function-scope data), and any number of Instructions. Parameters passed to the function are called Inputs to the Function. Functions in the VM don't return a Value; they will instead do so by modifying the Inputs!
  • Instructions have the instruction/opcode and up to 3 Operands.
  • Operands are the same as Values but can also be one of the following:
    • chunkvalue[#]: 0-based Chunk Value
    • exception: Exception currently being handled (hopefully in your exception handler)
    • field[#]: 0-based Field from 'this' object
    • function: Function currently being executed
    • function[#]: 0-based Function from the Chunk
    • functionvalue[#]: 0-based Function Value (Value from current Function)
    • input[#]: 0-based Input
    • register[#]: 0-based Register
    • inputs: Array of inputs
    • registers: Array of registers
    • this: The current object, or 'subject', being manipulated

Hello World!

; Hello World!
.registers 1
RESOLVETYPE 0, "System.Console"
RESOLVESTATICMETHOD 0, register[0], "WriteLine{string}"
FASTCALLSTATICMETHOD register[0], "Hello World!"

See LS2IL:Hello World for a walkthrough of this code.

See Also