r/dcpu16•
theinternet

DCPU emulation on DCPU

This is a fully implemented DCPU emulator written for DCPU.

Available here: http://code.google.com/p/dcpu-semu/

Written in assembly language and tested with DCPU-16 Studio.

Keep in mind that this is a first pass version to get it working. The primary goal is emulation speed over code size.

Feedback is welcome :)

Posted Apr 8, 2012, 1:15 PM UTC

5117
sli•

Out of curiosity: can it successfully run itself?

23
squeakyneb•

Oh sweet jesus I see where this is going.

Don't you fucking dare.

22
[deleted]•

[deleted]

1
AgentME•

No, where it gets interesting is when you have an emulator that can emulate two machines at once.

You have it emulate one program, and another emulator. You have that emulator run a different program, and another emulator. You have that emulator run a third program, and another emulator... It's a lazy excuse for multitasking.

1
squeakyneb•

... that is not how you do multitasking, and it's certainly not a lazy excuse for it.

That said, traditional multitasking requires either specially built programs or timed interrupts.

2
AgentME•

Lazy in the sense that the programs running on the emulators don't need to cooperate or even know what's going on. Definitely is a lot more work on the part of the emulator and whatever machine is running this monstrosity.

1
theinternetOP•

Working on it now :)

20
sli•

Happy cake day.

5
Alphasite•

Yep, happy cake day, and pretty epic username. :)

5
technoskald•

You'll need to rename the project "Xzibit" or "Inception".

0
burkey0307•

Yo dawg.

7
Alsweetex•

Upvote for insanity!

6
moozaad•

upvote for tactical sneaky sandbox if done right!

8
IMBJR•

Excellent, you have multithreading.

4
aha2095•

I dare you! In fact I dare you to go all out inception on its ass and go deeper!

3
TheScriptKiddie•

I see that you have proposed preemptive multitasking as a possible use of this emulator. I just started typing an explanation about how there would be a much easier way to do this, but then I realized the DCPU lacks an interrupt timer. How about cooperative multitasking instead? Most programs are loops anyway, so at the end of each loop, the program voluntarily sets the program counter to the head of the OS's context change subroutine. The routine then dumps all of the ram except for the memory range reserved for the OS and hardware to disk, does any housekeeping necessary, loads the dump of the next process on the list. The program counter is set back to the top of the running program's main loop, and off we go.

2
theinternetOP•

Enabling the ability to implement a preemptive multitasking OS through an emulation layer introduces a new paradigm for consideration in systems development for DCPU.

While there are reasons preemptive is preferred over cooperative, the pros and cons of each (as can be implemented) should be considered in any design decision.

1
matthewjosephtaylor•

Wow, this really opens up some possibilities. I assumed the emulator code would need to be much larger. Well done.

1