home *** CD-ROM | disk | FTP | other *** search
- .386
- locals
-
- _TEXT segment para public use32 'CODE'
-
- _TEXT ends
- _DATA SEGMENT DWORD PUBLIC USE32 'DATA'
- extrn __linear : DWORD, __pmodew:word
- maxaddr dd 0
- ENDS
-
- public __ll_malloc, __ll_free, __ll_transfer
-
- DGROUP group _TEXT, _DATA
-
- _TEXT segment
- assume cs:DGROUP,ds:DGROUP
- _main:
- ret
- ;________________________________________________________________________
- ;
- ; doesn't resize SS or CS!!!! use at own risk!!!
- ;
- resizeds proc
- test [__pmodew],-1
- jnz noresize
- cmp eax,[maxaddr]
- jbe noresize
- mov [maxaddr],eax
- push ebx
- push esi
- push edi
- dec eax
- mov dx,ax
- shr eax,16
- mov cx,ax
- mov bx,ds
- mov ax,8
- int 31h
- pop edi
- pop esi
- pop ebx
- cli
- sub ax,ax
- push es
- mov es,ax
- pop es
- push fs
- mov fs,ax
- pop fs
- push gs
- mov gs,ax
- pop gs
- sti
- noresize:
- ret
- resizeds endp
- ;
- ;void *__ll_malloc(int size)
- __ll_malloc:
- push ebp
- push esi
- push edi
- push ebx
- mov ebx,[esp+20]
- or ebx,ebx
- jz @@failed
- add ebx,4
- and ebx,0fffff000h
- mov cx,bx
- shr ebx,16
- mov ax,501h
- int 31h
- jc @@failed
- shl ebx,16
- mov bx,cx
- sub ebx,[__linear]
- mov eax,[esp+20]
- add eax,4095+4
- add eax,ebx
- and eax,0fffff000h
- call resizeds
- mov [ebx],si
- mov [ebx+2],di
- add ebx,4
- @@go2:
- mov eax,ebx
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
- @@failed:
- sub eax,eax
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
- ;
- ;________________________________________________________________________
- ;void __ll_free(void *block)
- ;
- __ll_free:
- push ebp
- push esi
- push edi
- push ebx
- mov ebx,[esp+20]
- or ebx,ebx
- jz @@failed
- ;
- ; if this were meant to be called by the user it would have more guards
- ; but the RTL should be the only thing calling it...
- ;
- sub ebx,4
- mov si,[ebx]
- mov di,[ebx+2]
- mov ax,502h
- int 31h
- @@failed:
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
-
- ;________________________________________________________________________
- ;void __ll_transfer(void)
- __ll_transfer:
- ret
- _TEXT ends
-
- END