-
I've been struggling to implement skip instructions for the RL78 for quite some time now. It seems the best way to go about it is to use a similar approach to what is used for ARM. However, because any instruction can be skipped, this makes all branches, calls and returns conditional and causes the decompiler to fail 90% of the time. This is usually due to exceeding the maximum instruction count. An alternative is to use local context and this actually works great, until it doesn't. The problem here occurs when an instruction which follows a skip instruction is branched into. Since there is a difference in instruction context disassembly "fails" and the decompiler will usually start puking I think the best way, other than built in support for skip instructions, would be to use the first approach with some way to tell the flow analysis and the decompiler that a branch/call/return is only conditional if it has been proceeded by a skip instruction. Any ideas on how to do this that won't suffer from the same issues when using context? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 40 replies
-
I think I just figured out a solution. I will use pcode injection for the skip instructions because I can get the next instruction and its lenses to inject the appropriate pcode to skip it from the java api. |
Beta Was this translation helpful? Give feedback.
-
Well, this is extremely gross but here is a work around. Having to put up with the "removing unreachable block" warnings and error bookmarks everywhere is much much better than not having it implemented at all. Luckily the bookmarks from disassembly "error" isn't a problem because the disassembly by flow to the next instruction occurs first. The pcodeop
|
Beta Was this translation helpful? Give feedback.
-
Have you looked at the PA-RISC approach or considered the use of delays slots (you are allowed to branch into a delay slot)? As you discovered context is dicey for this type of skipping logic and should probably be avoided due to the dynamic nature (an instruction may be skipped or not-skipped depending on flow). |
Beta Was this translation helpful? Give feedback.
-
Sleigh support for |
Beta Was this translation helpful? Give feedback.
Sleigh support for
inst_next2
has been merged into master for 10.2 release.(See ca80be4)