1.0.0 • Published 2 years ago

platzi-virtual-machine v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Platzi Virtual Machine

The Platzi Virtual Machine (PVM) is a virtualized stack-based architecture machine. Its word size (and size of stack items) is 256-bit with a memory model that is a simple word-addressed byte array. The stack has a maximum size of 1024 and it uses an independent storage model based on a modified Merkle Particia Tree. All locations in both storage and memory are well defined initially as zero

Installation

Install the CLI via npm with:

yarn global add pvm

Then, use the CLI to manually test a bytecode input

pvm --code 0x6080 --gasLimit 100

PUSH1   @ pc=0   gas=100         cost=3
Stack:   [ '0x80' ]
Memory:  []

STOP    @ pc=2   gas=97  cost=0
Stack:   [ '0x80' ]
Memory:  []

Output:  0x00
Root:    0x29adae8041417fab44a067497a0daedde9e76b8e2f7a1b8ea07dbc5dc2e14588

Reference

OPCODEMNEMONIC
0x00STOP
0x01ADD
0x02MUL
0x03SUB
0x04DIV
0x06MOD
0x0aEXP
0x10LT
0x11GT
0x14EQ
0x16AND
0x17OR
0x18XOR
0x19NOT
0x50POP
0x51MLOAD
0x52MSTORE
0x54SLOAD
0x55SSTORE
0x56JUMP
0x57JUMPI
0x5bJUMPDEST
0x60PUSH1
0x61PUSH2
0x62PUSH3
0x63PUSH4
0x64PUSH5
0x65PUSH6
0x66PUSH7
0x67PUSH8
0x68PUSH9
0x69PUSH10
0x6aPUSH11
0x6bPUSH12
0x6cPUSH13
0x6dPUSH14
0x6ePUSH15
0x6fPUSH16
0x70PUSH17
0x71PUSH18
0x72PUSH19
0x73PUSH20
0x74PUSH21
0x75PUSH22
0x76PUSH23
0x77PUSH24
0x78PUSH25
0x79PUSH26
0x7aPUSH27
0x7bPUSH28
0x7cPUSH29
0x7dPUSH30
0x7ePUSH31
0x7fPUSH32
0x80DUP1
0x81DUP2
0x82DUP3
0x83DUP4
0x84DUP5
0x85DUP6
0x86DUP7
0x87DUP8
0x88DUP9
0x89DUP10
0x8aDUP11
0x8bDUP12
0x8cDUP13
0x8dDUP14
0x8eDUP15
0x8fDUP16
0x90SWAP1
0x91SWAP2
0x92SWAP3
0x93SWAP4
0x94SWAP5
0x95SWAP6
0x96SWAP7
0x97SWAP8
0x98SWAP9
0x99SWAP10
0x9aSWAP11
0x9bSWAP12
0x9cSWAP13
0x9dSWAP14
0x9eSWAP15
0x9fSWAP16
0xf3RETURN

LICENSE

MIT