Last visit was: Thu May 01, 2025 12:04 pm
It is currently Thu May 01, 2025 12:04 pm



 [ 26 posts ]  Go to page Previous  1, 2
 Virtual 16-bit CPU/ISA Simpleton (emulator + assembler) 
Author Message

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
I decided to use Qt+QOpenGLWidget as platform for emulator.
I named virtual PC based on Simpleton4: SimpX.
For now it's just testing platform without real specifications for future use.

First run of graphic program in emulator could be seen here: https://youtu.be/pzXnAzf8gd8
It runs this code:
Code:
   mode new

   r0 <- 32768
   r1 <- ( 32768 + 4096 ) ; expression syntax is needed

start   r2 <- r0
   r3 <- 0
loop   [ r2 ] = [ r2 ] + r3
   r2 <- r2 + 1
   r3 <- r3 + 1
   void = r2 - r1 ; cmp (result is ignored)
   jnz loop
   pc <- start

Screen space is located at address 32768 in the CPU address space.
It is monochrome bitmap with 16 pixels per word, 256 pixels per line and 256 lines per screen.
So, overall video memory size is 4Kw.
Program just increments every word of video memory in increasing increments.
Emulator makes 1000 CPU steps per frame, so framerate is visually slow.

After some fixes and improvements Simpleton repositary on github will be replaced by SimpX repositary.


Mon May 24, 2021 3:09 am

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
Emulation of SimpX goes online!
Link: http://alxhost.tk/SimpX/SimpX.html
To run first demo select file 'test0.asm' in the left panel and click 'Emulation->Run' menu.
It' interesting to hear about FPS (are shown in the bottom status line) with full-screen and 200/300/400% (selected in 'View') menu. To go back to full-document scale just change size of Browser window in any way (for example: minimize/maximize).


Thu Jun 10, 2021 2:54 pm

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1821
Looks nice! I'm getting about 66 FPS normally and 81 FPS at 200%.


Thu Jun 10, 2021 3:01 pm

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
BigEd wrote:
Looks nice! I'm getting about 66 FPS normally and 81 FPS at 200%.

Thanks for testing!
Qt+WebAssembly is really cool thing to implement this cross-standalone-cross-web application, but I feel it could be much more speedy. But anyway these results make me happy.


Thu Jun 10, 2021 3:33 pm

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
Github page for Simpleton 4 is removed. It is replaced by SimpX project: https://github.com/aa-dav/SimpX which is Qt project for Simpleton with assembler and emulator.

Github page: https://github.com/aa-dav/SimpX (including most actual documentation https://github.com/aa-dav/SimpX#readme)
Online emulator and assembler: http://alxhost.tk/SimpX/SimpX.html


Sun Jun 20, 2021 3:47 pm

Joined: Mon Oct 07, 2019 2:41 am
Posts: 768
Notice how clean 16 bits computers are if you don't try to add bytes. E instruction could be a byte swap.
<16..9><8..1> --> <8..1><16..9>


Sun Jun 20, 2021 10:05 pm

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
oldben wrote:
Notice how clean 16 bits computers are if you don't try to add bytes.

I agree! Absence of bytes was the most disturbing idea for me at first. But the more I think about it the more I like it.

Quote:
E instruction could be a byte swap.
<16..9><8..1> --> <8..1><16..9>

There is no need in separate byte swap in Simpleton because it could be achieved as 'rrci dest reg 8' ('dest <= reg >> 8' in new syntax). (Cyclic) Rotate Right (updating Carry) does it.
Need of so called hardware 'barrel shifter' to do such things in 1 cycle is another thing which concerns me beacuse of Simpleton hardware becomes more complex than I wanted.
I thought about it and think that rotate by 8 could be implemented as separate hardware circuit (so byte swap is still 1-clock in ALU) and 1-7 and 9-15 offsets could be implemented with additional clocks per bit offset. Alternatively it could be 4/8/12 bits offsets as 1-clock bases (so, nibble granularity is fastest) with 1-3 clock penalty for 1-3 bit step.
However - why not barrel shifter? :)

