How are addresses calculated in 32bit real mode?

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
Mahkoe
Posts: 4
Joined: Fri Jun 22, 2012 2:27 pm

How are addresses calculated in 32bit real mode?

Post by Mahkoe »

I've been learning how addresses work, and any information I found (as far as I understand it) talks about two 16 bit registers used as a segment and an offset. It makes sense, but while I was reading an explanation of movsb (since I didn't know what it was when I was signing up) it mentioned that it can use the extended registers. How are addresses calculated with these 32bit registers? And if the 64 bit registers are sometimes used, how are they used?

Thanks
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: How are addresses calculated in 32bit real mode?

Post by Kazinsal »

32-bit real mode is a bit of a kludge of names there. Real mode is inherently 16-bit. However, you can put the processor into protected mode, load your data segments with a 4GB limit, then drop back to real mode. Reload your data segments, and while the base will change, the limit will no longer be 64KB but stay as 4GB. This is known as unreal mode, and I'm going to assume that's what you're talking about.

When in "unreal mode", you can address data via the 32-bit registers. The segment will be shifted four bits to the left and added to the offset as usual, but the offset is now 32 bits wide instead of sixteen, allowing you full access to the 4GB physical address space. So 0x1234:0x56789ABC will be calculated as 0x56789ABC + 0x12340 = 0x5679BDFC.

As for the 64-bit registers, as far as I'm aware, you can't use them at all in real mode. There's no instruction override prefix like there is to allow 32-bit registers to be used in a 16-bit mode.

Any other questions?
Mahkoe
Posts: 4
Joined: Fri Jun 22, 2012 2:27 pm

Re: How are addresses calculated in 32bit real mode?

Post by Mahkoe »

No, that was exactly what I was looking for. Thanks a lot! Oh, actually, I do have a question. How do you mark threads as solved?
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: How are addresses calculated in 32bit real mode?

Post by Kazinsal »

Edit your original post and change the subject line.
Post Reply