Question

Program loaders of simple OS like DOS, read the program code from a floppy or a HDD and move its byte code to the RAM.

Question 1: Where the byte code is moved exactly? To the Heap, Stack or another region of the RAM?

Lets have a look at this asm code: mov eax, 5. "5" is a value, that is moved to the RAM, too.

Question 2: How can the value be moved into eax? Does a mov-opcode exists for that?

Was it helpful?

Solution

Question 1: Where the byte code is moved exactly? To the Heap, Stack or another region of the RAM?

The exact location generally depends on:

  • the OS
  • the amount of memory installed
  • the program
  • the history of memory allocation

It's rare for programs to run inside of other programs or to share stack and heap with one another and they usually have their own.

DOS simply finds a free block of memory, where the program can fit and loads it there, potentially slicing the block in two. AFAIR, there is a way to prefer lower or higher addresses, but that's pretty much it. Resident programs and drivers will obviously affect the location.

Question 2: How can the value be moved into eax? Does a mov-opcode exists for that?

This must have been a separate question. Yes, there is an instruction for mov eax, 5 on i80386+ CPUs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top