📄 instructiongenerator1.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>Finding Classes</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" text="#000000" link="#0000FF" vlink="#0000CC" alink="#6666FF">
<h1><img alt="" src="findClasses.gif" width="32" height="32">Generating instructions.
Part 1.</h1>
<h2>Some basics.</h2>
<h3><A HREF="index.html"><img alt="" src="revendepro.gif" width="16" height="16" border="0">Revendepro page.</A></h3>
<p>I think there are two main types of instruction:</p>
<ul>
<li>Assignment instructions, these include mov, add, xor, call etc.</li>
<li>Jump instructions, the jump instructions with or without condition.</li>
</ul>
<p>All other types of instructions aren't very important right now. And to make
it even simple I expect that the proc contains only of not call assignment instructions.
Now I would like to make a general form if these instructions having a Source
and a Target. For example mov eax, ecx, has a target eax and as source ecx.
But we also must support xor eax, ecx, which has a target eax, and as source
ecx xor eax. So how do make the Source and Target. I think about one basic Source
class with descendent for the following types:</p>
<ul>
<li>RegSource: a source that specifies a reg and its type (dword, low word,
high byte, low byte).</li>
<li>ConstSource: a source that uses a constant value as input.</li>
<li>RefSource: a source that specifies a other source, which is uses as pointer,
it must also specify the size that is pointed.</li>
<li>DuoSource: a source that requires two sources, and applies some operation
on it like: multiply, divided, add, and, xor, etc.</li>
</ul>
<p>With these sources I think we covered the most important thing. Because I already
have the source for a disassembler, It wasn't hard to write some code that converted
a instruction into a AssignInstruction, but because I'm lazy I did write just
a very small part which can easily be extended. I only also need something to
make identify a Ret instruction. Now that we can convert an procedure to an
row of assign instructions. I would like to be able to append some of these
instructions as explained with the following example:</p>
<table border="1" width="100%">
<tr>
<th>Assembler</th>
<th>Assign instructions</th>
<th>Append assign instructions</th>
</tr>
<tr>
<td>
<p>mov eax, [eax]<br>
mov eax, [eax]</p>
</td>
<td>eax := PDWord(eax)^<br>
eax := PDWord(eax)^</td>
<td>eax := PDWord(PDWord(eax)^)^</td>
</tr>
</table>
<p> So what exactly do I want:<br>
<br>
I want to replace two successive assign instructions with one instruction in
which is the same as the last instruction only with the the Target of the first
replaced with the Source of the first instruction.<br>
<br>
I came with the following requirements for appending two successive instructions:</p>
<ul>
<li>The procedure consists of only assignments and Ret instructions.</li>
<li>Target of the first instructions is a register, because if it is something
else it's value might be used somewhere else.</li>
<li>The Target is set again and not used before it is set again.</li>
<li>None of the instructions might include a call.</li>
</ul>
<p>Having all this, it is just a matter of implementing it.</p>
<hr>
<a href="InstructionGenerator2.html">Part2: Real pascal</a>
<hr>
<a href="http://www.puthoon.com" target="_top"><img alt="" src="puthoonMini.gif" width=20 height=20 border=0></A><FONT Face="Symbol,fantasy">Puqwn</FONT><BR>
E-mail: <a href="MAILTO:puthoon@puthoon.com">puthoon@puthoon.com</a>
<HR>
Copyright © 1999, 2000 Puthoon. All rights reserved
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -