Board index » delphi » Modes in Pascal

Modes in Pascal

I was wondering which mode should I use - real or protected.
What are the difference,advatages and the disadvantages ?

P.S. I want to add a "Glosary of therms" to my home page and hope it'll
grow soon and fast
        ...so if you're interested to help me please send the therms
that you know (directly!) in
        the following order:
        (example)
        therm               |                stands for
|                purpouse
---------------------+-------------------------------+-----------------------------------------------

        CPU                 |    Central Processing Unit        |    The
"brain of the computer, the part of the

|                                               |     computer composed
of electrical circuitry

|                                               |     directing most of
the computer system's

|                                               |     activities

 

Re:Modes in Pascal


Peter Moraliyski  (huibm...@ibm.net) wrote:

Quote
>I was wondering which mode should I use - real or protected.
>What are the difference,advatages and the disadvantages ?

Hi,
your message was wonderful: filled with tons of "&nbsp"...
Real mode programs are smaller and they require no additional support,
protected mode apps need a loader+extender (rtm.exe) but they can use extended
memory, not only 1M (640K...) and the direct DOS memory access is harder.

Borland said, their protected mode compilers work faster. Maybe this applies
to other DPMI stuff, too.

Re:Modes in Pascal


JRS:  In article <34B3D77F.4164A...@ibm.net> of Wed, 7 Jan 1998 14:29:05
in comp.lang.pascal.borland, Peter Moraliyski <huibm...@ibm.net> wrote:

Quote
>I was wondering which mode should I use - real or protected.
>What are the difference,advatages and the disadvantages ?

>P.S. I want to add a "Glosary of therms" to my home page and hope it'll
>grow soon and fast
>        ...so if you're interested to help me please send the therms
>that you know (directly!) in

Posting in duplicate (in header : Content-Type: multipart/alternative;)
is IMHO pointless, annoying, and against charter; you can easily turn it
off, AIUI.

This group is read by a large number of foreigners.  IMHO it would help
them (apart from the Finns & Dutch, who do not need such help) if you
could take "Spelling 001".  For example, "therms" are units of heat, as
can be seen in larger Websters; so a mere spelling-checker would not
necessarily suffice, although it should pick up "Glosary".

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Don't Mail News. Y2k for beginners http://www.merlyn.demon.co.uk/year2000.txt
  My list of Critical Dates is : http://www.merlyn.demon.co.uk/misctime.htm#CDs
  Web <URL: http://www.merlyn.demon.co.uk/> -- includes FAQqish topics & links.

Re:Modes in Pascal


Quote
In article <68v8rq$i1...@gentiana.datanet.hu>, BandiT <apa...@mol.hu> wrote:
>Peter Moraliyski  (huibm...@ibm.net) wrote:

>>I was wondering which mode should I use - real or protected.
>>What are the difference,advatages and the disadvantages ?

>Hi,
>your message was wonderful: filled with tons of "&nbsp"...
>Real mode programs are smaller and they require no additional support,
>protected mode apps need a loader+extender (rtm.exe) but they can use extended
>memory, not only 1M (640K...) and the direct DOS memory access is harder.

>Borland said, their protected mode compilers work faster. Maybe this applies
>to other DPMI stuff, too.

Do not assume. Protected mode is per se slower as loading pointers
takes much longer. However, when the extra memory it allows becomes an
issue then it is faster than solutions using XMS or disk. One thing in
which DPMI is clearly slower is starting up.

IMO one should use Real mode unless memory is an issue. However, one
should write in such a way that converting to DPMI is easy (like just
recompiling). Of course one can make two versions like Borland did with
TP and TPX (In Turbo Pascal only)

Osmo

Re:Modes in Pascal


In article: <68vl4u$...@kruuna.Helsinki.FI>  ronka...@cc.helsinki.fi (Osmo

Quote
Ronkanen) writes:

>In article <68v8rq$i1...@gentiana.datanet.hu>, BandiT <apa...@mol.hu> wrote:
>>Peter Moraliyski  (huibm...@ibm.net) wrote:

[...]

Quote
>>Borland said, their protected mode compilers work faster. Maybe this applies
>>to other DPMI stuff, too.

>Do not assume. Protected mode is per se slower as loading pointers
>takes much longer.

This is only true on 286 and 386 processors.  processors. According to my TASM
quick reference guide, a LDS/LES/LFS/LGS instruction on a 486 (and presumably
above) takes the same time (6 or 12 cycles, depending on operand) in both real
and protected mode. Loading pointers is slower on 286's (7~ vs 21~) and 386's
(7~ vs 22~).

Quote
> However, when the extra memory it allows becomes an
>issue then it is faster than solutions using XMS or disk.

Yes. There is also the overlay issue, which often slows down large real mode
programs considerably. Sometimes the extra memory available to protected mode
apps can improve performance very considerably.

Quote
> One thing in which DPMI is clearly slower is starting up.

Yes. The RTM.EXE DLL has to be loaded and initialized, and the DPMI16BI.OVL DPMI
server as well if there is no DPMI server presently loaded on the host system.

Quote
>IMO one should use Real mode unless memory is an issue. However, one
>should write in such a way that converting to DPMI is easy (like just
>recompiling). Of course one can make two versions like Borland did with
>TP and TPX (In Turbo Pascal only)

Yes, real mode is just fine for small apps that don't use much memory, but I
would still develop a DPMI version for debugging purposes, as protected mode is
much better at finding those obscure bugs that often go unnoticed in real mode.

-- Jay

 --------------------------------------------------------------------------
| Jason Burgon - author of Graphic Vision, TV-Like GUI for 256 Colour SVGA |
| g...@jayman.demon.co.uk   ftp://SimTel/msdos/turbopas/gv4svga1.zip         |
| ***NEW VERSION OF GV AVAILABLE FROM*** -> http://www.jayman.demon.co.uk  |
 --------------------------------------------------------------------------

Re:Modes in Pascal


In article <83753747...@jayman.demon.co.uk>,
Jason Burgon  <Ja...@jayman.demon.co.uk> wrote:

Quote
>In article: <68vl4u$...@kruuna.Helsinki.FI>  ronka...@cc.helsinki.fi (Osmo
>Ronkanen) writes:

>>Do not assume. Protected mode is per se slower as loading pointers
>>takes much longer.

>This is only true on 286 and 386 processors.  processors. According to my TASM
>quick reference guide, a LDS/LES/LFS/LGS instruction on a 486 (and presumably
>above) takes the same time (6 or 12 cycles, depending on operand) in both real
>and protected mode. Loading pointers is slower on 286's (7~ vs 21~) and 386's
>(7~ vs 22~).

What do you mean with "depending on operand"? LES only takes memory and
calculating EA takes constant time. Moving to segment register (like MOV
ES,AX) takes 3 on real and 9 on protected mode according to my source
(an opcode list I downloaded). That is 6 cycle overhead in PM. Are you
sure that it is not 6 in RM and 12 in PM? (my source is silent on LES
etc. ln PM).

Common sense says that there must be overhead. When one changes segment
register in protected mode the processor has to load the data on segment
limits and access rights. Unless there is some kind of caching for the
data then there must be overhead.
...

Quote

>>IMO one should use Real mode unless memory is an issue. However, one
>>should write in such a way that converting to DPMI is easy (like just
>>recompiling). Of course one can make two versions like Borland did with
>>TP and TPX (In Turbo Pascal only)

>Yes, real mode is just fine for small apps that don't use much memory, but I
>would still develop a DPMI version for debugging purposes, as protected mode is
>much better at finding those obscure bugs that often go unnoticed in real mode.

True. Of course with careful programming there is no need to develop any
protected mode version. One can just compile one.

Osmo

Re:Modes in Pascal


Quote
Jason Burgon wrote:

