OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 8:00 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Data overwrites interrupt table here?
PostPosted: Tue Mar 22, 2016 4:31 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Tue Mar 22, 2016 4:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
That code sets SS:SP to 0000:7C00, which is nowhere near 0000:0000.

Why do you think this will overwrite the IVT?


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Tue Mar 22, 2016 5:41 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Tue Mar 22, 2016 12:36 pm 
Offline
Member
Member

Joined: Sat Dec 19, 2015 10:48 am
Posts: 42
I'm not talking about the stack. I mean this data:
Code:
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 !


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Tue Mar 22, 2016 1:08 pm 
Offline
Member
Member

Joined: Fri Jan 30, 2015 4:57 pm
Posts: 215
Location: Germany
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.


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Sat Mar 26, 2016 12:57 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
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


Top
 Profile  
 
 Post subject: Re: Data overwrites interrupt table here?
PostPosted: Sat Mar 26, 2016 1:48 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group