Waiting for 6502 implemented on top of Sudoku!
This, basically, uses a table to store 64 kilobytes of memory, a single-row table for storing register values, and uses regular procedural programming to run the CPU (<a href="https://github.com/lasect/pg_6502/blob/main/init/05_execute.sql" rel="nofollow">https://github.com/lasect/pg_6502/blob/main/init/05_execute....</a>)<p>I give that an A+ for perseverance, but I would have hoped to see something that uses the strengths of SQL more.<p>For example, there could be a table with the decode ROM (<a href="https://www.cpcwiki.eu/index.php/MOS_6502#The_Decode_ROM_.28PLA.29" rel="nofollow">https://www.cpcwiki.eu/index.php/MOS_6502#The_Decode_ROM_.28...</a>) that could be used to drive the logic.<p>Have a main loop that uses the inputs of that ROM to look up the output bits and update a table, and add triggers that handle each “micro-op”. A SQL engine could run those triggers in parallel until they hit a race condition, but those can be avoided a bit by having separate tables for each register.<p>Even better would be if there were tables with every logic gate and wire in the original CPU, using a trigger to move the signals around. That would be a good test of the trigger handling in a SQL engine.
Cool! How about Postgres on MOS tech 6502 8-bit microprocessor powered by Microsoft's 6502 BASIC?
Kim-1 emulator and assembler for T3X0:<p><a href="https://t3x.org/t3x/0/sim65kit.html" rel="nofollow">https://t3x.org/t3x/0/sim65kit.html</a><p><a href="https://t3x.org/kimuno/" rel="nofollow">https://t3x.org/kimuno/</a><p>Pocket calc as 6502 code<p><a href="https://t3x.org/kimuno/kimcalc.html" rel="nofollow">https://t3x.org/kimuno/kimcalc.html</a><p>T3x0 compiler to build the emulator:<p><a href="https://t3x.org/t3x/0/index.html" rel="nofollow">https://t3x.org/t3x/0/index.html</a><p>I've got to run under OpenBSD/i386 but it needs a bit of tweaks in the Makefile. On the target section:<p><pre><code> # CFLAGS=$CFLAGS" -m32" # on x86 64-bit systems
CFLAGS=$CFLAGS" -static" # in case all else fails
CFLAGS=$CFLAGS" -fPIC" # get rid of stupid linker errors
CFLAGS=$CFLAGS" -Wl,-z,notext" # get rid of stupid linker errors
CFLAGS=$CFLAGS" -fno-PIE -no-pie" # get rid of stupid linker errors
</code></pre>
Do the same in the bin/tx0.sh and bin/build.sh just in case.
In my system I set the target to unix-386, and T3XDIR it's set
to T3XDIR=/usr/local/t3x/lib in the Makefile and bin/tx0.sh scripts.<p>Also, T3XBIN it's set to BINDIR= /usr/local/t3x/bin<p>Then I ran:<p><pre><code> sh bin/modpath.sh /usr/local/t3x/lib
gmake all-native
doas gmake install-native install-modules
</code></pre>
But it was still broken. Then, I edited /usr/local/t3x/bin/tx0 and set<p>TX3DIR is above, and ditto with the four CFLAGS flags I posted.<p>Just the ones at lines 38-42.<p>OFC set PATH to /usr/local/t3x0/bin:$PATH in ~/.profile:<p><pre><code> export PATH=/usr/local/t3x0/bin:$PATH
</code></pre>
Yeah, it's tricky, but from now on everything will just compile with<p><pre><code> 'tx0 foo'
</code></pre>
where 'foo' it's a foo.t file.<p>This was compiled under an Atom n270 CPU based netbook. I think the author uses a Pentium III machine. If T3X0 can do a MOS 6502 emulation that well, you can try expanding s65/sim65 to cover the Apple I emulation.<p>And, as a plus, it might run fast on DOS 386 machines if s65/sim65 it's compiled a native binary.