[...]

Quote
> Yes, real mode is just fine for small apps that don't use much memory, but I
> would still develop a DPMI version for debugging purposes, as protected mode is
> much better at finding those obscure bugs that often go unnoticed in real mode.

> Jay

Hi Jay,

Can you give us more information on all these obscure bugs, and how PMode
is better at finding them?

This would be an excellent time to start a thread on system debugging and
learn how the experts do it!

I am forever trying to move a 255-character string into a string[80] :)

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.csolve.net/~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.csolve.net/~add/zips/tcp.htm

Re:Modes in Pascal


Quote
Jason Burgon wrote:

[...]

Quote
> Yes. There is also the overlay issue, which often slows down large real mode
> programs considerably. Sometimes the extra memory available to protected mode
> apps can improve performance very considerably.

[...]

I find no difficulties writing "large" programs with overlays.

First, you learn how to write compact code. This skill helps in many ways
besides allowing you to do more with less. Since you don't have so much
source to wade through, it is easier to see what you are doing and to
modify or troubleshoot your code.

Second, keep all the activity for critical code in the same unit. Once it
is loaded, there is no need to swap. Of course, you put some common items
in a base unit that is not overlayed and is always available.

Third, use OVERXMS to put the overlay in XMS ram. Retrieving it is faster
than hard disk, and you don't have the problem with SmartDrive demoting
your overlay and replacing it with more recent files.

Fourth, get Duncan Murdoch's software to view your TPU's, and Turbo Power
PSA (Program Structure Analysis) so you can analyse variable usage and
track the size of your variables and routines. You will soon learn what
methods eat memory, and different ways to shrink your software. This will
make it load and run faster.

If you are addressing large amounts of data, you can use 32-bit Flat Real
mode.

It is amasing how much you can do with very little code. To me, a routine
that takes over 1k is huge!

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.csolve.net/~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.csolve.net/~add/zips/tcp.htm

Re:Modes in Pascal


Quote
In article <34B9DB8E.6...@isinurl.net>, Mike  <a...@isinurl.net> wrote:
>Jason Burgon wrote:

>[...]

>> Yes, real mode is just fine for small apps that don't use much memory, but I
>> would still develop a DPMI version for debugging purposes, as protected mode is
>> much better at finding those obscure bugs that often go unnoticed in real mode.

>> Jay

>Hi Jay,

>Can you give us more information on all these obscure bugs, and how PMode
>is better at finding them?

If the program uses bad pointer to reference data then in protected mode
runtime error 216 will be issued.

Osmo

Re:Modes in Pascal


Quote
Jason Burgon wrote:

> In article: <68vl4u$...@kruuna.Helsinki.FI>  ronka...@cc.helsinki.fi (Osmo
> Ronkanen) writes:

> >In article <68v8rq$i1...@gentiana.datanet.hu>, BandiT <apa...@mol.hu> wrote:
> >>Peter Moraliyski  (huibm...@ibm.net) wrote:

> [...]

> >>Borland said, their protected mode compilers work faster. Maybe this applies
> >>to other DPMI stuff, too.

> >Do not assume. Protected mode is per se slower as loading pointers
> >takes much longer.

> This is only true on 286 and 386 processors.  processors. According to my TASM
> quick reference guide, a LDS/LES/LFS/LGS instruction on a 486 (and presumably
> above) takes the same time (6 or 12 cycles, depending on operand) in both real
> and protected mode. Loading pointers is slower on 286's (7~ vs 21~) and 386's
> (7~ vs 22~).

> > However, when the extra memory it allows becomes an
> >issue then it is faster than solutions using XMS or disk.

> Yes. There is also the overlay issue, which often slows down large real mode
> programs considerably. Sometimes the extra memory available to protected mode
> apps can improve performance very considerably.

> > One thing in which DPMI is clearly slower is starting up.

> Yes. The RTM.EXE DLL has to be loaded and initialized, and the DPMI16BI.OVL DPMI
> server as well if there is no DPMI server presently loaded on the host system.

