{"id":606,"date":"2009-10-18T11:01:07","date_gmt":"2009-10-17T23:01:07","guid":{"rendered":"https:\/\/www.deltics.co.nz\/blog\/?p=606"},"modified":"2009-10-18T20:07:05","modified_gmt":"2009-10-18T08:07:05","slug":"learning-experiences","status":"publish","type":"post","link":"https:\/\/www.deltics.co.nz\/blog\/posts\/606\/","title":{"rendered":"Learning Experiences &#8211; Moving The Execution Point Pre-Delphi 2010"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">[Estimated Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes]<\/span><\/span><p>Thanks to commenters I have already learned two useful things as a result of yesterday&#8217;s post, both things which I cannot fathom how I did not already know. \u00a0But here&#8217;s something I learned for myself as a result of a comment made by Malcolm Groves at the Auckland Delphi 2010 launch day recently.<\/p>\n<p><!--more-->As mentioned in yesterdays post, a new feature in Delphi 2010 is the ability to drag and drop the execution point when stopped in debug mode.<\/p>\n<p>However, Malcolm mentioned that this could be achieved &#8211; rather more awkwardly &#8211; in previous versions of Delphi via the CPU window, although the precise details escaped his memory at the time, other than that it involved modifying the contents of a particular register.<\/p>\n<p>I found myself last night in exactly the situation I described in my speculative &#8220;when this might be useful&#8221; discussion of moving execution points. \u00a0I happened to be in an older version of Delphi at the time and it was a relatively small project so a &#8220;halt, modify, recompile and retest&#8221; cycle wouldn&#8217;t have been too arduous, but I decided instead to reach for the CPU window to see if I couldn&#8217;t figure out how to achieve it and see just how awkward it might be.<\/p>\n<p>It didn&#8217;t take long, and actually, it wasn&#8217;t too awkward at all.<\/p>\n<p>Here&#8217;s the CPU view, with an additional bit of highlighting to draw attention to the useful areas (click to embiggen):<\/p>\n<figure id=\"attachment_608\" aria-describedby=\"caption-attachment-608\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/registers.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-608 \" title=\"CPU View\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/registers.jpg?resize=300%2C104&#038;ssl=1\" alt=\"CPU View (with highlighting)\" width=\"300\" height=\"104\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/registers.jpg?resize=300%2C104&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/registers.jpg?w=678&amp;ssl=1 678w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-608\" class=\"wp-caption-text\">CPU View (with highlighting)<\/figcaption><\/figure>\n<p>The two connected box highlights show that the EIP register contains the current execution point address. \u00a0So this is the register that Malcolm was referring to.<\/p>\n<p>Now, there are actually TWO ways we can use this information to change the execution point in older Delphi versions&#8230;<\/p>\n<p>You can either position the highlight in the CPU disassembly view on the desired execution point and invoke the &#8220;New EIP&#8221; item on the disassembly context menu:<\/p>\n<figure id=\"attachment_609\" aria-describedby=\"caption-attachment-609\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/New-EIP.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-609 \" title=\"New EIP\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/New-EIP-300x286.jpg?resize=300%2C286&#038;ssl=1\" alt=\"Move EIP to Selected Line\" width=\"300\" height=\"286\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/New-EIP.jpg?resize=300%2C286&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/New-EIP.jpg?w=488&amp;ssl=1 488w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-609\" class=\"wp-caption-text\">Move EIP to Selected Line<\/figcaption><\/figure>\n<p>Or you can directly increment or decrement the EIP register using the register view context menu:<\/p>\n<figure id=\"attachment_610\" aria-describedby=\"caption-attachment-610\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Increment-EIP.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-610 \" title=\"Increment EIP\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Increment-EIP-300x117.jpg?resize=300%2C117&#038;ssl=1\" alt=\"Increment or Decrement EIP Register\" width=\"300\" height=\"117\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Increment-EIP.jpg?resize=300%2C117&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Increment-EIP.jpg?w=711&amp;ssl=1 711w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-610\" class=\"wp-caption-text\">Increment or Decrement EIP Register<\/figcaption><\/figure>\n<p>In this capture I&#8217;ve also highlighted the address of the next executable point corresponding to a line of source in my code &#8211; you will notice that the addresses in that list are non-contiguous, and when incrementing or decrementing the EIP value I think you need to be careful that you set the value to an address that corresponds to one of the addresses in this list.<\/p>\n<p>When you increment\/decrement the EIP register, the value is incremented as a simple value, without respect to this list of addresses. \u00a0i.e. &#8220;Increment&#8221; add&#8217;s 1 (one) to the value, it doesn&#8217;t advance it to the &#8220;next valid address&#8221;.<\/p>\n<p>I&#8217;m not sure what would happen if you tried to resume execution from an address that is not in that CPU disassembly list, but I&#8217;m pretty confident it wouldn&#8217;t be &#8220;good things&#8221;.<\/p>\n<p>So grateful thanks to the commenters to my previous post and to Malcolm for furthering my awareness of things already at my disposal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">[Estimated Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes]<\/span><\/span>Thanks to commenters I have already learned two useful things as a result of yesterday&#8217;s post, both things which I cannot fathom how I did not already know. \u00a0But here&#8217;s something I learned for myself as a result of a comment made by Malcolm Groves at the Auckland Delphi 2010 launch day recently.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4],"tags":[95,292],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-debugging","tag-delphi"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1TKYv-9M","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":5,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":612,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/606\/revisions\/612"}],"wp:attachment":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}