Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nathsou/cocovm
Tiny register-based VM https://nathsou.github.io/CocoVM/
https://github.com/nathsou/cocovm
Last synced: about 2 months ago
JSON representation
Tiny register-based VM https://nathsou.github.io/CocoVM/
- Host: GitHub
- URL: https://github.com/nathsou/cocovm
- Owner: nathsou
- Created: 2016-11-02T22:15:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-24T09:58:14.000Z (about 8 years ago)
- Last Synced: 2024-10-11T20:42:55.331Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.12 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CocoVM
Coco is a small and flexible CPU emulator, you can choose the number of registers, the amount of RAM and the architecture (4bits, 8bits, 128bits...)###Example
```asm
;fibonacci sequence;prints fib(15)
MOV @4, #15;init data
MOV %0, #1
MOV %1, #1
MOV %2, #0
MOV %3, #2
JMP mainmain:
INC %3
MOV %2, %0
ADD %0, %1
MOV %1, %2
CMP %3, @4
JNE main
OUT %0
HLT
```##Addressing modes
Coco supports 3 addressing modes:
###register address (%)
to access the content of the nth register
```asm
MOV %0, %n
```The 0th register ("%0") can be seen as the accumulator.
###RAM address (@)
to access the nth byte in RAM
```asm
MOV %0, @n
```###immediate (#)
to use a numerical directly
```asm
MOV %0, #1789
```