Let's Code MS DOS 0x29: Extended Memory XMS

2,503
0
Published 2024-07-10
In the previous episode we learned how to use Expanded Memory even down to the original IBM PC. From the IBM AT and other 286 machines onwards we can use Extended Memory instead. It doesn't require any additional hardware and allows you to use more than 640K of memory in real mode MS DOS programs.

Support me on Patreon: www.patreon.com/root42
Support me on Ko-Fi: ko-fi.com/root42
Support me on PayPal: paypal.me/ArneSchmitz
Support me on YouTube: youtube.com/channel/UCPjFa_UZBUDzdJTIEdyGjIQ/join

Music: A Little Wonder by Spino2006

Source Code: codeberg.org/root42/dosxms

All Comments (14)
  • @robertsundling
    This really brought me back to the early 90’s! Good stuff. This is exactly how I had to do things before I could afford tools to program in protected mode. Thanks for this trip down memory lane—pun intended. By the way, don’t forget to add 1023 to the number of bytes you’re allocating (when calculating total_size) before dividing by 1024, since 320*200 isn’t divisible by 1024. (You’re technically 512 bytes short there, with N_FRAMES 35.) 😃
  • @karlfoley
    Remember authoring a memory management course years ago. By forcing VGA to mono mode you were able to extend the 640KB limit to 700KB+ by including the VGA colour memory into the memory map
  • Very nostalgic. I used to develop a gamedev library that extended qbasic and it had some nice XMS based sprite routines. ie, Load all assets to XMS, then fetch when needed. It was fast enough for tilebased games and you never need to map memory(unlike EMS), once you finish setting it up. I can just call xmsSprite(....) and it would just do it like conventional RAM. You still have to pass an XMS handle as argument but that was it. I temember it still worked on Windows 98 SE.
  • @LeoOno
    wow, this is so nostalgic :) !
  • @maxmuster7003
    On 80386+ i like to use the 16 bit BIG real mode with DS,ES,FS,GS=4 gb and CS,SS=64 kb + A20 gate on. With VBE 2/3 bios we can write directly into the linear framebuffer with 32 bit data and 32 bit addresses using instructions with operand size prefix(hex 66) + addresss size prefix(hex 67). The 16 bit Big mode allows to use 16 bit DOS and BIOS function and himem.sys.
  • @arlandi
    interesting to see this run on PCem or 86box. thanks for the video.
  • 286 has LOADALL bug, which lets to setup segment registers and address full 16MB registers so XMS possible without standard protected mode enter/exit. Also there is a double trap trick for faster 286 protection mode exit.
  • total noob at asm and dos programming here: you first initialize the far pointer to the main XMS procedure from the returned segment and offset stored in es and bx respectively. Then you call this function using call es:[XMSPtr] but before that you overwrite es with ds which I don’t understand because I don’t how it ended up in ds.
  • @IExSet
    Wow, i just cought video which not liked yet ! 😂