home *** CD-ROM | disk | FTP | other *** search
- ;* ****************************************************** *
- ;* 386MEM.ASM *
- ;* (c) 1993 Holger Suhr & DMV *
- ;* ****************************************************** *
-
- ;* ****************************************************** *
- ;* Die nachfolgenden Funktionen erlauben das Kopieren *
- ;* und Füllen von Speicherflächen mit Unterstützung der *
- ;* 386-Funktionen REP MOVSD bzw. REP STOSD, die *
- ;* bei gleichem Zeitbedarf jeweils 4 Byte *
- ;* kopieren/füllen *
- ;* Vorausgesetzt wird, daß die Speicherflaeche auf *
- ;* 4-Byte-Boundary ausgelegt ist, da nur dann der volle *
- ;* Geschwindigkeitsgewinn zum Tragen kommt *
- ;* *
- ;* Eben aus diesem Grund werden ungerade Bytes und *
- ;* ungerade Worte zuletzt kopiert/gefüllt *
- ;* ****************************************************** *
-
- ; Standard Turbo-C include-file
- ; erlaubt die Beschreibung von Sourcen, die über alle
- ; Speichermodelle gültig sind
-
- INCLUDE RULES.ASI
-
- PLUS = 0
-
- IF LPROG
- ; bei LARGE-Code-Modellen liegt der erste Parameter
- ; 2 byte tiefer auf dem Stack, da das Code-Segment
- ; beim call gesichert wird.
-
- PLUS = 2
- ENDIF
-
-
- ExtSym@ _cpu386,WORD,__CDECL__
-
- CSeg@
-
-
- ;* ******************************************************* *
- ;* void hswap(void *DEST,void *SRCE,int anz) *
- ;* *
- ;* copy BYTE array to BYTE array *
- ;* *
- ;* ******************************************************* *
-
- PubProc@ hswap,__CDECL__
-
- push bp
- mov bp,sp
- push si
- push di
- push ds ; ds wird evtl. verändert
-
- IF LDATA
- ; bei LARGE-Data Modellen werden 4-Byte-Pointer übergeben
-
- les di,dword ptr [bp+4+PLUS] ; destination
- lds si,dword ptr [bp+8+PLUS] ; source
- mov cx,word ptr [bp+12+PLUS] ; anzahl bytes
- ELSE
- push ds ; in NEAR-Data-Modellen liegen
- pop es ; Source und Destination im DS
- mov di,word ptr [bp+4+PLUS] ; destination
- mov si,word ptr [bp+6+PLUS] ; source
- mov cx,word ptr [bp+8+PLUS] ; anzahl bytes
- ENDIF
-
- jcxz wcop5 ; nichts zu tun ??
- shr cx,1 ; bytes /2 == worte
- pushf ; ungerade bytes ? im carryflag
-
- wcop0:
- jcxz wcop4 ; keine worte ? dann carrytest1
- test __cpu386,1 ; 386-er vorhanden ?
- jz wcop2 ; leider nicht
-
- .386
- shr cx,1 ; worte /2 == dwords
- pushf ; ungerade words ? im carryflag
-
- wcop1:
- jcxz wcop3 ; keine dwords, dann carrytest2
- rep movsd ; copy dwords
-
- jmp short wcop3 ; carrytest2
-
- .8086
-
- wcop2:
- rep movsw ; copy words
- jmp short wcop4 ; carrytest1
-
- wcop3:
- popf ; carry == ungerade words ?
- jnc wcop4 ; nein, dann nicht..
- movsw ; ja, wird kopiert
-
- wcop4:
- popf ; carry == ungerade bytes ?
- jnc wcop5 ; nein, dann nicht..
- movsb ; ja, wird kopiert1
-
- wcop5: ; und tschüß...
- pop ds
- pop di
- pop si
- pop bp
- ret
-
- EndProc@ hswap,__CDECL__
-
- ;* ******************************************************* *
- ;* void meminit(void *buf,int anz,unsigned char wert) *
- ;* *
- ;* füllen einer Fläche mit Bytes *
- ;* ******************************************************* *
-
- PubProc@ meminit,__CDECL__
-
- push bp
- mov bp,sp
- push si
- push di
-
- IF LDATA
- ; bei LARGE-Data-Modellen werden 4-Byte-Pointer übergeben
- les di,dword ptr [bp+4+PLUS]
- mov cx,word ptr [bp+8+PLUS]
- mov al,byte ptr [bp+10+PLUS]
- ELSE
- ;bei SMALL-Data Modellen sind beide Pointer im DS
- push ds
- pop es
- mov di,word ptr [bp+4+PLUS]
- mov cx,word ptr [bp+6+PLUS]
- mov al,byte ptr [bp+8+PLUS]
- ENDIF
-
- cld
- jcxz bfil6 ; nichts zu tun ??
- mov ah,al ; Füllbyte wird Füllwort
- shr cx,1 ; Bytes /2 = worte
- pushf ; ungerade bytes ? im carryflag
-
- bfil1:
- jcxz bfil5 ; keine worte ? dann carrytest1
- test __cpu386,1 ; 386-er vorhanden ?
- jz bfil3 ; leider nicht
-
- .386
- push ax ; füllwort
- shl eax,16 ; nach oben schieben
- pop ax ; und nach unten = füll-dword
- shr cx,1 ; worte /2 == dwords
- pushf ; ungerade worte ? im carryflag
-
- bfil2:
- jcxz bfil4 ; keine dwords, dann carrytest2
- rep stosd ; copy dwords
-
- jmp short bfil4 ; carrytest2
-
- .8086
-
- bfil3:
- rep stosw ; copy words
- jmp short bfil5 ; carrytest1
-
- bfil4:
- popf ; carry == ungerade words ?
- jnc bfil5 ; nein, dann nicht..
- stosw ; ja, wird kopiert
-
- bfil5:
- popf ; carry == ungerade bytes ?
- jnc bfil6 ; nein, dann nicht..
- stosb ; ja, wird kopiert
-
- bfil6: ; und Tschüß...
- pop di
- pop si
- pop bp
- ret
-
- EndProc@ meminit,__CDECL__
-
- CSegEnd@
-
- end
- ;* ****************************************************** *
- ;* Ende von 386MEM.ASM *
-
-