articles/bytecode.md: new article
This commit is contained in:
parent
ca88f673be
commit
b6dcb9f67a
1 changed files with 28 additions and 0 deletions
28
articles/bytecode.md
Normal file
28
articles/bytecode.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Bytecode
|
||||
Bytecode, also known as *p-code* (for *portable code*) is a machine language-like representation
|
||||
of a program. Unlike actual machine code, it has a higher-abstraction level, since commonly
|
||||
bytecode is bespoke to the [language](programming_language.md) that it's meant to be used with, supporting high-level
|
||||
operations such as closures, memory management, dynamic typing, etc..
|
||||
|
||||
Usually bytecode is meant to be run in a [virtual machine](virtual_machine.md); this is common for scripting
|
||||
languages in order to achieve an usable performance, bytecode being a compact representation
|
||||
is more cache friendly than an [AST](abstract_syntax_tree.md) so it allows for faster execution.
|
||||
|
||||
In other cases, bytecode is used as an intermediate representation for compiled languages,
|
||||
before lowering down to more machine-specific code.
|
||||
|
||||
## Examples
|
||||
### PL/0 p-code
|
||||
- `lit` (load constant)
|
||||
- `opr` (operation, this opcode packs multiple arithmetic ops.)
|
||||
- `lod` (load variable)
|
||||
- `sto` (store variable)
|
||||
- `cal` (call procedure)
|
||||
- `int` (increment register)
|
||||
- `jmp` (unconditional jump)
|
||||
- `jpc` (conditional jump)
|
||||
|
||||
TODO more info
|
||||
|
||||
### Lua bytecode
|
||||
TODO
|
Loading…
Add table
Reference in a new issue