Board index » delphi » Very Fast Seg Copiers - CODE

Very Fast Seg Copiers - CODE

Here is my segment copier in its entirety.
optimise if you can ;-)

PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
ASM
 push ds
  mov es,[d]
  mov ds,[s]

  mov di,0
  mov si,0

  mov cx,16000  { Yup 16000 instuctions for a                             64K transfer}
  DB $66; rep movsw

 pop ds
END;

So

Copy_Mem_seg(VirtualScreenName,$A000);
Would draw the contents of the virtualscreen to the VDU
--
Said the spider, "My pretty little tasty thing, you think you will go to
hell?  Whatever makes you hink your alive?"

 

Re:Very Fast Seg Copiers - CODE


Here is my segment copier in its entirety.
optimise if you can ;-)

PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
ASM
 push ds
  mov es,[d]
  mov ds,[s]

  mov di,0
  mov si,0

  mov cx,16000  { Yup 16000 instuctions for a                             64K transfer}
  DB $66; rep movsw

 pop ds
END;

So

Copy_Mem_seg(VirtualScreenName,$A000);
Would draw the contents of the virtualscreen to the VDU
--
Said the spider, "My pretty little tasty thing, you think you will go to
hell?  Whatever makes you hink your alive?"

Re:Very Fast Seg Copiers - CODE


Daylieen Theyalas heeft geschreven in bericht
<01bd55f0$21b58c60$0100007f@daylieen>...

Quote
>Here is my segment copier in its entirety.
>optimise if you can ;-)

>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>ASM
> push ds
>  mov es,[d]
>  mov ds,[s]

>  mov di,0
xor di,di
>  mov si,0
xor si,si

>  mov cx,16000  { Yup 16000 instuctions for a   64K transfer}

It's 64000 bytes, not 64k.
Quote
>  DB $66; rep movsw

> pop ds
>END;

>So

>Copy_Mem_seg(VirtualScreenName,$A000);
>Would draw the contents of the virtualscreen to the VDU
>--
>Said the spider, "My pretty little tasty thing, you think you will go to
>hell?  Whatever makes you hink your alive?"

Re:Very Fast Seg Copiers - CODE


Quote
>> mov di,0
> xor di,di
> >  mov si,0
> xor si,si

Oh well serves me right for being vain.

--
Said the spider, "My pretty little tasty thing, you think you will go to
hell?  Whatever makes you think your alive?"

Re:Very Fast Seg Copiers - CODE


Quote
>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>ASM
> push ds
>  mov es,[d]
>  mov ds,[s]

>  mov di,0
>  mov si,0

>  mov cx,16000  { Yup 16000 instuctions for a   64K transfer}
>  DB $66; rep movsw

With CX set to 16000 you wouldnt use REP MOVSW, that would only copy 16000
words, 32000bytes, youd need to use REP MOVSD.. and its faster to move dword
blocks than it is to move word blocks

Re:Very Fast Seg Copiers - CODE


In article <01bd55f0$21b58c60$0100007f@daylieen>,

Quote
Daylieen Theyalas <l...@coventry.ac.uk> wrote:
>Here is my segment copier in its entirety.
>optimise if you can ;-)

>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>ASM
> push ds
>  mov es,[d]
>  mov ds,[s]

>  mov di,0
>  mov si,0

>  mov cx,16000  { Yup 16000 instuctions for a                                 64K transfer}
>  DB $66; rep movsw

> pop ds
>END;

Your code does not work properly as it assumed that direction flag is
cleared. You need to add "cld".

Osmo

Re:Very Fast Seg Copiers - CODE


In article <898277564.4017.0.nnrp-11.c1edb...@news.demon.co.uk>,

Quote
GoDFaTHeR <godf...@hotmail.com> wrote:
>>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>>ASM
>> push ds
>>  mov es,[d]
>>  mov ds,[s]

>>  mov di,0
>>  mov si,0

>>  mov cx,16000  { Yup 16000 instuctions for a   64K transfer}
>>  DB $66; rep movsw

>With CX set to 16000 you wouldnt use REP MOVSW, that would only copy 16000
>words, 32000bytes, youd need to use REP MOVSD.. and its faster to move dword
>blocks than it is to move word blocks

What do you think the "db $66" means?

Osmo

Re:Very Fast Seg Copiers - CODE


Osmo Ronkanen schrieb:

Quote
> In article <898277564.4017.0.nnrp-11.c1edb...@news.demon.co.uk>,
> GoDFaTHeR <godf...@hotmail.com> wrote:
> >>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
> >>ASM
> >> push ds
> >>  mov es,[d]
> >>  mov ds,[s]

> >>  mov di,0
> >>  mov si,0

> >>  mov cx,16000  { Yup 16000 instuctions for a   64K transfer}
> >>  DB $66; rep movsw

> >With CX set to 16000 you wouldnt use REP MOVSW, that would only copy 16000
> >words, 32000bytes, youd need to use REP MOVSD.. and its faster to move dword
> >blocks than it is to move word blocks

