Frawley wrote:Haha, I was in the middle of editing my post when you replied. I do not have any OS loaded yet. I am just using a basic kernel that I wrote and it needs a small buffer for another interrupt. Since there is no OS loaded, can I just choose any segment I want to?
Almost any. Since you are in real mode, you should get the amount of base memory installed (int 12h, if I remember correctly, also int 15h/eax=E820h may be of use). The memory from 0 to 4FFh is reserved (real-mode interrupt vector table and BIOS data area), also the last few kilobytes of conventional memory (9C00h-9FFFh is a typical range) is reserved for the Extended BIOS Data Area. Other that that, any memory is available.
Edit: since you allocate memory in a interrupt, I would make my memory allocation routines thread-safe - since interrupts can occur anytime, you don't want the memory allocator to be in an inconsistent state when entering the interrupt handler. This means that locking and other synchronisation mechanisms will be necessary. However, in real mode, when there is only one processor executing code, a simple cli/sti type locking will suffice.
Also, if the amount of memory required is small (less than say one kilobyte), I would try to use the stack of the interrupt handler.