Data overwrites interrupt table here?

Programming, for all ages and all languages.
Post Reply
bilsch01
Member
Member
Posts: 42
Joined: Sat Dec 19, 2015 10:48 am

Data overwrites interrupt table here?

Post 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.
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Data overwrites interrupt table here?

Post 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?
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Data overwrites interrupt table here?

Post 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.
bilsch01
Member
Member
Posts: 42
Joined: Sat Dec 19, 2015 10:48 am

Re: Data overwrites interrupt table here?

Post 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 !
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: Data overwrites interrupt table here?

Post 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.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Data overwrites interrupt table here?

Post by Roman »

BIOS loads the boot sector at 0x7C00.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Data overwrites interrupt table here?

Post 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".
Post Reply