{"id":25763,"date":"2007-08-01T10:00:00","date_gmt":"2007-08-01T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/08\/01\/footnotes-in-win32-history-vlm-very-large-memory-support\/"},"modified":"2022-09-01T09:37:14","modified_gmt":"2022-09-01T16:37:14","slug":"20070801-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070801-00\/?p=25763","title":{"rendered":"Footnotes in Win32 history: VLM (Very Large Memory) support"},"content":{"rendered":"<p>A long-forgotten footnote in Win32 history is the set of functions known as &#8220;VLM&#8221; for &#8220;Very large Memory&#8221;. To understand VLM, you first need to understand the Alpha AXP.<\/p>\n<p>The Alpha AXP was a wonderful architecture, and I was sad to see it go. Partly because it meant that the years I spent learning the ins and outs of the processor were now just wasted space in my brain, good only for muttering incoherently during meetings and blog entries. Hang on a second&#8230;<\/p>\n<p>The Alpha AXP was a 64-bit processor. None of this &#8220;64-bit mode&#8221; versus &#8220;32-bit mode&#8221; that we have with the AMD64 and EM64T (and early versions of the Itanium). It was 64-bit all the time. Now, the instruction set did provide a few arithmetic instructions which operated on 32-bit values, but the results were always sign-extended back up to 64 bits. This one concession to 32-bit code meant that you could run code that was conceptually 32-bit on this 64-bit CPU: All the operating system has to do is treat the 32-bit addresses 0x00000000 through 0x7FFFFFFF as 64-bit addresses 0x00000000`00000000 through 0x00000000`7FFFFFFF, and treat 32-bit addresses 0x80000000 through 0xFFFFFFFF as 64-bit addresses 0xFFFFFFFF`80000000 through 0xFFFFFFFF`FFFFFFFF, The processor&#8217;s natural sign extension did the rest.<\/p>\n<p>(And now you can see another reason why there is a no-man&#8217;s land around the 2GB boundary. If objects were allowed to cross the 2GB boundary, they would end up being split up when converted to the Alpha AXP&#8217;s 64-bit address space.)<\/p>\n<p>This is sort of analogous to running 16-bit Windows programs on an 80386 processor. Your 16-bit program could still use those 32-bit registers if it only knew they were there.<\/p>\n<p>This clever design of the Alpha AXP meant that you could read through quite a bit of Alpha AXP assembly language without being able to tell whether the code was designed as 32-bit or 64-bit code since it all looked the same. The only giveaway would be when the code loaded a pointer from memory.<\/p>\n<p>Anyway, back to VLM. Windows\u00a0NT on an Alpha AXP was a 32-bit operating system on a 64-bit processor. The 32-bit address space was only a tiny fraction of the full 64-bit address space available to the processor. And VLM gave you access to that space that would otherwise go wasted.<\/p>\n<p>You allocated memory in the 64-bit address space with functions like <code>VirtualAllocVlm<\/code>. All of the VLM functions operated on 64-bit pointers (called <code>PVOID64<\/code>). Allocating memory via VLM returned you a <code>PVOID64<\/code>, a 64-bit pointer to the memory, and your program had to use these 64-bit pointers to access the memory. And like its successor AWE, VLM allocated non-paged memory.<\/p>\n<p>In addition to allocating memory, there were special functions for memory-mapping a file into the 64-bit address space and performing disk I\/O into and out of these 64-bit addresses. But that&#8217;s about it. The rest of Win32 still used 32-bit pointers, so you couldn&#8217;t pass these 64-bit addresses to functions like <code>lstrcmpi<\/code>. You were given the raw materials for allocating memory in the 64-bit address space and the rest was up to you.<\/p>\n<p>These functions were designed for high-end database programs which required enormous quantities of memory and (more importantly) address space. The memory wasn&#8217;t pageable because high-end database programs invariably perform their own highly specialized memory management, and paging just gets in the way.<\/p>\n<p>With the death of the Alpha AXP also came the death of VLM, since the Alpha AXP was the only architecture that supported 64-bit addresses in 32-bit code.<\/p>\n<p>This model of programming is not dead, however. It was seen in Windows\u00a03.1 with the <code>WINMEM32<\/code> library (which even let you create 32-bit code segments!), and a more restricted version of it lives on in AWE.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ah, the Alpha AXP.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2],"class_list":["post-25763","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Ah, the Alpha AXP.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=25763"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25763\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=25763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=25763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=25763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}