Page 1 of 1

Data overwrites interrupt table here?

Posted: Tue Mar 22, 2016 4:31 am
by bilsch01
There is a real mode program here: http://wiki.osdev.org/Real_mode_assembly_bare_bones.
It begins with a set up like this:

Code: Select all

 org 0x7C00   ; add 0x7C00 to label addresses
 bits 16      ; tell the assembler we want 16 bit code
 
   mov ax, 0  ; set up segments
   mov ds, ax
   mov es, ax
   mov ss, ax     ; setup stack
   mov sp, 0x7C00 ; stack grows downwards from 0x7C00
QUESTION: doesn't the data begin by overwriting the interrupt table at 0000:0000 ?

TIA. Bill S.

Re: Data overwrites interrupt table here?

Posted: Tue Mar 22, 2016 4:50 am
by Octocontrabass
That code sets SS:SP to 0000:7C00, which is nowhere near 0000:0000.

Why do you think this will overwrite the IVT?

Re: Data overwrites interrupt table here?

Posted: Tue Mar 22, 2016 5:41 am
by iansjack
The IVT will only be overwritten if the stack grows to be 0x7c00 bytes in size. Should this happen you probably have bigger issues to worry about.

Re: Data overwrites interrupt table here?

Posted: Tue Mar 22, 2016 12:36 pm
by bilsch01
I'm not talking about the stack. I mean this data:

Code: Select all

welcome db 'Welcome to My OS!', 0x0D, 0x0A, 0
 msg_helloworld db 'Hello OSDev World!', 0x0D, 0x0A, 0
 badcommand db 'Bad command entered.', 0x0D, 0x0A, 0
 prompt db '>', 0
 cmd_hi db 'hi', 0
 cmd_help db 'help', 0
 msg_help db 'My OS: Commands: hi, help', 0x0D, 0x0A, 0
 buffer times 64 db 0
Where does this string begin: Welcome to My OS !

Re: Data overwrites interrupt table here?

Posted: Tue Mar 22, 2016 1:08 pm
by Techel
Since you set up the segment registers to be 0, the location accessed will be 0x7C00 (the starting offset specified with org) plus the offset of the data within the file.

Re: Data overwrites interrupt table here?

Posted: Sat Mar 26, 2016 12:57 pm
by Roman
BIOS loads the boot sector at 0x7C00.

Re: Data overwrites interrupt table here?

Posted: Sat Mar 26, 2016 1:48 pm
by iansjack
Yes. The "org" directive doesn't control where the program is loaded. It's information that you are giving the assembler; you are saying "I am going to load the program at this location - bear that in mind when assigning addresses".