ec2-3-147-65-65.us-east-2.compute.amazonaws.com | ToothyWiki | MoonShadow | RecentChanges | Login | Webcomic
A JavaScript [DCPU16] emulator implementation is [here].
It implements the [v1.7 spec], and the following devices:
One of each is attached to the DCPU (in arbitrary order, check device IDs on startup).
An asynchronous command shell is provided for debugging and controlling the emulation. Online help is provided via the help command. The asm command will switch to assembly editing mode, allowing you to paste DCPU16 assembly source from elsewhere on the web.
In addition to the instruction syntax used in the examples by Notch, the assembler supports the following:
- org / .org / origin - followed by a numerical expression, the origin directive begins a block of assembly at the address given by the expression
- dat - followed by a list of quoted strings and numerical expressions, the data directive emits the corresponding words at the current position
- ret as an alias for SET PC, POP
- b followed by an expression will attempt to generate a single-instruction branch. The instruction may trash O. Assembly will fail if a suitable instruction/operand combination cannot be found.
- anywhere a numerical constant may occur, a mathematical expression optionally using labels may also occur (with the caveat that origin directives can only refer to labels preceding them). Constant expressions evaluating to values in the 0x00..0x1f range will use the appropriate constant in the operand field, other values will cause a multiword instruction to be emitted.
- local numerical labels are supported, similar to GCC. Unlike GCC, when referring to a numerical label, you *must* specify whether to search forward or back from the referring instruction by appending 'f' or 'b' respectively; e.g.
1:
ifg a, b
b 1f ; bail out
; do stuff
b 1b ; loop round
1:
- def may be used to assign the result of an expression to a label. When relocation support is added, expressions depending on labels will get relocated, while those depending only on def-labels and constants will not.
- macros are supported. Parameters may be supplied, and will be interpolated as appropriate. Macro parameter names must start with an underscore. Macro substitution is not (currently) recursive, only one level is supported.
macro test (_a, _b, _c)
dat (_a+_b), _c
endm
test( 1, 2, 7 )
expands to
dat 3, 7
There is a GitHub? repository for the project [here].
You can paste code on this wiki and produce URLs that automatically load it in the emulator. The URL syntax is a little convoluted. See DDD/Pong for an example. If you want to do this - WelcomeToWiki! Please make yourself a home page and paste your code into subpages of that, to avoid clashes in the global namespace.
A cooperative multitasking OS is being written, hopefully in character for the game. Source can be obtained from the [github repository]. You can see it [here] (click ok, type "run" in the emulator command box). The line editing works but the shell doesn't do anything with the input just yet. CTRL+n will open a new shell terminal, CTRL+left/right arrow will switch terminals. Status bar contains, left to right: bottom word of current clock (ticks at ~4Hz, will be used for cursor blinking, watchdog and event timers); amount of free memory in words (may not actually reflect maximum allocatable area due to fragmentation); foreground process handle for current terminal; identifier for process owning current terminal.