Board index » delphi » Several PMode questions

Several PMode questions

Hello everyone!

I have some questions concerning BP7 and the protected mode it uses for
the compiled programs.
It would be very kind, if I get replies via email.

1. My 3d-engine is a lot slower in pmode than in rmode. I know, that
this might occur from system-calls (eg. irqs, but I don`t use many) or
some jumps or calls. But is this all? The speed drops by 10% and that is
a lot. Can I avoid this?

2. What is the easiest and safest way to get memory blocks larger than
64K? Just putting several getmem behind another? But I think, they do
not necessarily need to join to a large block...

3. Is there a way to linearely address all ram? Like a desciptor that
points to the start of the physical memory. And how would I have to
access normal variables in the integrated-asm? I don`t want to use so
many segment registers.

4. Has anybody a sound-routine to play wave-files in pmode with source?
Just an easy one short and without fx.

5. How are segment registers handled in pmode under BP? Where do they
point to (integrated asm)? What does the processor do?

Thanx a lot for your effort,
Christian

 

Re:Several PMode questions


Quote
Christian Fleischer wrote:

Can't answer all your questions, but I'll try a couple.

Quote
> Hello everyone!

> I have some questions concerning BP7 and the protected mode it uses for
> the compiled programs.
> It would be very kind, if I get replies via email.

Posted and e-mailed.

Quote
> 1. My 3d-engine is a lot slower in pmode than in rmode. I know, that
> this might occur from system-calls (eg. irqs, but I don`t use many) or
> some jumps or calls. But is this all? The speed drops by 10% and that is
> a lot. Can I avoid this?

I understand port calls are are also a bottle-neck, though that might
not apply.  Have you tried running the code in TPROF to see where the
bottlenecks are, and possibly give some idea of where to optimize?

Quote
> 2. What is the easiest and safest way to get memory blocks larger than
> 64K? Just putting several getmem behind another? But I think, they do
> not necessarily need to join to a large block...

See the Language Guide.  You can access a large block using
GlobalAllocPtr() function to get large blocks of memory.  The manual has
a couple examples of how to apply this.

Quote
> 3. Is there a way to linearely address all ram? Like a desciptor that
> points to the start of the physical memory. And how would I have to
> access normal variables in the integrated-asm? I don`t want to use so
> many segment registers.

Borland's DPMI uses 16-bit protected mode.  I doubt you could get flat
model from it easily, if at all.  TMT does flat-model addressing, and
for TP, there's an extender called "swallow" (look around for
swal101.zip) which I understand can help you make a 32-bit flat-model
program out of a real-mode TP program.

Quote
> [...]
> 5. How are segment registers handled in pmode under BP? Where do they
> point to (integrated asm)? What does the processor do?

I understand the general idea, but don't know all the in-depth details.
Segment registers contain selector values.  A selector is a pointer into
a descriptor table, where each descriptor contains information about
what memory it addresses and access rights to that memory.  Dig around
www.intel.com or www.x86.org and you may turn up some more detailed
documents about how protected mode addressing works.

Quote
> Thanx a lot for your effort,
> Christian

--
Scott Earnest        | We now return you to our regularly |
set...@ix.netcom.com | scheduled chaos and mayhem. . . .  |

Re:Several PMode questions


Quote
Scott Earnest wrote:

> Christian Fleischer wrote:
> > 1. My 3d-engine is a lot slower in pmode than in rmode. I know, that
> > this might occur from system-calls (eg. irqs, but I don`t use many) or
> > some jumps or calls. But is this all? The speed drops by 10% and that is
> > a lot. Can I avoid this?

> I understand port calls are are also a bottle-neck, though that might
> not apply.  Have you tried running the code in TPROF to see where the
> bottlenecks are, and possibly give some idea of where to optimize?

Another reason you program is slower in pmode might be that you load
the segment registers (ES, ...) quite often. This incurs no penalty in
rmode, but in pmode a lot of checks are performed each time a segment
register is loaded (I seem to remember 80 cycles for a segment load).
So minimising these might help recovering your speed.
Note that jumps and calls often cause segment loads, but also data
operations (any pointer operation for instance: in a loop involving
an array pointer, I wouldn't be surprised if the pointer segment is
loaded in each iteration).

Good luck,
Remco

P.S. I assume most of the code involved is in Pascal, otherwise
this seems the wrong group :)
--
_________________________________________________________________
Remco Vietor                            Department of Chemistry
re...@chem.gla.ac.uk                       J. Black Building
                                        University of Glasgow
                                        Glasgow G12 8QQ
                                        U.K.

Re:Several PMode questions


Quote
t...@panix.com wrote:
> Why don't you simply use TMT Pascal?  It is full 32-bit; it runs in
> protested mode, and of course has no 64K limitation.  You can [...]

  ^^^^^^^^^^^^^^

Oh come now, DPMI isn't THAT bad, is it?  :-)  (One of those things I
find irresistable to pass up.)

--
Scott Earnest        | We now return you to our regularly |
set...@ix.netcom.com | scheduled chaos and mayhem. . . .  |

Re:Several PMode questions


Re:Several PMode questions


Try TMT Pascal.  It is 32-bit, and has no 64K limitation.  See
www.tmt.com fro more information and for a free download.

On Tue, 14 Oct 1997 11:21:54 +0200, Christian Fleischer

Quote
<daydr...@cs.tu-berlin.de> wrote:
>Hello everyone!

>I have some questions concerning BP7 and the protected mode it uses for
>the compiled programs.
>It would be very kind, if I get replies via email.

>1. My 3d-engine is a lot slower in pmode than in rmode. I know, that
>this might occur from system-calls (eg. irqs, but I don`t use many) or
>some jumps or calls. But is this all? The speed drops by 10% and that is
>a lot. Can I avoid this?

>2. What is the easiest and safest way to get memory blocks larger than
>64K? Just putting several getmem behind another? But I think, they do
>not necessarily need to join to a large block...

>3. Is there a way to linearely address all ram? Like a desciptor that
>points to the start of the physical memory. And how would I have to
>access normal variables in the integrated-asm? I don`t want to use so
>many segment registers.

>4. Has anybody a sound-routine to play wave-files in pmode with source?
>Just an easy one short and without fx.

>5. How are segment registers handled in pmode under BP? Where do they
>point to (integrated asm)? What does the processor do?

>Thanx a lot for your effort,
>Christian

Re:Several PMode questions


Re:Several PMode questions


Why don't you simply use TMT Pascal?  It is full 32-bit; it runs in
protested mode, and of course has no 64K limitation.  You can download
a free version from www.tmt.com, and if you like it you can register
for a version with IDE and de{*word*81} and the new MMX technology.

On Tue, 14 Oct 1997 11:21:54 +0200, Christian Fleischer

Quote
<daydr...@cs.tu-berlin.de> wrote:
>Hello everyone!

>I have some questions concerning BP7 and the protected mode it uses for
>the compiled programs.
>It would be very kind, if I get replies via email.

>1. My 3d-engine is a lot slower in pmode than in rmode. I know, that
>this might occur from system-calls (eg. irqs, but I don`t use many) or
>some jumps or calls. But is this all? The speed drops by 10% and that is
>a lot. Can I avoid this?

>2. What is the easiest and safest way to get memory blocks larger than
>64K? Just putting several getmem behind another? But I think, they do
>not necessarily need to join to a large block...

>3. Is there a way to linearely address all ram? Like a desciptor that
>points to the start of the physical memory. And how would I have to
>access normal variables in the integrated-asm? I don`t want to use so
>many segment registers.

>4. Has anybody a sound-routine to play wave-files in pmode with source?
>Just an easy one short and without fx.

>5. How are segment registers handled in pmode under BP? Where do they
>point to (integrated asm)? What does the processor do?

>Thanx a lot for your effort,
>Christian

Other Threads