Re: doubt in protected mode
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Wed, 22 Nov 2006 16:13:26 -0500
OS wrote:
Hi all,
Hi Dharma - if you're using "OS" as a handle, what's your OS called, "OSOS"??? :)
SpooK has given you a pretty good answer to this, but I'll try a slightly different "approach"...
I have doubt about the memory manager.
Memory manager??? If you're doing what I think, the "memory manager" is up to you!
When i compile any asm
program,
As SpooK points out, "compile" is a dirty word to some people. If there's a linker involved, it's more than "assemble" that's happening. I like "build" as a fairly neutral word...
it generates
the map file
Is the map file coming from the assembler or the linker? Usually, it's the linker's job, I think. Nasm's "-f bin" mode will generate a map file, too, though... It might be helpful if you'd specify which tools you're using, since they differ quite a bit. (normally we'd want to know "what OS?", too, but I assume that's "in progress")
which will contain information about the code segment
,data segment.
While the segmented memory addressing scheme is "real" (who'd make up something so ugly?), "code segment" and "data segment" is somewhat of an "abstraction", known only to the assembler/linker - at the "machine level" it's all just bytes.
There's a subtle distinction you'll need to understand between "16/32-bit code", and having the CPU in "16/32-bit mode". The former is what you tell the assembler to do. The latter is determined by a bit in the cs descriptor. You want 'em to match!!!
when i execute
the program, it will copy the code and data to some location in memory
Right. But the copy routine doesn't know or care if it's code or data, or what "bitness" it is - it's "just bytes". The copy knows "from where, to where, how many?" ("from" or "to" may be reachable - easily - only in pmode...)
. Now iam jumping to protected mode .
Okay. Let's ASSume you mean 32-bit protected mode. 16-bit protected mode exists - you'll want to switch to 16-bit pmode before switching back to rmode, if you want to do that. Otherwise you can probably ignore it.
1) if the base address for code and data segment is zero and paging is
disabled , which part of memory will the code and data will be copied
Since you say "base", I assume you *do* know how pmode selectors work - if not, SpooK has straightened you out. It'll copy from/to where you say - if the "base" is zero, from offset to offset (probably esi to edi). But... big *BUT*... is your a20 gate enabled? If not, memory intended to access odd megabyte addresses will access even megabytes. This will screw you up!!! May not be an issue... yet.
If paging is not enabled, a "logical" or "linear" address is the same as the "physical" address - segreg * 16 + offset in rmode, segreg.base + offset in pmode - big difference!
2) will the content of the data segment in the real mode, copied to the
data segment in the
protected or how to know whether the content of code and data segment
belongs to real or
protected mode,
What mode is the CPU in when it encounters it?
If you've told the assembler "bits 16" (or per your assembler's syntax), it isn't going to change to 32-bit code by copying it someplace else. Data is less fussy.
3) which part of code segment and data segment will be copied in real
mode and
which part of code and data segment will be copied to protected
mode ? when i executed a
asm program
What mode is the CPU in when it executes this copy? What mode is it in when it executes the code you've copied? What "bitness" was the code? That's what counts.
Please help me in this regards, since it is very much important,
Yup!!!
i
tried myself a lot to understand but i didnt find the solution
10 RTFM
20 experiment
30 ask
40 goto 10
You'll probably have to loop for a while before you "get" it all. No single part is that "hard", but there's a lot of it...
Best,
Frank
.
- Follow-Ups:
- Re: doubt in protected mode
- From: SpooK
- Re: doubt in protected mode
- References:
- doubt in protected mode
- From: OS
- doubt in protected mode
- Prev by Date: Re: doubt in protected mode
- Next by Date: Re: doubt in protected mode
- Previous by thread: Re: doubt in protected mode
- Next by thread: Re: doubt in protected mode
- Index(es):
Relevant Pages
|