{"id":783,"date":"2018-12-28T21:18:03","date_gmt":"2018-12-28T21:18:03","guid":{"rendered":"http:\/\/pdp2011.sytse.net\/wordpress\/?p=783"},"modified":"2018-12-28T21:18:03","modified_gmt":"2018-12-28T21:18:03","slug":"stack-limit","status":"publish","type":"post","link":"https:\/\/pdp2011.sytse.net\/wordpress\/stack-limit\/","title":{"rendered":"Stack limit"},"content":{"rendered":"<p>Some weeks ago I was involved in a discussion about how the leds on the 11\/70 should work &#8211; more specifically, how to deal with the differences in the &#8216;real&#8217; hardware and Oscar Vermeulen&#8217;s PiDP-11 console. I had what I thought was a rather nice idea, but it wasn&#8217;t received very well &#8211; and, given the lack of real and working 11\/70 systems about, it wasn&#8217;t very easy to find out what was &#8216;right&#8217;. So I thought about it for a while, and decided to focus on something else for a while. The idea I came up with was to revisit the old 11\/70 test programs. The first one in the set, EKBA, I had already managed to run flawlessly, but I didn&#8217;t spend much time with the second one, EKBB.<\/p>\n<p>Maybe it was my subconscious playing a trick, because EKBB is &#8211; as far as I know, at least &#8211; the only program that includes a console test&#8230; and that very quickly proved that my nice idea for the console wasn&#8217;t working at all. But after reverting it, I then decided to have a look at all the other error messages that EKBB was throwing at me. Mainly these were in two categories &#8211; DIV condition codes and stack limit behaviour.<\/p>\n<p>The DIV condition codes caused a bit of a headache &#8211; again, I should probably say, but because the last time I looked at this bit of core is already 8 years ago, the details had slipped a bit. I did manage to fix a couple of the error &#8211; messages, I should probably add, because functionally it did work correctly already; what the tests do is determine at which point the DIV instruction is aborted in a number of edge cases such as divide by zero.<\/p>\n<p>More interesting really were the errors about the stack limit.<\/p>\n<p>Originally, PDP2011 was going to be something like an 11\/94 &#8211; since that seemed the most interesting model, and also I had the listings for the ZKDJ test that showed the actual workings of the machine in much greater detail than the manuals did. When that worked, I added the other models mostly by selectively disabling bits of the core for 11\/94. But, 11\/94 may have the highest number, but it isn&#8217;t in all respects the most complex machine &#8211; and, one of those is the stack limit, which is a lot more complex and different in 11\/70 (and 11\/45 too, for that matter). And, the version that I had implemented might pass the tests for the J-11 cpus, 11\/34 and 11\/44, but it certainly did not pass the tests for 11\/70.<\/p>\n<p>Turns out I had misunderstood quite a bit of the way it is supposed to work. For instance, I had assumed that the initial (after reset) value of the stack limit register should be 400. But actually, it should be 0 &#8211; and the limit of 376 and 340 above that is arranged in logic. And, even more of a surprise, the stack limit mechanism also protects the PSW from being overwritten by the stack &#8211; and in the 11\/45, even more internal registers are.<br><a href=\"\/wordpress\/wp-content\/uploads\/2018\/12\/Screenshot-2018-12-28-at-22.02.22.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-784 size-large\" src=\"\/wordpress\/wp-content\/uploads\/2018\/12\/Screenshot-2018-12-28-at-22.02.22-1024x816.png\" alt=\"\" width=\"640\" height=\"510\"><\/a><br>So as usual the interesting question is, how can it be that PDP2011 systems of all possible configurations &#8211; including quite a few 11\/70 &#8211; have run since November 2011 and this bug wasn&#8217;t ever found? I&#8217;d speculate that the operating systems usually don&#8217;t run into yellow or red stack traps &#8211; and if they do, it is probably a secondary effect of something else going wrong. If that is the case, the errors wouldn&#8217;t be recoverable, and then it doesn&#8217;t matter so much if the trap mechanism doesn&#8217;t work entirely as it should.<\/p>\n<p>Anyway, it&#8217;s fixed now. Not that EKBB now passes flawlessly &#8211; there are a few puzzles left in it. But first up now is to go back to the console and the leds. And oh, what I almost forgot &#8211; thanks to J\u00f6rg Hoppe for providing the listings of these tests, and obviously Al Kossow too for everything Bitsavers. None of this would be possible without freely accessible documentation.<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some weeks ago I was involved in a discussion about how the leds on the 11\/70 should work &#8211; more specifically, how to deal with the differences in the &#8216;real&#8217; hardware and Oscar Vermeulen&#8217;s PiDP-11 console. I had what I thought was a rather nice idea, but it wasn&#8217;t received very well &#8211; and, given [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-783","post","type-post","status-publish","format-standard","hentry","category-pdp11","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/posts\/783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/comments?post=783"}],"version-history":[{"count":0,"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"wp:attachment":[{"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pdp2011.sytse.net\/wordpress\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}