DB 66h;REP MOVSW is identical with REP STOSD

Quote

> What do you think the "db $66" means?

> Osmo

DB 66h; is a prefix: DB 67h too

DB 66h;MOV AX,ES:[DI] -->MOV EAX,ES:[DI]
DB 67h;MOV AX,ES:[DI] -->MOV AX,ES:[EDI]
DB 66h, 67h;MOV AX,ES:[DI] --> MOV EAX,ES:[EDI]
DB 66h;STOSW --> STOSD

Yours, Michael

Re:Very Fast Seg Copiers - CODE


In article <358AB0A3.8C9B...@nol.at>,
Michael Knapp  <michaelkn...@nol.at> wrote:

Quote

>Osmo Ronkanen schrieb:

>> In article <898277564.4017.0.nnrp-11.c1edb...@news.demon.co.uk>,
>> GoDFaTHeR <godf...@hotmail.com> wrote:
>> >>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>> >>ASM
>> >> push ds
>> >>  mov es,[d]
>> >>  mov ds,[s]

>> >>  mov di,0
>> >>  mov si,0

>> >>  mov cx,16000  { Yup 16000 instuctions for a   64K transfer}
>> >>  DB $66; rep movsw

>> >With CX set to 16000 you wouldnt use REP MOVSW, that would only copy 16000
>> >words, 32000bytes, youd need to use REP MOVSD.. and its faster to move dword
>> >blocks than it is to move word blocks

>DB 66h;REP MOVSW is identical with REP STOSD

You completely missed by point.

Quote

>> What do you think the "db $66" means?

>> Osmo

>DB 66h; is a prefix: DB 67h too

>DB 66h;MOV AX,ES:[DI] -->MOV EAX,ES:[DI]
>DB 67h;MOV AX,ES:[DI] -->MOV AX,ES:[EDI]

Actually that is incorrect.

MOV AX,ES:[DI] is coded:  26 8B 05  but MOV AX,ES:[EDI] is coded as 26
67 8B 07. The order of the prefixes is not what matters but the fact
that the addressing mode is specified with 5 in the first and 7 in the
second. What you say would to my knowledge be MOV AX,ES:[Ofs32]. The
addressing modes with 32-bits are different and therefore one cannot
just put the $67 prefix.

In fact if one wanted MOV AX,ES:[EDI] one should do DB $66; MOV
AX,ES:[BX]

Quote
>DB 66h, 67h;MOV AX,ES:[DI] --> MOV EAX,ES:[EDI]

Ditto here.

Quote
>DB 66h;STOSW --> STOSD

>Yours, Michael

Osmo

Re:Very Fast Seg Copiers - CODE


Re:Very Fast Seg Copiers - CODE


Quote
> GoDFaTHeR  wrote:
> With CX set to 16000 you wouldnt use REP MOVSW, that would only copy
16000
> words, 32000bytes, youd need to use REP MOVSD.. and its faster to move
dword
> blocks than it is to move word blocks

I don't think I expressed myself properly. This is working code that will
copy 64000
bytes from one segment to another.  It works in  Real mode and movsd isn't
recognised by the TP7 inline assembler, the key if the db $66; statement
which
(somehow?) causes the following movsw statement copy dwords instead of
ordinary word. So in closing I reiterate the fact that this code works
perfectly and was not posted as a request for help (sorry to those who've
spent time trying to debug it -I'll be clearer in the future), but rather
as piece of information as to the fastest inline TP7/TP6 segment copier
I've been able to come up with.

--
Said the spider, "My pretty little tasty thing, you think you will go to
hell?  Whatever makes you think your alive?"

GoDFaTHeR <godf...@hotmail.com> wrote in article
<898277564.4017.0.nnrp-11.c1edb...@news.demon.co.uk>...

Quote

Re:Very Fast Seg Copiers - CODE


Re:Very Fast Seg Copiers - CODE


In article <01bd55f0$21b58c60$0100007f@daylieen>, Daylieen Theyalas
<l...@coventry.ac.uk> writes

Quote
>Here is my segment copier in its entirety.
>optimise if you can ;-)

>PROCEDURE Copy_Mem_Seg(S,D:WORD);assembler;
>ASM

you are missing
   cld

Quote
>  push ds
>  mov es,[d]
>  mov ds,[s]

>  mov di,0
xor di,di
>  mov si,0
xor si,si

>  mov cx,16000  { Yup 16000 instuctions for a                     64K

transfer}

Not quite 64K - more like 64000 bytes. Use 16384 (decimal)

--
Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Very Fast Seg Copiers - CODE


In article <358AB0A3.8C9B...@nol.at>, Michael Knapp
<michaelkn...@nol.at> writes

Quote

>DB 66h;REP MOVSW is identical with REP STOSD

Actually its identical with REP MOVSD

Your code will copy eax into all the locations *not* move all the bytes.

--
Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Very Fast Seg Copiers - CODE


Go to page: [1] [2] [3]

Other Threads