Author Topic: Low level hardware emulation  (Read 14185 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Low level hardware emulation
« on: March 20, 2011, 11:21:37 pm »
After a discussion about x86 emulation and WINE on #omnimaga, I became curious about the possibility of an emulation layer to provide additional functionality to Prizm programs by replacing missing hardware like the FPU and potentially other higher level functions.

Here's the basic conceptual framework I came up with:

  • All Assembly/C programs would go through a low level interpreter. This interpreter would be interrupt based and would copy a section of code into a buffer.
  • The buffer would be terminated with a Sleep instruction so that if the code finished executing the buffer, the processor would halt until the next interrupt fired in a few milliseconds.
  • When the interpreter detected something like an FPU instruction code, it would handle the instruction by replacing it with a call to a library routine.

This raises some obvious points, like the slowdown inherent in interpreted programs, but I don't think that's a serious problem, since most applications aren't speed critical enough for that to be a problem. Such an interpreter would also operate very low in the system, so it could probably be accomplished in only a few hundred cycles. You could also replace the interrupt/Sleep idea with a call to the interpreter so that it automatically calls the interpreter upon finishing. That would leave the interrupts open for modification by the program, as long as it doesn't modify itself to overflow the buffer.

Anyway, just a thought.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Low level hardware emulation
« Reply #1 on: March 20, 2011, 11:24:02 pm »
Why not just use actual routines for floating point and such? Unless you have some newer SuperH code in particular that you want to port.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Low level hardware emulation
« Reply #2 on: March 20, 2011, 11:25:33 pm »
I might have something along those lines planned...  <_<
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Low level hardware emulation
« Reply #3 on: March 20, 2011, 11:33:26 pm »
Hmm, well, does the processor support illegal instruction exceptions? I think that would be the best solution rather than interpreting code.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Low level hardware emulation
« Reply #4 on: March 20, 2011, 11:35:12 pm »
It does support general illegal instruction exceptions. However, I'm not sure if FPU codes trigger those. I should probably check.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Low level hardware emulation
« Reply #5 on: March 21, 2011, 12:23:57 am »
Well, if you're making it interpreted anyways, why not just make an interpreted language of your own? Just a thought.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Low level hardware emulation
« Reply #6 on: March 21, 2011, 01:34:39 am »
Because it's much more difficult to interpret a high level language like BASIC than to interpret Assembly. Something like Java would be possible, but porting a virtual machine would be a nightmare.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Low level hardware emulation
« Reply #7 on: March 21, 2011, 03:30:16 am »
I had an idea to take this one step further. Instead just porting an interpreter for SH3E instructions, how about adding functionality for the SH4 instruction set. SH3 opcodes work on the SH4, but the SH4 just adds some more fpu calculations along with also some graphics acceleration based codes. documentation is here http://documentation.renesas.com/eng/products/mpumcu/rej09b0318_sh_4sm.pdf
« Last Edit: March 21, 2011, 03:32:02 am by z80man »

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Low level hardware emulation
« Reply #8 on: March 21, 2011, 03:36:04 am »
Emulating graphics chips in software sucks :P

That'd actually be a very useful thing, though. If I ever decide to actually try this, then those would be a necessity.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Low level hardware emulation
« Reply #9 on: March 21, 2011, 03:50:27 am »
Emulating graphics chips in software sucks :P

That'd actually be a very useful thing, though. If I ever decide to actually try this, then those would be a necessity.
That reminds me.
I should start work on my openGL port to Casio Basic. With slow math and drawing commands I wonder how may frames per hour (or day :P) will I get. I should also get going on that BASIC 8 color bmp viewer. It might take a few hours to render though. But seriously we need a new BASIC interpreter. Not a full blown one with every command, but just the important math and graphics ones with maybe a few new bitmap commands too.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Low level hardware emulation
« Reply #10 on: March 21, 2011, 04:01:40 am »
This particular picture took 15 minutes to render in Casio-BASIC:



I think you'd be lucky to get frames per month...  :P
« Last Edit: March 21, 2011, 04:02:21 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Low level hardware emulation
« Reply #11 on: March 21, 2011, 09:24:37 am »
There is no way that took 15 minutes to render.  There's just... What the heck.  Okay, so is this the OS or hardwares' fault?  That's actually on the calc, right?  Could you show a video of that.  Maybe put a camera over it, and host a livestream or something? *shrugs*

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Low level hardware emulation
« Reply #12 on: March 21, 2011, 09:31:16 am »
There is no way that took 15 minutes to render.  There's just... What the heck.  Okay, so is this the OS or hardwares' fault?  That's actually on the calc, right?  Could you show a video of that.  Maybe put a camera over it, and host a livestream or something? *shrugs*
It's the OS, no doubt about it. Drawing something like this in asm is probably about as fast as on an 8x calc.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Low level hardware emulation
« Reply #13 on: March 21, 2011, 09:36:04 am »
There is no way that took 15 minutes to render.  There's just... What the heck.  Okay, so is this the OS or hardwares' fault?  That's actually on the calc, right?  Could you show a video of that.  Maybe put a camera over it, and host a livestream or something? *shrugs*
It's the OS, no doubt about it. Drawing something like this in asm is probably about as fast as on an 8x calc.
Wow. So, CKOS or what?

EDIT: IE: Casio-Knight OS or what?
« Last Edit: March 21, 2011, 09:36:44 am by graphmastur »

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Low level hardware emulation
« Reply #14 on: March 21, 2011, 09:38:34 am »
There is no way that took 15 minutes to render.  There's just... What the heck.  Okay, so is this the OS or hardwares' fault?  That's actually on the calc, right?  Could you show a video of that.  Maybe put a camera over it, and host a livestream or something? *shrugs*
It's the OS, no doubt about it. Drawing something like this in asm is probably about as fast as on an 8x calc.
Wow. So, CKOS or what?

EDIT: IE: Casio-Knight OS or what?
What do you mean?