What's new

Chip 8

aprentice

Moderator
vma said:
Not with Dragon2! The Game does NOT show Game Over. This other Chip-8 Emu I have (can't remeber the name) will pop up a Windows Messagebox. I wonder how the autor knew that the game was over?

Cheers,
vma

the other emus pop a message box when the quit opcode is called
 

extro

New member
hi, here is another question. Can somebody explain to me how to implement the binary translation stuff into the chip8 emu? Some example code would be really helpful, thx.
 

zenogais

New member
extro said:
hi, here is another question. Can somebody explain to me how to implement the binary translation stuff into the chip8 emu? Some example code would be really helpful, thx.

Binary translation, as in dynamic recompilation?
 

extro

New member
hm, that would lead to another question what is exactly the difference? It seems that these two methods are mixed up sometimes.
 

zenogais

New member
extro said:
hm, that would lead to another question what is exactly the difference? It seems that these two methods are mixed up sometimes.

They are the exact same, there is no difference. There are, however, two different flavors of binary translation:
  • dynamic recompilation - CPU instructions are decoded and compiled to native code on the fly.
  • static recompilation - An entire program is compiled to the native architecture at load time.
 

extro

New member
zenogais said:
They are the exact same, there is no difference. There are, however, two different flavors of binary translation:
  • dynamic recompilation - CPU instructions are decoded and compiled to native code on the fly.
  • static recompilation - An entire program is compiled to the native architecture at load time.

can you provide a little step by step introduction (just pseudo code) how dynamic recompilation works? Does it create binary or just assembler code for the target workstation?
Im little confused now, because I read something about binary translation and at the they came up with something like that.

PHP:
switch(mem_adr){
   case 0xABCD: do_something();
   case 0xABCE: do_something();
}

they are not switching opcodes, instead they switch memory adresses?
 

zenogais

New member
Chances are it would be more helpful for you to check out my tutorial on Dynamic Recompilation. Basically you're emitting pure binary, but working with the binary emitters at the assembly langauge level.
 
Last edited:

Doomulation

?????????????????????????
Your tutorial doesn't say how to translate chip8 ops into the compilation, though ;) Afaik.
Though other than that I think it was pretty good...
 

extro

New member
Doomulation said:
Your tutorial doesn't say how to translate chip8 ops into the compilation, though ;) Afaik.
Though other than that I think it was pretty good...
yeah exactly, an example with the chip8 opcode and dynarec would be really great :)
 

zenogais

New member
Doomulation said:
Yes, that would be very nice!

Ok, I'll work on translating a Chip8 opcode/series of opcodes and modify this post. Its really not that difficult if you understand assembly language :p I kept the tutorial non-chip8 specific because I wanted people emulating any system to be able to grab useful code from it.
 
Last edited:

extro

New member
zenogais said:
Ok, I'll work on translating a Chip8 opcode/series of opcodes and modify this post. Its really not that difficult if you understand assembly language :p I kept the tutorial non-chip8 specific because I wanted people emulating any system to be able to grab useful code from it.

woah, you are my man. That's good news indeed, hope it takes not to much effort. Otherwise let us know if you need any help :) thx
 

Doomulation

?????????????????????????
zenogais said:
Ok, I'll work on translating a Chip8 opcode/series of opcodes and modify this post. Its really not that difficult if you understand assembly language :p I kept the tutorial non-chip8 specific because I wanted people emulating any system to be able to grab useful code from it.
Well ehhh actually, I'm too lazy to work it out plus I'm not all-knowledgeable about assembly. I know a little, but not so many instructions.
But this will be very nice, because I was thinking of rebuilding chuit with a dynarec.
 

aprentice

Moderator
I was browsing through my programming folder and found this in my chip8 emu's directory. Since im not working on the chip8, i'll just post this here for any current or future chip8 programmers that are interested :p

This file dates back to july 6, so it was awhile ago, i dont quite remember everything in it :p
 

Doomulation

?????????????????????????
zenogais said:
Ok, I'll work on translating a Chip8 opcode/series of opcodes and modify this post. Its really not that difficult if you understand assembly language :p I kept the tutorial non-chip8 specific because I wanted people emulating any system to be able to grab useful code from it.
What happens to those dynamic recompilation opcodes? :cry: :down:
 

extro

New member
aprentice said:
I was browsing through my programming folder and found this in my chip8 emu's directory. Since im not working on the chip8, i'll just post this here for any current or future chip8 programmers that are interested :p

This file dates back to july 6, so it was awhile ago, i dont quite remember everything in it :p

hi this looks like a static version of recompilation, isn't it?

Still exited about the dynamic stuff ;)
 

zenogais

New member
Apprentice: Sorry about that, I've been incredibly busy and meant to post something on these forums. But basically for a simple Chip8 register to register move you would merely do something like this:

Code:
// Opcode: 0x8**0
mX86Assembler.MovMtoR(EAX, &mReg[((Opcode&0x00F0)>>4)]);
mX86Assembler.MovRtoM(&mReg[((Opcode&0x0F00)>>8)], EAX);

Now of course this is in unoptimized form, but this is the basic concept. Where mX86Assembler is an instance of the class X86Assembler which emits opcodes to memory.
 

extro

New member
zenogais said:
Apprentice: Sorry about that, I've been incredibly busy and meant to post something on these forums. But basically for a simple Chip8 register to register move you would merely do something like this:

Code:
// Opcode: 0x8**0
mX86Assembler.MovMtoR(EAX, &mReg[((Opcode&0x00F0)>>4)]);
mX86Assembler.MovRtoM(&mReg[((Opcode&0x0F00)>>8)], EAX);

Now of course this is in unoptimized form, but this is the basic concept. Where mX86Assembler is an instance of the class X86Assembler which emits opcodes to memory.


looks interesting, how would that MoMtoR Method look like?
 

Top