home *** CD-ROM | disk | FTP | other *** search
- ;/*************************************************************************
- ;**
- ;** Copyright 1982-1995 Btrieve Technologies, Inc. All Rights Reserved
- ;**
- ;*************************************************************************/
- ;/*************************************************************************
- ; BMEMCOPY.ASM
- ; You need the object for this module if your application uses
- ; the Borland Powerpack 32-Bit DOS Extender (BTI_DOS_32B) or the
- ; Phar Lap TNT 32-Bit DOS Extender (BTI_DOS_32P). We provide
- ; this source for your reference needs. You don't need it if
- ; you use 'bmemcopy.obj', which is already assembled.
- ;
- ; IMPORTANT
- ; ---------
- ; Btrieve Technologies, Inc., invites you to modify this file
- ; if you find it necessary for your particular situation. However,
- ; we cannot provide technical support for this module if you
- ; do modify it.
- ;
- ;*************************************************************************/
- .386 ; must have .386 otherwise masm
- ; will try to generate 16-bit code
- TITLE Functions to copy data to/from DOS real memory
- _TEXT SEGMENT
- ASSUME CS:_TEXT
- PUBLIC _getLowMemByte
- PUBLIC _setLowMemByte
- PUBLIC _getLowMemWord
- PUBLIC _setLowMemWord
- PUBLIC _getLowMemLong
- PUBLIC _setLowMemLong
- PUBLIC _copyToLow
- PUBLIC _copyFromLow
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_CHAR cdecl getLowMemByte(
- ;* BTI_WORD sel,
- ;* BTI_ULONG selOffset);
- ;*
- ;* Description:
- ;*
- ;* Returns a byte from low memory using the given
- ;* selector and offset.
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: Protected mode selector
- ;* <input>
- ;*
- ;* selOffset: Protected mode offset
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* a byte
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _getLowMemByte PROC NEAR
- push ebp
- mov ebp,esp
- push ebx
- mov ebx,[ebp+12] ; selOffset
- push ds
- mov ds, [ebp+8] ; sel
- mov al, ds:[ebx]
- pop ds
- xor ah, ah
- pop ebx
- pop ebp
- ret
-
- _getLowMemByte ENDP
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_CHAR setLowMemByte(
- ;* BTI_WORD sel,
- ;* BTI_ULONG selOffset,
- ;* BTI_BYTE src )
- ;*
- ;* Description:
- ;*
- ;* Copy a byte to low memory at the given address
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: Selector of destination address
- ;* <input>
- ;*
- ;* selOffset: Offset of destination address
- ;* <input>
- ;*
- ;* src: Byte to be copied.
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* None.
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- _setLowMemByte PROC NEAR
- push ebp
- mov ebp, esp
- push ebx
- mov ebx, [ebp+12]
- mov al, [ebp+16]
- push es
- mov es, [ebp+8]
- mov es:[ebx], al
- pop es
- xor ah, ah
- pop ebx
- pop ebp
- ret
- _setLowMemByte ENDP
-
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_WORD getLowMemWord( BTI_WORD sel, BTI_ULONG selOffset )
- ;*
- ;* Description:
- ;*
- ;* Return the word at location given by sel:selOffset
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: Selector of source address
- ;* <input>
- ;*
- ;* selOffset: Offset of source address
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* The word that resides in low memory at sel:selOffset
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- _getLowMemWord PROC NEAR
- push ebp
- mov ebp, esp
- push ebx
- mov ebx, [ebp + 12]
- push ds
- mov ds, [ebp+8]
- mov ax, ds:[ebx]
- pop ds
- pop ebx
- pop ebp
- ret
- _getLowMemWord ENDP
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_WORD setLowMemWord(
- ;* BTI_WORD sel,
- ;* BTI_ULONG selOffset,
- ;* BTI_WORD src )
- ;*
- ;* Description:
- ;*
- ;* Copy the src value to low memory at sel:selOffset
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: Selector of destination address
- ;* <input>
- ;*
- ;* selOffset: Offset of destination address
- ;* <input>
- ;*
- ;* src: Value to be copied.
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* None.
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _setLowMemWord PROC NEAR
- push ebp
- mov ebp, esp
- push ebx
- mov ebx, [ebp+12] ; offset
- mov ax, [ebp+16] ; data value
- push es
- mov es, [ebp+8] ; selector
- mov es:[ebx], ax
- pop es
- pop ebx
- pop ebp
- ret
- _setLowMemWord ENDP
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_ULONG getLowMemLong( BTI_WORD sel, BTI_ULONG selOffset )
- ;*
- ;* Description:
- ;*
- ;* Copy 4 bytes from sel:selOffset
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: selector of source address
- ;* <input>
- ;*
- ;* selOffset: offset of source address
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* Long value is returned in AX register
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _getLowMemLong PROC NEAR
- push ebp
- mov ebp,esp
- push ebx
- mov ebx, [ebp+12] ; offset
- push ds
- mov ds, [ebp+8] ; selector
- mov eax, ds:[ebx]
- pop ds
- pop ebx
- pop ebp
- ret
- _getLowMemLong ENDP
-
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* BTI_ULONG setLowMemLong(
- ;* BTI_WORD sel,
- ;* BTI_ULONG selOffset,
- ;* BTI_ULONG src )
- ;*
- ;* Description:
- ;*
- ;* Copy 4 bytes from src to sel:selOffset in low memory
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* sel: selector of source address
- ;* <input>
- ;*
- ;* selOffset: offset of source address
- ;* <input>
- ;*
- ;* src: source to copy
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* None.
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _setLowMemLong PROC NEAR
- push ebp
- mov ebp,esp
- push ebx
- mov ebx, [ebp+12] ;selOffset
- mov eax, [ebp+16] ;src
- push es
- mov es, [ebp+8] ;sel
- mov es:[ebx], eax
- pop es
- pop ebx
- pop ebp
- ret
- _setLowMemLong ENDP
-
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* void copyToLow(
- ;* unsigned short dst_sel,
- ;* unsigned dst_offset,
- ;* void * src,
- ;* unsigned int size)
- ;*
- ;* Description:
- ;*
- ;* Copies a block to a specified real mode address from
- ;* a 32-bit flat address.
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* dst_sel: Destination selector
- ;* <input>
- ;*
- ;* dst_offset: Destination offset
- ;* <input>
- ;*
- ;* src: 32-bit pointer to source
- ;* <input>
- ;*
- ;* size: Length of source
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* None.
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _copyToLow PROC NEAR
- push ebp
- mov ebp, esp
- push ebx
- push edi
- push esi
- push es
- mov es , [ebp+8] ; dst_sel
- mov edi, [ebp+12] ; dst_offset
- mov esi, [ebp+16] ; src
- cld
- mov ecx, [ebp+20] ; size
- shr ecx, 2 ; move double words
- rep movsd
- mov ecx, [ebp+20]
- and ecx, 3 ; move extra bytes
- jcxz no_copy_to
- rep movsb
- no_copy_to:
- pop es
- pop esi
- pop edi
- pop ebx
- pop ebp
- ret
- _copyToLow ENDP
-
- ;
- ;*
- ;****************************************************************************
- ;*
- ;* Prototype:
- ;*
- ;* void copyFromLow(
- ;* void * dst,
- ;* unsigned short src_sel,
- ;* unsigned src_offset,
- ;* unsigned int size)
- ;*
- ;* Description:
- ;*
- ;* copies a block from a specified real mode address to
- ;* a 32-bit flat address.
- ;*
- ;* Preconditions:
- ;*
- ;* None.
- ;*
- ;* Parameters:
- ;*
- ;* dst: 32-bit destination address
- ;* <input>
- ;*
- ;* src_sel: Selector of source address
- ;* <input>
- ;*
- ;* src_offset: Offset of source address
- ;* <input>
- ;*
- ;* size: Size to copy
- ;* <input>
- ;*
- ;*
- ;* Return value:
- ;*
- ;* None.
- ;*
- ;* Globals:
- ;*
- ;* None.
- ;*
- ;* Called Functions:
- ;*
- ;* None.
- ;*
- ;* Comments:
- ;*
- ;* None.
- ;*
- ;****************************************************************************
- ;*
- ;
- _copyFromLow PROC NEAR
- push ebp
- mov ebp,esp
- push ebx
- push edi
- push esi
- push es
- push ds
-
- push ds
- pop es
- mov edi, [ebp+8] ; dst
- mov ds , [ebp+12] ; src_sel
- mov esi, [ebp+16] ; src_offset
- cld
- mov ecx, [ebp+20] ; size
- shr ecx, 2 ; move double words
- rep movsd
- mov ecx, [ebp+20]
- and ecx, 3 ; move extra bytes
- jcxz no_copy_from
- rep movsb
-
- no_copy_from:
- pop ds
- pop es
- pop esi
- pop edi
- pop ebx
- pop ebp
- ret
- _copyFromLow ENDP
-
-
- _TEXT ENDS
- END
-