diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 49 |
1 files changed, 48 insertions, 1 deletions
@@ -30,6 +30,31 @@ Simple! IF iter < 20; GOTO loop_start LOG Done! +### Prime Counter + + #!/bin/ducky + LOG Counting... + NEWLINE + LET primes=0 + LET MAX=100000 + LET n = 2 + LBL test_number + LET iter = 2 + LET stop = sqrt n + LBL test_loop + IF !(n % iter); GOTO composite + INC iter + IF iter <= stop; GOTO test_loop + INC primes + LBL composite + INC n + IF n < MAX; GOTO test_number + LOG Number of primes below + LOGVAR MAX + LOG : + LOGVAR primes + NEWLINE + ## Building POSIX systems are supported, as are some Rockbox targets. @@ -57,10 +82,32 @@ This will create `a.out`, which contains the bytecode. ducky a.out +## Technical Details + +The program consists of four parts: the interpreter, compiler, bytecode interpreter, and C transcompiler. + +### Interpreter + +Executes ducky directly. + + +### Bytecode Compiler + +Compiles ducky to a stack-machine based bytecode. + +### Bytecode Interpreter + +Executes the bytecode generated by the bytecode compiler. + +### C Transcompiler + +Translates bytecode generated by the bytecode compiler into C. +Depends on labels as values, which is a GCC extension. + ## Future Directions - - Compile to C? - Refactor code + - Input - Add more builtins - Arrays? - Functions? |