<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Issues in Writing a VM &#8211; Part 2</title>
	<atom:link href="http://www.algorithm.co.il/blogs/programming/python/issues-in-writing-a-vm-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/</link>
	<description>Algorithms, for the heck of it</description>
	<lastBuildDate>Tue, 21 Jun 2011 21:07:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: avi</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-117</link>
		<dc:creator>avi</dc:creator>
		<pubDate>Tue, 01 Apr 2008 04:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-117</guid>
		<description>I&#039;ve just discovered your blog. Fantastic! Keep on writing.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just discovered your blog. Fantastic! Keep on writing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lorg</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-116</link>
		<dc:creator>lorg</dc:creator>
		<pubDate>Sat, 29 Mar 2008 19:59:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-116</guid>
		<description>Also, Arkon: the change to eip Erez suggested may be done by the VM manually. It doesn&#039;t necessarily involve changing the expressions.</description>
		<content:encoded><![CDATA[<p>Also, Arkon: the change to eip Erez suggested may be done by the VM manually. It doesn&#8217;t necessarily involve changing the expressions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lorg</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-115</link>
		<dc:creator>lorg</dc:creator>
		<pubDate>Sat, 29 Mar 2008 19:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-115</guid>
		<description>My solution was just checking if the IP register was *touched*.

The CPU class knows what is the IP register, and the VM can ask it about it.
Each time a register is modified, the VM-state holder checks if it&#039;s the eip register, and if it is, it sets a flag to True. Before each instruction, the VM checks to see if the flag is false. If it is, it modifies the IP.  If it isn&#039;t it keeps the IP value, and resets the flag back to false.

In effect, this is a hook by the VM state on register changes. I know it special-cases the IP register, but I think that&#039;s OK.</description>
		<content:encoded><![CDATA[<p>My solution was just checking if the IP register was *touched*.</p>
<p>The CPU class knows what is the IP register, and the VM can ask it about it.<br />
Each time a register is modified, the VM-state holder checks if it&#8217;s the eip register, and if it is, it sets a flag to True. Before each instruction, the VM checks to see if the flag is false. If it is, it modifies the IP.  If it isn&#8217;t it keeps the IP value, and resets the flag back to false.</p>
<p>In effect, this is a hook by the VM state on register changes. I know it special-cases the IP register, but I think that&#8217;s OK.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arkon</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-114</link>
		<dc:creator>arkon</dc:creator>
		<pubDate>Sat, 29 Mar 2008 19:46:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-114</guid>
		<description>Ah I forgot to mention that you will have to change the expression trees so that all IP references as rvalues will use the shadowed IP..</description>
		<content:encoded><![CDATA[<p>Ah I forgot to mention that you will have to change the expression trees so that all IP references as rvalues will use the shadowed IP..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arkon</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-113</link>
		<dc:creator>arkon</dc:creator>
		<pubDate>Sat, 29 Mar 2008 19:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-113</guid>
		<description>Ahh Eres nice idea. But if we care about performance, I&#039;m not sure whether inserting an expression all the times, where sometimes they won&#039;t be used, is good enough. Though on the other hand, it depends on how quick you know if there was a change.

The easiest, ok not the easiest, but the best solution would be to have an IP register and a shadow IP register. The shadow register will contain the current IP, and will be used for rvalues only. The IP register will be reset to undefined every instruction. Then if the real IP register was set, you will know to use it. Otherwise continue to next instruction, and set the shadow one again.
This wasy even if an instruction jumps to itself it will keep on working...</description>
		<content:encoded><![CDATA[<p>Ahh Eres nice idea. But if we care about performance, I&#8217;m not sure whether inserting an expression all the times, where sometimes they won&#8217;t be used, is good enough. Though on the other hand, it depends on how quick you know if there was a change.</p>
<p>The easiest, ok not the easiest, but the best solution would be to have an IP register and a shadow IP register. The shadow register will contain the current IP, and will be used for rvalues only. The IP register will be reset to undefined every instruction. Then if the real IP register was set, you will know to use it. Otherwise continue to next instruction, and set the shadow one again.<br />
This wasy even if an instruction jumps to itself it will keep on working&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lorg</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-112</link>
		<dc:creator>lorg</dc:creator>
		<pubDate>Sat, 29 Mar 2008 01:36:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-112</guid>
		<description>You are right in regards to the real solution, this is a very good point. However, it might apply differently to other processors. It might still be workable there by changing the instructions&#039; expression trees. In any case I&#039;ll probably have to work it in. Thanks!

As to appending the change to the IP:
This solution was workable, but more work, and it meant modifying the expressions. The third solution is more general, and it seems to me to be more elegant.</description>
		<content:encoded><![CDATA[<p>You are right in regards to the real solution, this is a very good point. However, it might apply differently to other processors. It might still be workable there by changing the instructions&#8217; expression trees. In any case I&#8217;ll probably have to work it in. Thanks!</p>
<p>As to appending the change to the IP:<br />
This solution was workable, but more work, and it meant modifying the expressions. The third solution is more general, and it seems to me to be more elegant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erez</title>
		<link>http://www.algorithm.co.il/blogs/computer-science/issues-in-writing-a-vm-part-2/#comment-111</link>
		<dc:creator>Erez</dc:creator>
		<pubDate>Sat, 29 Mar 2008 00:02:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/index.php/programming/python/issues-in-writing-a-vm-part-2/#comment-111</guid>
		<description>Regarding the 2nd 2:
Appending a change to the IP should work for all instructions, if you follow the IP to figure out what statement to execute next.

The real solution however (and you should know it), for Intel at least, is *prepending* the change to the IP for all instructions. It works for absolute jumps, and especially relative ones: jumps/calls are relative to the end of the instruction.</description>
		<content:encoded><![CDATA[<p>Regarding the 2nd 2:<br />
Appending a change to the IP should work for all instructions, if you follow the IP to figure out what statement to execute next.</p>
<p>The real solution however (and you should know it), for Intel at least, is *prepending* the change to the IP for all instructions. It works for absolute jumps, and especially relative ones: jumps/calls are relative to the end of the instruction.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

