More C0D4G3

Monday, July 31, 2006

Part 1 done

The entire IllexBoyAdvance core has been rewritten, so now it outputs code while it executes it. Actually, this is pretty old news, and the guys at GP32X have known it for a while. I'm just lazy when it comes to updating this blog. :P

Part 2, while requiring much less code than Part 1, will be much harder as it's not repetitive nor simple:
Picture a bank of memory. It contains all the memory that can contain executable code. This includes the BIOS, RAM, ROM, and whatever else.

A normal static-recompiler will output one code-block for each address it reads from on run-time.
Now, we have a very small, but fast RAM, and a very large but slow ROM. How much do you want to bet that people are swapping their code into RAM as needed to speed things up? This creates a little problem: Each address can contain many different instructions in the course of execution.
Self-modifying code is the Achilies Heel of static recompilers. So, does that mean I got myself into a dead end?
No. But that is why Part 2 is so much harder than Part 1.
I see three paths to overcoming this obstacle:
1) Ignore it.
Maybe I'm wrong and nobody executes stuff on RAM. Maybe only a few games do. I have to do some tests and find out if I actually have a problem in my hands or not.

2) Binary Tree style.
Remember that bank of memory I mentioned earlier? For each executable instruction, I'd have a pointer to a Bintree, where previously executed instructions are the keys. Whenever there's a Jump/Call, the emulator looks for the appropriate tree in a big array, uses the instruction to find out if it has been decompiled before or not, and then:
If it has NOT been decompiled previously:
Compile it, add the code offset to the tree.

If it has been decompiled: Compare each instruction of the code currently being decompiled, and the version that was done previously. If a jump is reached and all opcodes are the same, then there is nothing to do. If not all the opcodes are the same, store the offset of the first different opcode, output a new disassembly, without overwriting the previous one.

When executing code that has already been recompiled, each time there's a jump, look in the array for the corresponding tree, get an offset, compare it with the the opcode it's supposed to execute. If it's good, jump to the pre-compiled code. If not, resort to the interpretor.

3) Dynarec Style.
For each code block, there's a translated code cache. When an instruction overwrites memory that has been recompiled, the cache block is invalidated (thrown away). Of course, there's no chance of doing that here. Instead, a new cache would have to be made, and some sort of hash would differenciate the caches.

Both methods 2 and 3 have a heavy performance penalty on the emulator, but it remains faster than a Dynarec. As can be seen, neither are trivial to implement, so I have to give this a whole lot of thought before I start coding. If anybody has any suggestions (even if it's to say, "Your blog entry made no sense. Please refrain from blogging at 1AM") I'd really like to hear them.
That's what I created the A7Board for. http://tkf15h.phpnet.us

18 Comments:

At 7:27 AM, Anonymous Anonymous said...

The biggest problem is that code may be modified, ie uncompressed, when put from ROM to RAM. Then all static decompilation stuff is worthless. Unless you do in "DynaRec" style - recompile all, call it, see, monitor, if memory changed, if yes, recompile it once again (with modified memory), call again, etc. Terrible.

 
At 5:56 PM, Anonymous Anonymous said...

cant wait for IBA! £50 donation heading your way when its done!

 
At 12:12 PM, Anonymous Anonymous said...

TKF15H, any updates on the status? Thanks for all the work.

 
At 3:16 PM, Anonymous Anonymous said...

This comment has been removed by a blog administrator.

 
At 5:27 PM, Anonymous Anonymous said...

This comment has been removed by a blog administrator.

 
At 7:06 PM, Blogger Unknown said...

Sorry for not showing any work done. I simply haven't the time for a hobby (ie coding), and my GP2X is kinda bricked (boots when it wants to, the result of prolonged use leading to over-heating I guess). Even if it did work reliably, its 1200km away (back in Rio, I'm in Recife again). My coding rig is also back in Rio, so if I had the time I wouldn't be able to code anyway. >_<

 
At 9:34 AM, Anonymous Anonymous said...

I am truly pleased to read this blog posts which contains tons of useful information, thanks for providing these statistics.


my web-site animation-world.com

 
At 9:40 AM, Anonymous Anonymous said...

Internet is the biggest server of fun with a lot of variety.

o To make sure that the funny element remains intact inside your text message,
keep that short and simple. There are a few selections of these to choose from on this site too.


my blog post ... click the next document

 
At 9:43 AM, Anonymous Anonymous said...

If you are exercising every day, the fat you burn will be harnessed into muscle.
It is important that you realise that if you do miss one
of your exercise sessions it is not the end of the world.
Most of us love it; going to Mac - Donald or Burger King from
time to time.

my blog post; women fitness tips abs

 
At 12:35 PM, Anonymous Anonymous said...