> >IMO one should use Real mode unless memory is an issue. However, one
> >should write in such a way that converting to DPMI is easy (like just
> >recompiling). Of course one can make two versions like Borland did with
> >TP and TPX (In Turbo Pascal only)

> Yes, real mode is just fine for small apps that don't use much memory, but I
> would still develop a DPMI version for debugging purposes, as protected mode is
> much better at finding those obscure bugs that often go unnoticed in real mode.

> -- Jay

>  --------------------------------------------------------------------------
> | Jason Burgon - author of Graphic Vision, TV-Like GUI for 256 Colour SVGA |
> | g...@jayman.demon.co.uk   ftp://SimTel/msdos/turbopas/gv4svga1.zip         |
> | ***NEW VERSION OF GV AVAILABLE FROM*** -> http://www.jayman.demon.co.uk  |
>  --------------------------------------------------------------------------

//,
//, Some other question do NEVER AGAIN  let me sleep
//, good. Which "Porsche" is faster? The red or blue
//, one?
//,
//, And by the way why should be protected mode
//, in any way can be running faster with using
//, an NOT LINEAR addressing......
//, Hahahahahahahaha.
//,
//, Really down level questions......
//, M.Z.
//,      (PS: there is NO reply expected)
//,

Re:Modes in Pascal


In article: <34BA09C5.1...@isinurl.net>  Mike <a...@isinurl.net> writes:

Quote

>Jason Burgon wrote:

>[...]

>> Yes. There is also the overlay issue, which often slows down large real mode
>> programs considerably. Sometimes the extra memory available to protected mode
>> apps can improve performance very considerably.

>[...]

>I find no difficulties writing "large" programs with overlays.

>First, you learn how to write compact code. This skill helps in many ways
>besides allowing you to do more with less. Since you don't have so much
>source to wade through, it is easier to see what you are doing and to
>modify or troubleshoot your code.

I agree 100%, but sometimes 640k (or rather the ~600K DOS memory typically
available) just aint enough for code and data, so something has to give.

Quote
>Second, keep all the activity for critical code in the same unit.

The problem with this is that it often lumps code together for the wrong reason.
It would have been nice in BP7 could group code from several units into the same
real-mode code segment, like it can for the same PM code segment.

Quote
> Once it
>is loaded, there is no need to swap. Of course, you put some common items
>in a base unit that is not overlayed and is always available.

>Third, use OVERXMS to put the overlay in XMS ram. Retrieving it is faster
>than hard disk, and you don't have the problem with SmartDrive demoting
>your overlay and replacing it with more recent files.

Yes I had a big session with overlays, XMS and all that stuff a couple of years
ago, and yes, it can help a lot. It's still not as fast as PM though, and
setting the size of overlay buffer and probation area to the optimum size on any
given host machine is tricky.

Quote
>Fourth, get Duncan Murdoch's software to view your TPU's,

TPP's :-))

Quote
>and Turbo Power
>PSA (Program Structure Analysis) so you can analyse variable usage and
>track the size of your variables and routines. You will soon learn what
>methods eat memory, and different ways to shrink your software. This will
>make it load and run faster.

I haven't tried this one. How much wonka are we talking here?

Quote
>If you are addressing large amounts of data, you can use 32-bit Flat Real
>mode.

Only if you don't want your app to run on (almost) anyone else's machine.

Quote
>It is amasing how much you can do with very little code. To me, a routine
>that takes over 1k is huge!

Me too. I come from a background of programming in 6809 assembler, where a 1K
~program~ was fairly big. :-)

-- Jay

 --------------------------------------------------------------------------
| Jason Burgon - author of Graphic Vision, TV-Like GUI for 256 Colour SVGA |
| g...@jayman.demon.co.uk   ftp://SimTel/msdos/turbopas/gv4svga1.zip         |
| ***NEW VERSION OF GV AVAILABLE FROM*** -> http://www.jayman.demon.co.uk  |
 --------------------------------------------------------------------------

