Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | This is another proof that Vim is perfectly compatible with Vi. |
| 2 | The URM macro package was written by Rudolf Koenig ("Rudi") |
| 3 | (rudolf@koeniglich.de) for hpux-vi in August 1991. |
| 4 | |
| 5 | Getting started: |
| 6 | |
| 7 | type |
| 8 | in your shell: vim urm<RETURN> |
| 9 | in vim: :so urm.vim<RETURN> |
| 10 | in vim: * (to load the registers and boot the URM-machine :-) |
| 11 | in vim: g (for 'go') and watch the fun. Per default, 3 and 4 |
| 12 | are multiplied. Watch the Program counter, it is |
Viktor Szépe | dbf749b | 2023-10-16 09:53:37 +0200 | [diff] [blame] | 13 | visible as a comma moving around. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 14 | |
| 15 | This is a "standard URM" (Universal register machine) interpreter. The URM |
| 16 | concept is used in theoretical computer science to aid in theorem proving. |
| 17 | Here it proves that vim is a general problem solver (if you bring enough |
| 18 | patience). |
| 19 | |
| 20 | The interpreter begins with register 1 (not 0), without macros and more-lines |
| 21 | capability. A dot marks the end of a program. (Bug: there must be a space |
| 22 | after the dot.) |
| 23 | |
| 24 | The registers are the first few lines, beginning with a '>' . |
| 25 | The program is the first line after the registers. |
| 26 | You should always initialize the registers required by the program. |
| 27 | |
| 28 | Output register: line 2 |
| 29 | Input registers: line 2 to ... |
| 30 | |
| 31 | Commands: |
| 32 | a<n> increment register <n> |
| 33 | s<n> decrement register <n> |
| 34 | <x>;<y> execute command <x> and then <y> |
| 35 | (<x>)<n> execute command <x> while register <n> is nonzero |
| 36 | . ("dot blank") halt the machine. |
| 37 | |
| 38 | Examples: |
| 39 | |
| 40 | Add register 2 to register 3: |
| 41 | (a2;s3)3. |
| 42 | Multiply register 2 with register 3: |
| 43 | (a4;a5;s2)2; ((a2;s4)4; s3; (a1;a4;s5)5; (a5;s1)1)3. |
| 44 | |
| 45 | There are more (complicated) examples in the file examples. |
| 46 | Note, undo may take a while after a division. |
| 47 | |