amigojapan

Untitled

May 27th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. Copyright 2009 Usmar A Padow [email protected]
  2. VM for running mutating programs.
  3. This VM is intended for running programs that can mutate.
  4. It is keept simple in order to prevent programs from chrashing.
  5. It ignores opcodes that are not valid, allowing for data to be combined with opcodes
  6. The memory is all stored in ASCII, not in HEX, since I want to make it easy for me to understand.
  7. NULL=00
  8.  
  9. registers
  10. AH general registed 1
  11. BH general register 2
  12. CH=general register 3
  13. IP=instruction pointer
  14. opcodes
  15. 00 NULL NULL, ignore this instruction
  16. 00 NULL 01, data start tag (These two tags are not really nessesary execpt for being able to distingush data from non data)
  17. 00 NULL 02, data end tag ( "" )
  18. 01 move reg val, sets register to a value
  19. 02 move reg reg, sets a register to the value of another register
  20. 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
  21. Note:the memory structure should be a list that contains strings, in this string "123456" 12 is low 34 is mid 56 is high
  22. 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)
  23. 05 add NULL NULL, adds AH to BH ans stores it in CH,dont do anything if the registers are not integers
  24. 06 output NULL NULL, sends string from memory location from AH to BH to stdout
  25. if values are out of range of the memory or are not ints, then do nothing
  26. 07 mutation NULL NULL, writes the value of AH to a random position in memory
  27.  
  28. 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
  29.  
  30. inputs,not yet implemented
  31. input value, appends value to memory
  32.  
  33. example program helloworld.wvm
  34. Hello #Data point 00
  35. World!#Data point 01
  36. 01BH01#point 01, set the end of the output in BH, AH is 00 by default
  37. 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