forked from Blecki/DCPUB
-
Notifications
You must be signed in to change notification settings - Fork 0
C-like language compiled to DCPU assembly
License
colinvh/DCPUC
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
DCPUC, A C-like language for the DCPU-16, the 16-bit 'hardware' in Mojang's game 0x10c. This compiler targets DCPU assembly. http://0x10c.com/doc/dcpu-16.txt The output of this compiler has been tested with this emulator https://github.com/mappum/DCPU-16 and may output the 'BRK' instruction, which is a feature of that emulator and not of the official DCPU-16 spec. There is a simple GUI compiler included (DCPUCIDE). Try compiling this program: function fib(n) { if (n == 0) return 0; if (n == 1) return 1; return fib(n-1) + fib(n-2); } var a = fib(6); For reference SET PUSH, 0x0006 JSR LABEL0_fib SET PUSH, A BRK ;Non-standard :LABEL0_fib SET PUSH, 0x0000 SET A, SP SET PUSH, [0x0003+A] SET A, 0x0 IFE POP, POP SET A, 0x1 SET PUSH, A IFE POP, 0x0 SET PC, LABEL1END SET PUSH, 0x0000 SET A, POP SET B, POP ADD SP, 0x0001 SET PC, B :LABEL1END SET PUSH, 0x0001 SET A, SP SET PUSH, [0x0003+A] SET A, 0x0 IFE POP, POP SET A, 0x1 SET PUSH, A IFE POP, 0x0 SET PC, LABEL2END SET PUSH, 0x0001 SET A, POP SET B, POP ADD SP, 0x0001 SET PC, B :LABEL2END SET PUSH, 0x0002 SET A, SP SET PUSH, [0x0003+A] SET A, POP SUB A, POP SET PUSH, A JSR LABEL0_fib SET PUSH, A SET PUSH, 0x0001 SET A, SP SET PUSH, [0x0004+A] SET A, POP SUB A, POP SET PUSH, A JSR LABEL0_fib SET PUSH, A SET A, POP ADD A, POP SET PUSH, A SET A, POP SET B, POP ADD SP, 0x0001 SET PC, B SET B, POP ADD SP, 0x0001 SET PC, B Have fun, and read the language spec!
About
C-like language compiled to DCPU assembly
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published