It's interesting that Shift Left through Carry by 1 bit is just 'add dest src src' ('dest = src + src' in new syntax) and (Cyclic) Rotate Left through Carry is 'addc dest src src' ('dest = src +c src' in new syntax). (I got it from MSP 430 documentation) These instructions are not counterparts for rrc and rrci commands in Simpleton, but could be helpful. In fact rlc and rlci commands could be achieved by rrc/rrci with 16-offset operand in X.


Sun Jun 20, 2021 10:52 pm

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
Current SimpX can handle input from keyboard and gamepads (but gamepads are not working in web compilation, hmmm, sad)

Single input-output port controls it in the way simpliest for the hardware: by writing to port portInput we set line (single bit) of input wire.
Reading from port gives 16 signals on the wires. 16 bits of wires x 16 bit of inputs gives 256 possible input signals through portInput.
128 first signals corresponds to USB code keys: https://gist.github.com/MightyPork/6da2 ... 55fdc73db2
But codes 1, 2 and 3 corressponds to CTRL, SHIFT and ALT.

http://alxhost.tk/SimpX/SimpX.html selecting test0.asm and executing menu command "Emulator->Compile and run" will run program showing input in hex codes (first 64 keys of USB keycodes and first gamepad, but not working online). May not work if current language setting of keyboard is not english.


Wed Jul 07, 2021 5:27 am

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
I decided to use hosting of github, so online emulator can be viewed here: https://aa-dav.github.io/
A little bit more tests added, first are about usage of single video mode of SimpX as text terminal (bitmap is used as character generator and writes are done to tilemap) and last one is about usage as linear plane bitmap videomode (tilemap contains linear numbers from 0 to 1023 and writes are done to bitmap).
To run emulation we must select 'test' file and click Emulation->Compile and run.
It's better to click View->Set 400% to get correct aspect ration.
Documentation can be viewed at https://github.com/aa-dav/SimpX


Fri Mar 25, 2022 7:14 am

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
It's absolute madness!
TotalVacuum made port of DrMario for SimpX!!!
(in fact he is testing his C compiler to Fort for many many systems he covers including SimpX by accident, but this also explains slow framerate - he just do everything via "putpixel", lol)

There is need in some instructions.
Open online emulator: https://aa-dav.github.io/
Press "+" button to add empty source code file. Name it (input line above) drmario.asm
Then copy-paste source code from file "drmario.asm" from archive: http://totalvacuum.ru/SIMPX/drmario.zip
Note: It will take very long time for Web Qt to paste text, seems it's normal.
Input buttons are WASD.
Many many respects to TotalVacuum! :)


Sun Apr 13, 2025 9:58 am

Joined: Wed Feb 03, 2021 4:13 am
Posts: 21
It was fun to interact with Total Vacuum to improve his port of Dr. Mario from Uzebox to SimpX.
The main problem of speed was putpixel which was chosen because of very different Uzebox videomode.
Uzebox in this port uses 40 colums 6x8 tiles while SimpX has more classical 32 columns 8x8.
It requires to invent DrawTile6x8 procedure with optimized loops and tile data for SimpX.
I made speedy procedure with doubled tiles table for left-oriented and right-oriented variants of each tile for avoiding shifts and bit operations where possible.

I've lost ability to recompile web-version of SimpX, so I cannot just add new files to web-version right now.
Instead it will require copy-paste.

So, let's open https://aa-dav.github.io/ and choose any test source, for example test07-lines.asm. Erase all text and replace it by content of new file https://aa-dav.github.io/col40.asm
Qt Web is weird with copy-paste. You should press CTRL+V in empty code editor and after that popup will appear with single "Insert" menu - push it.
Another intuitive ways seems don't work. Weird.
Anyway after copy-pasting run it with 'Compile and run menu'.
And this is 40 column demo. Nothing really interesting at all - just blinking 6x8 tiles at full speed.

Anyway Total Vacuum made suggestion how to eliminate doubleness (clever packing scheme) and made some speedups in his SetTile procedure.
Notice: he is testing his C compiler to Forth compiler which has target platform of SimpX too (among others).
Result is here: https://aa-dav.github.io/drmario.asm


Sun Apr 20, 2025 1:34 am
 [ 26 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: AhrefsBot, claudebot and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software