summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/dynarec.c (unfollow)
Commit message (Collapse)Author
2005-07-03Centralised the ICODE_ATTR and IDATA_ATTR #defines. Renamed some musepack ↵Jens Arnold
and rockboy headers to avoid clashes with rockbox headers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6991 a1c6a512-1295-4272-9138-f99709370657
2005-03-05Minor bug when writing files; files weren't truncated to 0, so whenMichiel Van Der Kolk
writing a file smaller than the previous one, it adds garbage to the end. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6147 a1c6a512-1295-4272-9138-f99709370657
2005-03-05 Bugggggggggggssssssssss *chases with flyswatter and swats them*Michiel Van Der Kolk
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6144 a1c6a512-1295-4272-9138-f99709370657
2005-03-05printing of the PC in assembly dumps.Michiel Van Der Kolk
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6143 a1c6a512-1295-4272-9138-f99709370657
2005-03-05Dynarec debug system added - creates various debugging files in the root.Michiel Van Der Kolk
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6142 a1c6a512-1295-4272-9138-f99709370657
2005-03-05More opcodes implemented on dynarec, somewhat working, some bugs.Michiel Van Der Kolk
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6141 a1c6a512-1295-4272-9138-f99709370657
2005-03-03Added dynarec(under construction) and outline for lcd modesMichiel Van Der Kolk
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6119 a1c6a512-1295-4272-9138-f99709370657
clear: both; } .markdown-body span.align-right>span { display: block; overflow: hidden; margin: 13px 0 0; text-align: right; } .markdown-body span.align-right span img { margin: 0; text-align: right; } .markdown-body span.float-left { display: block; margin-right: 13px; overflow: hidden; float: left; } .markdown-body span.float-left span { margin: 13px 0 0; } .markdown-body span.float-right { display: block; margin-left: 13px; overflow: hidden; float: right; } .markdown-body span.float-right>span { display: block; overflow: hidden; margin: 13px auto 0; text-align: right; } .markdown-body code, .markdown-body tt { margin: 0 2px; padding: 0px 5px; border: 1px solid #eaeaea; background-color: #f8f8f8; border-radius: 3px; } .markdown-body code { white-space: nowrap; } .markdown-body pre>code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } .markdown-body .highlight pre, .markdown-body pre { background-color: #f8f8f8; border: 1px solid #ccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px; border-radius: 3px; } .markdown-body pre code, .markdown-body pre tt { margin: 0; padding: 0; background-color: transparent; border: none; } .highlight .hll { background-color: #ffffcc } .highlight { background: #ffffff; } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */

Ducky

IRC: #ducky-lang at irc.freenode.net

Introduction

Ducky is a BASIC-like programming language originally insipred by Duckyscript, the USB Rubber Ducky's scripting language.

Examples

Hello World

1
2
3
#!/bin/ducky
LOG Hello, world!
NEWLINE

Simple!

Fibonacci Sequence

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/bin/ducky
LET a = 0; LET b = 0; LET iter = 0
LABEL loop_start
LOGVAR a
NEWLINE
LET c = a+b
LET a = b
LET b = c
INC iter
IF iter < 20; GOTO loop_start
LOG Done!
NEWLINE

Prime Counter

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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.

Unix/Linux

make
sudo make install

This installs the /bin/ducky binary.

Usage

Running Directly (no compilation)

ducky scriptname.ds

Compiling to bytecode

ducky -c scriptname.ds

This will create a.out, which contains the bytecode.

Executing bytecode

ducky a.out

Full Compile (from ducky to machine code)

ducky -a scriptname.ds
./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.

Benchmark Results

21 Nov 2015:

c - clang     26 27 27 27 27 27 27 27 27 27 - AVG 26.9
c - gcc       29 29 29 29 29 29 29 29 29 29 - AVG 29
c - tcc       28 28 28 28 28 28 28 28 28 28 - AVG 28
ducky - clang 15 15 15 15 15 15 15 15 15 15 - AVG 15
ducky - gcc   28 28 28 28 28 28 28 28 28 26 - AVG 27.8

26 Nov 2015:

LanguageCompilerOptimization LevelScoresMean score
DuckyClang-O04 4 4 4 4 4 4 4 4 4 4
DuckyClang-O115 15 15 15 15 15 15 15 15 1515
DuckyClang-O221 21 21 21 21 21 21 21 21 2121
DuckyClang-O321 21 21 21 21 21 21 21 21 2121
DuckyGCC-O05 5 4 5 5 5 5 5 5 5 4.9
DuckyGCC-O122 23 23 23 23 23 23 23 23 2322.9
DuckyGCC-O226 26 26 26 26 26 26 26 26 2626
DuckyGCC-O326 26 26 26 26 26 26 26 26 2626
CClang-O028 28 28 28 28 28 28 28 28 2828
CClang-O128 29 29 28 28 28 28 28 29 2928.4
CClang-O228 29 29 29 28 29 29 28 28 2828.4
CClang-O328 28 28 29 28 29 28 29 28 2828.3
CGCC-O028 28 28 28 28 28 28 28 28 2828
CGCC-O130 30 30 30 29 30 29 30 30 2929.7
CGCC-O230 30 30 30 30 30 30 30 30 3030
CGCC-O330 30 30 30 30 30 30 30 30 3030

Future Directions