Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

rtlib_memman.bi

Uploader:MitgliedThePuppetMaster
Datum/Zeit:26.08.2008 22:20:19

'###############################################################################################################
'###############################################################################################################
'###   F B - C O R E
'###############################################################################################################
'###############################################################################################################
'### Version:  1.00.0
'### Revision: 0
'###############################################################################################################
'### (c) 2008 By.: /_\ DeltaLab's Germany [experimental computing]
'### Author:       Martin Wiemann
'### Date of Idea: 2008.08.16 - 17:55:38
'###############################################################################################################
'### Copy('s) of this code or a part of this IS allowed!!!
'###############################################################################################################





'###############################################################################################################
'== begin temporaly code ==
DIM SHARED x_heap_end AS UInteger = 2 * 1024 * 1024



'###############################################################################################################
Private Function _mem_alloc (V_Length As UInteger) as Any Ptr
Dim XPtr as Any Ptr = Cast(Any Ptr, x_heap_end)
x_heap_end += V_Length
Return XPtr
End Function

'====================================================================================================================
Private Function _mem_realloc(V_MemPtr as Any Ptr, V_Length As UInteger) as Any Ptr
Dim XPtr as Any Ptr = Cast(Any Ptr, x_heap_end)
x_heap_end += V_Length
Return XPtr
End Function

'====================================================================================================================
Private Sub _mem_free(V_MemPtr as Any Ptr)
'V_MemPtr = 0
End Sub
'== end temporaly code ==

'====================================================================================================================
Private Sub x_memcpy(V_DestPtr as Any Ptr, V_SrcPtr as Any Ptr, V_Size as UInteger)
Asm
    push    ebp
    mov     ebp, esp
    push    ecx
    push    edx
    push    edi
    push    esi
    mov     esi, [V_SrcPtr]
    mov     edi, [V_DestPtr]
    mov     ecx, [V_Size]
    mov     edx, ecx
    and     ecx, &HFFFFFFFC
    shr     ecx, 2
    rep     movsd
    mov     ecx, edx
    and     ecx, 3
    rep     movsb
    pop     esi
    pop     edi
    pop     edx
    pop     ecx
    mov     esp, ebp
    pop     ebp
End Asm
End Sub

Private Sub _memcpy(V_DestPtr as Any Ptr, V_SrcPtr as Any Ptr, V_Size as UInteger)
Dim DPtr as UByte Ptr = Cast(UByte Ptr, V_DestPtr)
Dim SPtr as UByte Ptr = Cast(UByte Ptr, V_SrcPtr)
For X as UInteger = 1 to V_Size
    *DPtr = *SPtr
    DPtr += 1
    SPtr += 1
Next
End Sub

'====================================================================================================================
Private Sub _memset(V_DestPtr as Any Ptr, V_Value as UByte, V_Size as UInteger)
Dim DPtr as UByte Ptr = Cast(UByte Ptr, V_DestPtr)
For X as UInteger = 1 to V_Size
    *DPtr = V_Value
    DPtr += 1
Next
End Sub