-
Notifications
You must be signed in to change notification settings - Fork 108
SVML Specification
martin-henz edited this page Feb 26, 2020
·
21 revisions
This page serves as a repository for preliminary specification of a virtual machine code (byte code) format for Virtual Machine implementations of Source.
The assembly code consists of an array of arrays. Each element array represents one instruction. Each instruction has the opcode in position 0, followed by the arguments, which might include numbers, boolean values or strings, depending on the instruction.
Header:
- Magic word: 0x5005ACAD
- Version number: 2 bytes for minor, 2 bytes for major
- Constant pool count
- Constant pool
- code
The code is a sequence of bytes, with segments of length 1 to 3 representing individual instructions. The first byte is the opcode, and the following bytes are the arguments.
See here for comparison: https://en.wikipedia.org/wiki/Java_class_file
(click on the link)
Each constant pool entry has:
- 1 byte: Type of constant pool entry
- 2 bytes: Length of constant pool entry in bytes (including 1 + 2)
- remaining bytes: data of constant pool entry (for example the string, in unicode)