Re:Modes in Pascal


In article: <69b4ed$...@kruuna.Helsinki.FI>  ronka...@cc.helsinki.fi (Osmo

Quote
Ronkanen) writes:

>In article <83753747...@jayman.demon.co.uk>,
>Jason Burgon  <Ja...@jayman.demon.co.uk> wrote:

>>According to my TASM quick reference guide, a LDS/LES/LFS/LGS instruction
>>on a 486 (and presumably above) takes the same time (6 or 12 cycles,
>>depending on operand) in both real and protected mode. Loading pointers is
>>slower on 286's (7~ vs 21~) and 386's (7~ vs 22~).

>What do you mean with "depending on operand"? LES only takes memory and
>calculating EA takes constant time.

I think it means you can have something like "LES DI,[BX]" as well as "LES
DI,[SomeAddress]. The exact entry from the TASM Quick Ref for LDS is as follows:

Opcode Instruction    486  386     286     86    Description
C5 /r  LDS r16,m16:16 6/12 7,pm=22 7,pm=21 16+EA Load DS:r16 with ptr from mem

Note that the 486 entry uses the normal "register/memory" operand timing
notation, whereas the 386 and 286 entries use the RealMode,ProtectedMode="
notation. This could be a typo, but it's a rather blatent one if it is.

Quote
> Moving to segment register (like MOV
>ES,AX) takes 3 on real and 9 on protected mode according to my source
>(an opcode list I downloaded). That is 6 cycle overhead in PM.

Yes this is what my (self-amended) entry in my TASM QR says as well. This
operation is used rarely though. ie it will be a very small percentage of
program time used doing this.

Quote
>Are you
>sure that it is not 6 in RM and 12 in PM? (my source is silent on LES
>etc. ln PM).

No, I can't put my hand on my heart and say I'm (or Borland's reference to be
more precise) correct. It could be a typo.

Quote
>Common sense says that there must be overhead. When one changes segment
>register in protected mode the processor has to load the data on segment
>limits and access rights. Unless there is some kind of caching for the
>data then there must be overhead.

I would agree, but common sense and Intel processors are uncomfortable bed
fellows. :-)

Even if all segment loads are slower in PM, this can be offset (at least in
large apps) by the fact that you don't need to use overlays, which means you
don't have to force far calls. A near call/return is much faster than a far call
(3 or 5 compared to rm=18,pm=20 on a 486).

The only slowdown I've perceived is when a PM application is repeatedly calling
the underlying DOS/BIOS via the DPMI. Calling DOS/BIOS functions is of course
much slower in protected mode. Again though, this slowdown is not percievable in
many applications because of the relatively low number of DOS/BIOS calls made by
the program.

-- Jay

 --------------------------------------------------------------------------
| Jason Burgon - author of Graphic Vision, TV-Like GUI for 256 Colour SVGA |
| g...@jayman.demon.co.uk   ftp://SimTel/msdos/turbopas/gv4svga1.zip         |
| ***NEW VERSION OF GV AVAILABLE FROM*** -> http://www.jayman.demon.co.uk  |
 --------------------------------------------------------------------------

Re:Modes in Pascal


In article: <34B9DB8E.6...@isinurl.net>  Mike <a...@isinurl.net> writes:

Quote

>Jason Burgon wrote:

>[...]

>> Yes, real mode is just fine for small apps that don't use much memory, but I
>> would still develop a DPMI version for debugging purposes, as protected mode
>> is much better at finding those obscure bugs that often go unnoticed in real
>> mode.

>> Jay

>Hi Jay,

>Can you give us more information on all these obscure bugs, and how PMode
>is better at finding them?

Protected mode means that there are hardware checks on memory accesses. You
can't write to a code segment for example. Also, each data segment is given
access rights and segment limits, so trying to write past a segment limit will
cause a GPF (General Protection Fault). This also includes the stack segment, so
stack over/underflow will also be detected.

