jdah / jdh-8

An 8-bit minicomputer with a fully custom architecture
MIT License
1.29k stars 89 forks source link

Question about implementing jdh-8 support into TRSE #34

Closed leuat closed 2 years ago

leuat commented 2 years ago

Hi there! First of all, thanks for this wonderful project! Really amazing stuff.

Second, check out TRSE (www.turborascal.com), my modern IDE + pascal compiler + resource management solution for 65(c)02/Z80/X86/Motorola 68000 computers. Some yt videos:

or check out my youtube channel (https://www.youtube.com/c/leuat79) or https://lemonspawn.com/gallery_/ for a list of showcases

So the actual question: Would you be OK if I (just for fun) went ahead added support for your CPU + computer into TRSE? Since my compiler is modular/easily extendable, adding support for your CPU should be a piece of cake - even better since you've already providing code for mul16 and div etc etc (I'm used to the 6502 and z80). In that case, a user would be able to rapidly start a new project for your system -> type a couple of lines of Pascal -> press Ctlr+R ->program gets executed automatically in your emulator. If you're wondering how this would look, then download TRSE and check out how I've added support for 15-20ish old computers and their respective emulators + have over 400 tutorials / sample projects.

Reason why I wanted to do this: your code is clean. emulator readily available, no hassle with start addresses, assembler included, compiles out of the box. I have my own 6502/z80 assembler, and could easily create my own for your CPU - but since you already provide an assembler.. I'm lazy =)

btw I also made my own "fake" computer, though emulator only - which uses a 6502 + SID - check out a demo on the computer here: https://www.youtube.com/watch?v=BqIxwTUWUh0.

regards

Nicolaas

jdah commented 2 years ago

Go for it! Don't hesitate to ask if the documentation is unclear anywhere.

leuat commented 2 years ago

thanks! If I manage to get the example file working properly, I'll see if I'll get it implemented. will let you know later! Just gotta get the basics up and running first..

jdah commented 2 years ago

The first example is fixed now with 2b3b5983ec20b84a8b919c9e7a2cb136534ca2b8, the OS will just jmp [ADDR_RAM] after setting up the stack and memory bank register!

leuat commented 2 years ago

so the final question is then.. what should the stack register 0xfffd point to by default? and the memory bank register 0xfffa? Just so we can have some default values.. I'm getting pong to display, but it crashes instantly (I'm not doing anything to set up SP etc)

leuat commented 2 years ago

ok just set

poke(&state, 0xFFFF, 0xC0);
poke(&state, 0xFFFD, 0xBF);

in main in order to get everything up and running. everything seems to work now, thanks!

jdah commented 2 years ago

SP can really point wherever, but it's typically set to 0xFEFF and MB is 0 for regular RAM and 1 for the graphics memory bank.

leuat commented 2 years ago

First, check out https://www.youtube.com/watch?v=8PY0lXf3tpQ on how JDH-8 is implemented

Screenshot 2022-01-05 at 12 24 21

Ok so I spent 3 hours this morning adding basic JDH-8 support into TRSE. This means

Mind you: the compiler is currently empty, and the only allowed keyword is ... inline assembler! The next step is to implement assign statements, for statements, while, procedure calls etc.. these are already defined in a parent class so all I need to do is fill in missing instructions etc. But will probably take some time. And I'm usually quite lazy.

Some missing features / wishes from JDH-8:

Dunno how motivated/interested you are on continuing work on your computer, but I usually make a lot of demos for various platforms. Check out

BBC Micro: https://www.youtube.com/watch?v=UnAoYDjVLjc C64: https://www.youtube.com/watch?v=I0G5IxSBQl4 Gameboy: https://www.youtube.com/watch?v=2jY4wqkSxBs

so if you're keen, I could probably produce some (fake) 3d effects and other cool stuff. That is, .. after I've actually implemented the rest of the compiler =) Love the risc-like instruction set btw.

let me know your thoughts! ^L

leuat commented 2 years ago

another example: https://www.youtube.com/watch?v=BqIxwTUWUh0 is a demo for my own computer (emulator only, I suck at HW)

leuat commented 2 years ago

Did some more work on the compiler: you can now do for loops, call functions, assign variables / pointers, lookup pointers and perform single binary operations. No mul/div yet. If you try to do a:=(b+c)*d+2, it will fail. for now.

Video of the test setup, written in Rascal: https://www.youtube.com/watch?v=ws1cwZvYMD0

Some questions (when you have time, and I'm here): a) no shift left/right instructions? supposed to use mul/div instead? b) the index register H+L .. how are they supposed to be used? on the 6502, you have an index register lda (p),x, but I guess HL here is supposed to be used as on the Z80? So in order to shift to a specific address in a table, you would typically do

lda [table] lw16 a,b,[index] lw a,h,l ; loads the word

or did I misunderstand the intended use?

cheers! ^L

leuat commented 2 years ago

Twister effect : https://www.youtube.com/watch?v=aMNe2V4Cx-s

Screenshot 2022-01-06 at 01 16 13
jdah commented 2 years ago

a) no shift left/right instructions? supposed to use mul/div instead?

shl/shr are included in the os/lib/shift.asm file as callable procedures

b) the index register H+L .. how are they supposed to be used?

HL are the only way to access memory indirectly - that is, if you have an pointer in AB that you want want to load data from you need to first move AB into HL and then lw <reg> to get the data out.