[b][url=http://googlegm.weclub.info/viewthread.php?tid=31897&extra=]prada bags[/url][/b] Micronesia (Stati federati). Isole half way. Moldova. new home buyers ocean, land also is fight counterfeit options. earlier this month all over oregon, form place Hermes most likely was accorded a staggering $100 million in may damage while fighting 34 internet websites that many put up for sale imitations of its luxury handbags. in case, The ny find out standard the position associated with internet and then investigation engines like google have fun with in aiding the activity, In buying google, ask but search engines to avoid leaving inbound links path of the bad lookup directories,


[b][url=http://www.octopus38.com/forum.php?mod=viewthread&tid=2988720]wholesale handbags[/url][/b] going to a good idea this remedy by simply my own diamond ring internet affiliate web link. that way i'm able to pull in commissions on what other buyers vended. effective ways i stumbled onto right away was to buying a thoughtful in addition to the unique website address refocus this is my the domain to partner resource.


[b][url=http://www.awebcafe.com/blogs/viewstory/821878]burberry bags[/url][/b] has been doing your entire cleanser can be found in box structure? If element engages in and all families need to explore switch to educate yourself in relation to something else entirely thanks to the fact the icon version fat reduction exacerbating your problem there could be this : at the same time retinoid relying prescribed medication will probably cut down on your skin petrol formulating all over the actual attracts carried out. sebaceous glands tend to be remarkably private and way past respond for more info considering in particular going to be the slightest reason and that is this one reason it is that and consequently easy to understand more about intensify these items. It doesn legal matter whether all your family members allow for greasy in addition totally dry charm,your folks really should exfoliate a use them and in addition develop an all in one week.

 
At 1:39 AM, Anonymous Anonymous said...

Make a list of your nutrition chart involving juice
and fruits at the top followed by green vegetables and milk products.
It will help the prospective health and fitness aspirant keep
pace with the ever evolving world of fitness. These tips are followed by every pregnant woman all around
the world but remember whatever you do, you should first check with
your gynecologist so that there is no complication in your pregnancy.


My web-site: thesciencesphere.com

 
At 12:04 PM, Anonymous Anonymous said...

They aim at miming various good qualities of the counterparts
of the assumed celebrity. " Earlier today some cruise ship struck land in Alaska. If a person is connected with the latest headlines, it will develop an awareness in him with regards to the world which surrounds him.

Here is my web page - Latest Daily News

 
At 4:49 AM, Anonymous Anonymous said...

One can find lot of such funny sports moments very easily.

If you have your own website and want to use these Funny Animated Gif Images on the home page of your website
then you can easily take these images and place them on
your websites. However, for the next several miles until we got to our hotel, he smelled pretty dog-gone good, not.


Here is my website free funny pictures and signs

 
At 7:59 AM, Anonymous Anonymous said...

[url=http://yuanmeng360.net/space.php?uid=24547&do=blog&id=647462]unique handbags[/url] What are typical, understood reactions to the outlook Pro?


[url=http://www.wh189.cn/forum.php?mod=viewthread&tid=251096]cheap hermes bags online[/url] Kwa disgusting bwana Yoshinari alipendezwa na mawasiliano kati you watu tofauti aliamua kuwasiliana siyo tu kwa maneno lakini pia kwa mavazi. Kbuenos aires kubadilishana nguo unasaidia kuunganisha tu mila na jinsia tofauti. Basi alipenda sana task huu na kuifanya katika mji wa Nairobi.


[url=http://www.bbs.eucnt.com/viewthread.php?tid=721833&extra=]bags leather[/url] promotion UGG Knightsbridge keep

 
At 11:01 AM, Anonymous Anonymous said...

Hi there, after reading this awesome post i am too
cheerful to share my knowledge here with friends.

My webpage gngg.info

 
At 6:39 AM, Anonymous Anonymous said...

Here again you want to find or even create an angle or slant in which you
can take headline news and 'incorporate' it into a
post you are composing. It’s interesting how stars
get annoyed when the paparazzi takes pictures of them.
This is why the said Albanian gossip thashetheme celebrity news blog page is
written in Albanian '.

Here is my webpage :: latest celeb news

 
At 5:42 AM, Anonymous Anonymous said...

Hi! I simply want to give you a huge thumbs
up for the great info you've got here on this post. I will be returning to your web site for more soon.

Feel free to visit my blog; dentalshout.com

 
At 5:39 AM, Anonymous Anonymous said...

http://www.dolabuy.com/celine-bags.htm celine handbag louis vuitton belt size 34 louis v shoes pidgin louis vuitton sandal hermes house band que sera sera cancel louis vuitton spring collection cede broadcast offset celine bags

 

Post a Comment

<< Home