PM does help much with Turbo Pascal global data because it's all lumped together
in one segment, so writing a word value to a byte variable for example won't get
detected if the variable is declared as a global "var" or typed constant, but if
it's heap memory, then PM can be used to detect the fault because of its
inbuilt bounds-checking.

Tech note 1
===========

The above is only guaranteed to work if your PM application sets the
System.HeapLimit variable to 0. This means each heap memory allocation is
assigned its own selector, with a limit the same size as the memory requested.
HeapLimit sets the size of BP's sub-allocation block size, and is set to 8192 by
default. This means the memory manager requests 8K memory blocks from the DPMI
server, then sub-allocates small application memory requests from these 8k
allocations. This makes for faster memory allocations, but negates the benefit
of PM to a large extent (as does the "flat" memory model now in common use by
32-bit compilers). Therefore HeapLimit should normally only be set to 0 for
debigging purposes.

Tech note 2
===========

BP can only allocate about 2000 data selectors. Any more than this and it
crashes! It's quite easy therefore to run out of selectors when your application
has set HeapLimit to zero, since a new selector is allocated for every heap
memory allocation (including creating objects with "New").

Quote
>This would be an excellent time to start a thread on system debugging and
>learn how the experts do it!

Real experts never write buggy code, so that rules me out of that catagory! ;-)

Quote

>I am forever trying to move a 255-character string into a string[80] :)

:-)). PM would detect the fault if your 80 character string is heap memory
allocated and you have set HeapLimit to 0 at the start of your program.

-- Jay

 --------------------------------------------------------------------------
| Jason Burgon - author of Graphic Vision, TV-Like GUI for 256 Colour SVGA |
| g...@jayman.demon.co.uk   ftp://SimTel/msdos/turbopas/gv4svga1.zip         |
| ***NEW VERSION OF GV AVAILABLE FROM*** -> http://www.jayman.demon.co.uk  |
 --------------------------------------------------------------------------

Re:Modes in Pascal


In article <758616417...@jayman.demon.co.uk>,
Jason Burgon  <Ja...@jayman.demon.co.uk> wrote:

Quote
>In article: <69b4ed$...@kruuna.Helsinki.FI>  ronka...@cc.helsinki.fi (Osmo
>Ronkanen) writes:

>>In article <83753747...@jayman.demon.co.uk>,
>>Jason Burgon  <Ja...@jayman.demon.co.uk> wrote:

>>>According to my TASM quick reference guide, a LDS/LES/LFS/LGS instruction
>>>on a 486 (and presumably above) takes the same time (6 or 12 cycles,
>>>depending on operand) in both real and protected mode. Loading pointers is
>>>slower on 286's (7~ vs 21~) and 386's (7~ vs 22~).

>>What do you mean with "depending on operand"? LES only takes memory and
>>calculating EA takes constant time.

>I think it means you can have something like "LES DI,[BX]" as well as "LES
>DI,[SomeAddress]. The exact entry from the TASM Quick Ref for LDS is as follows:

Yes, and that is just calculating of the effective address. It has taken
constant time since 286. See other instructions that do not access
segment registers, do they have different timings. If not then think. Then
think, then think, and finally think.

Quote

>Opcode Instruction    486  386     286     86    Description
>C5 /r  LDS r16,m16:16 6/12 7,pm=22 7,pm=21 16+EA Load DS:r16 with ptr from mem

That EA is just what you described above: EA was as follows:

direct memory address, 6 cycles
DI+disp etc.           9 cycles
DI+disp etc.           5 cycles
BP+DI, BX+SI           7 cycles
BP+SI, BX+DI           8 cycles
BP+DI+disp BX+SI+disp 11 cycles
BP+SI+disp BX+DI+disp 12 cycles

This all for for 8086/88 only.

Quote

