First time 16-bit development

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

First time 16-bit development

Post by Jeffrey »

Alright, I have a few questions here.

Question 1:

What is the system state for the x86 platform at the time the MBR is loaded and does the BIOS pass anything to the MBR such as what drive it was loaded from, etc? Also, would there be any purpose to preserve the system state at the time of startup?

Question 2:

In 16-bit real mode, how exactly does the address 0413h point to 0040h:0013h?

Thanks!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Question 1:
DL holds the drive number you can use for bios calls, the rest of the registers are undefined.

Question 2:
RTFM: http://www.intel.com/products/processor/manuals/
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

Post by Jeffrey »

combuster,

As a matter of fact I do own the manuals and am currently at work playing around with a bit of 16-bit code. I was wondering if there was an easy explanation to the behavior of that address mapping that I could easily swallow without having to dive into any resources. You have made me feel like a complete noob with your response. If I wanted to dive into the inner workings of how the address mapping works, I would have waited til I got home to do that, but I was hoping for something a bit more than along the lines of "RTFM". Thanks.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Jeffrey wrote:combuster,

As a matter of fact I do own the manuals and am currently at work playing around with a bit of 16-bit code. I was wondering if there was an easy explanation to the behavior of that address mapping that I could easily swallow without having to dive into any resources. You have made me feel like a complete noob with your response. If I wanted to dive into the inner workings of how the address mapping works, I would have waited til I got home to do that, but I was hoping for something a bit more than along the lines of "RTFM". Thanks.
Well obviously, it has been posted many times here and everywhere that segment * 0x10 + offset = linear address. I don't think either that it is proper to expect us to feed you an answer when you say you are capable of finding out for yourself. That makes me feel like I was asked to do your homework. :(

EDIT: from the board rule to ask smart questions:
7.

When you ask your question, display the fact that you have done these things first; this will help establish that you're not being a lazy sponge and wasting people's time. Better yet, display what you have learned from doing these things. We like answering questions for people who have demonstrated they can learn from the answers.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

Post by Jeffrey »

combuster,

Yes, you are right. It was wrong of me to ask without first consulting the board posts. At first I did take offense to your response, but you were in the right, so I do apologize. Believe me, I see where the frustration can come from being asked the same questions over and over, we have a lot of that over at GovernmentSecurity.org. Thanks for your reply.
User avatar
lollynoob
Member
Member
Posts: 150
Joined: Sun Oct 14, 2007 11:49 am

Post by lollynoob »

You weren't completely in the wrong though; sometimes the manuals are a bit cryptic, especially for a newbie (T M's are F-ing hard to R, if you will). In case you were wondering more about segment:offset addressing, it goes something like this in real mode.

Say you had a value of 0x1000 in your ES register, and a value of 0x2345 in your DI register; ES:DI would point to the linear address 0x12345. The segment value is just left-shifted four bits before the two are added. This effectively gives you a 20-bit address space (plus some actually, if you consider high memory, which is 0xFFFF:0x0010 and above, though you'll need to enable the A20 line to use it).
Post Reply