Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Copyright 2009 Usmar A Padow [email protected]
- VM for running mutating programs.
- This VM is intended for running programs that can mutate.
- It is keept simple in order to prevent programs from chrashing.
- It ignores opcodes that are not valid, allowing for data to be combined with opcodes
- The memory is all stored in ASCII, not in HEX, since I want to make it easy for me to understand.
- NULL=00
- registers
- AH general registed 1
- BH general register 2
- CH=general register 3
- IP=instruction pointer
- opcodes
- 00 NULL NULL, ignore this instruction
- 00 NULL 01, data start tag (These two tags are not really nessesary execpt for being able to distingush data from non data)
- 00 NULL 02, data end tag ( "" )
- 01 move reg val, sets register to a value
- 02 move reg reg, sets a register to the value of another register
- 03 move val NULL, sets the memory to the value in AH in the memory position in BH, val can be 01low 02mid 03 high
- Note:the memory structure should be a list that contains strings, in this string "123456" 12 is low 34 is mid 56 is high
- 04 jmp VAL, conditional jump (if CH is Ture(non zero)) jump to location in VAL, if VAL is out of range of memory, dont jump, if AH is not an int, then dont jump(again to prevent crashing)
- 05 add NULL NULL, adds AH to BH ans stores it in CH,dont do anything if the registers are not integers
- 06 output NULL NULL, sends string from memory location from AH to BH to stdout
- if values are out of range of the memory or are not ints, then do nothing
- 07 mutation NULL NULL, writes the value of AH to a random position in memory
- I think I also need opcodes for malloc, copy from memory to memory, and possibly an opcode to copy the entire program to the next part of the memory although this can me achieved with the malloc and copy from memory to memory
- inputs,not yet implemented
- input value, appends value to memory
- example program helloworld.wvm
- Hello #Data point 00
- World!#Data point 01
- 01BH01#point 01, set the end of the output in BH, AH is 00 by default
- 060000#point 04, output from AH=00 to BH=03, should print the Data "Hello World!"
Advertisement
Add Comment
Please, Sign In to add comment