>Note that the 486 entry uses the normal "register/memory" operand timing
>notation, whereas the 386 and 286 entries use the RealMode,ProtectedMode="
>notation. This could be a typo, but it's a rather blatent one if it is.

So what. They first printed the book without 486 for version 6.0. Then
when they edited it for version 7.0 they just used different format for
some reason. Maybe they thought that everyone would anyway get that
it is realmode/protected mode as it could rationally mean nothing
else. Note that LES DI,xxx always takes memory as source, not register
so it cannot mean the register/memory format.

Quote

>> Moving to segment register (like MOV
>>ES,AX) takes 3 on real and 9 on protected mode according to my source
>>(an opcode list I downloaded). That is 6 cycle overhead in PM.

>Yes this is what my (self-amended) entry in my TASM QR says as well. This
>operation is used rarely though. ie it will be a very small percentage of
>program time used doing this.

How so?  It could be used very often. All depends on the program.

Quote

>>Are you
>>sure that it is not 6 in RM and 12 in PM? (my source is silent on LES
>>etc. ln PM).

>No, I can't put my hand on my heart and say I'm (or Borland's reference to be
>more precise) correct. It could be a typo.

>>Common sense says that there must be overhead. When one changes segment
>>register in protected mode the processor has to load the data on segment
>>limits and access rights. Unless there is some kind of caching for the
>>data then there must be overhead.

>I would agree, but common sense and Intel processors are uncomfortable bed
>fellows. :-)

Do you mean to imply that Intel does something magical like loading data
from memory in zero time. Do they use alien technology for that :-)

Quote

>Even if all segment loads are slower in PM, this can be offset (at least in
>large apps) by the fact that you don't need to use overlays, which means you
>don't have to force far calls. A near call/return is much faster than a far call
>(3 or 5 compared to rm=18,pm=20 on a 486).

Of course it is more than offset. But one does not always use the
program to handle large data, so the protected mode can still be slower
in some cases. Therefore it is good to provide also real mode version.

Yes, far call is slower but BP ties to avoid it as much as possible.
When possible it codes far call as PUSH CS and Near call.

Quote

>The only slowdown I've perceived is when a PM application is repeatedly calling
>the underlying DOS/BIOS via the DPMI. Calling DOS/BIOS functions is of course
>much slower in protected mode. Again though, this slowdown is not percievable in
>many applications because of the relatively low number of DOS/BIOS calls made by
>the program.

Try some pointer intensive code.

Osmo

Re:Modes in Pascal


In article <622121107...@jayman.demon.co.uk>,
Jason Burgon  <Ja...@jayman.demon.co.uk> wrote:

Quote

>Tech note 1
>===========

>The above is only guaranteed to work if your PM application sets the
>System.HeapLimit variable to 0. This means each heap memory allocation is
>assigned its own selector, with a limit the same size as the memory requested.
>HeapLimit sets the size of BP's sub-allocation block size, and is set to 8192 by
>default. This means the memory manager requests 8K memory blocks from the DPMI
>server, then sub-allocates small application memory requests from these 8k
>allocations. This makes for faster memory allocations, but negates the benefit
>of PM to a large extent (as does the "flat" memory model now in common use by
>32-bit compilers). Therefore HeapLimit should normally only be set to 0 for
>debigging purposes.

Not only faster, it also allows more memory to be allocated. Without
the sub-allocator one would soon run out of selectors. The sub-allocator
is the way to do small blocks. Actually heaplimit just states the threshold
between small and large blocks. Heapblock sets the size of block
allocated by the sub-allocator. It should be at minimum 4 times the
heaplimit, so by default 32K.

Quote
>Tech note 2
>===========

>BP can only allocate about 2000 data selectors. Any more than this and it
>crashes! It's quite easy therefore to run out of selectors when your application
>has set HeapLimit to zero, since a new selector is allocated for every heap
>memory allocation (including creating objects with "New").

Maybe I should have read this before writing.

Osmo

Go to page: [1] [2]

Other Threads