Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick DEBUG question... DS & ES

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
0
0
US
Ok... I haven't used debug in forever, and not a whole lot when I did ;-)

I just noticed recently noticed you can't use Segments like...

MOV AX,DS:[SI]
MOV ES:[DI],AX


but you can use...
DS:
-and-
ES:
by them selfs...

So to do the above move commands would you say...

DS:
MOV AX,[SI]
ES:
MOV [DI],AX


If so, do you have to switch to es: everytime you want to address from it, or does it stay current until you switch back?

also, what is the default?
SS:
-or-
DS:

Thanks,
-JS-

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
*I'm NOT SURE but I think protected mode started with the 386 (right?) because if you are able to use FS and GS in protected mode... those were not available on the 286...

386 came with 32 bit

286 was still 16 bit

So when you use an assembler such as TASM...

and you include the .386 option in the header, such as...

Code:
.MODEL  medium
Code:
.386
Code:
.CODE
  mov ax,es:[di]
Code:
  mov ax,fs:[di]
  mov ax,gs:[di]
Code:
end

Does this set it to protected mode?

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Protected mode came in with the 286.

What didn't come in with the 286 was a method of returning to real mode once you were in protected mode because (apparently) Intel didn't think that anyone would want to do that. Ha!

So the only way (as far as I know) to go from protected mode to real mode in a 286 was to reset it.

Which made Windoze really slow... even slower than it was anyway (at that time).

The instruction LMSW allows you to enter protected mode.

The FS and GS registers came in with the 386 which explains why you have to set .386 to get MASM or TASM to assemble them at all.

From what I've read in "Advanced Assembly Language Programming" by Allen Wyatt, it's usual to use a DOS extender when programming in protected mode.

This provides a reasonable interface between the protected mode program and the real mode DOS operating system.

Hence the term "DPMI" (Dos Protected Mode Interface).

rgds
Zeit.
 
OK, OK, I'm not really competent to do this, but very, very basically protected mode is the way Intel would have liked to have designed their processors, and real mode was provided for backward compatibility. You can do everything in protected mode that you can in real (assuming your operating system allows you; and that is a big point, protected mode allows the operating system to control application processes, a very important plus point. Not often appreciated by asm application programmers, but do you really want some other application messing up your memory and making yours crash. It's you who ends up looking stupid, not the person who couldn't keep his pointers in range!). And in protected mode you can access all the physical memory there is, directly, and without any fiddling about with EMS/XMS or anything like that.
The main difference is that the segment registers no longer hold a physical address. Instead they hold an index into a table, which contains all the information about that chunk of memory, how large it is, whether it is data or code, etc. In this way, if you try to access memory that has been allocated to someone else's application, the operating system can stop you. Multi-tasking etc. all becomes practical. Hence windows.
Yes, as for the 286 no-way-back thing, it's very true. The trick was to set up an internal timer to wake the processor up, and then tell the processor to stop. When the timer got round to it, it did its job, and the processor woke up in real mode (that being essential for backward compatibility. No point in waking up in protected mode on an old operating system in real mode...)
Protected mode is a whole new kettle of fish for us old dos programmers. Get a good book!
Windows wasn't made slow by the 286 no-way-back problem. The problem was hybrid code that expected the old dos file system and similar bios/basic interrupt stuff to work. All of this was real mode code. It just took a while to get protected mode equivalents for the huge amount of legacy in an operating system with a history as long as dos.
 
And the heros amongst us program Windows in assembler, but that's another story.

rgds
Zeit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top