wok diff linld/stuff/src/CRTL.ASM @ rev 20458

Up amule (2.3.2)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Oct 10 10:43:41 2018 +0200 (2018-10-10)
parents bcdfc23ee041
children 81a3d87e0965
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Sat Sep 29 15:27:00 2018 +0200
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Wed Oct 10 10:43:41 2018 +0200
     1.3 @@ -171,36 +171,6 @@
     1.4  
     1.5  
     1.6  ;***************************************************************
     1.7 -;void* malloc(unsigned sz);
     1.8 -;***************************************************************
     1.9 -        global  _malloc:near
    1.10 -        proc    _malloc near
    1.11 -
    1.12 -		pop	ax			;caller return address
    1.13 -                pop	cx			; sz
    1.14 -		push	cx
    1.15 -		push	ax
    1.16 -        global  malloc:near			; malloc(cx)
    1.17 -malloc:						; keep CX, use AX,BX
    1.18 -		mov	ax,[_heap_top]
    1.19 -		mov	bx,sp
    1.20 -		add	bh,-14h			; MIN_STACK=_1k+PAGE_SIZE
    1.21 -		sub	bx,ax			; can't overflow
    1.22 -		cmp	bx,cx
    1.23 -		mov	bx,offset msg_malloc
    1.24 -		jb	puts
    1.25 -		add	[_heap_top],cx		; _BEG has zero'd heap
    1.26 -		;mov	bx,ax
    1.27 -@@zalloc:
    1.28 -		;mov	[byte bx],0
    1.29 -		;inc	bx			; ZF=0
    1.30 -		;loop	@@zalloc
    1.31 -		ret
    1.32 -
    1.33 -        endp    _malloc
    1.34 -
    1.35 -
    1.36 -;***************************************************************
    1.37  ;void puts(const char* s):
    1.38  ;***************************************************************
    1.39          global  _puts:near
    1.40 @@ -438,8 +408,14 @@
    1.41                  push	ax
    1.42          global  malloc_or_die:near		; malloc_or_die(cx)
    1.43  malloc_or_die:
    1.44 -		call	malloc
    1.45 -		jz	_exit
    1.46 +		mov	ax,[_heap_top]		; return value
    1.47 +		mov	bx,sp
    1.48 +		add	bh,-14h			; MIN_STACK=_1k+PAGE_SIZE
    1.49 +		sub	bx,ax			; can't overflow
    1.50 +		cmp	bx,cx
    1.51 +		mov	bx,offset msg_malloc
    1.52 +		jb	die
    1.53 +		add	[_heap_top],cx		; _BEG has zero'd heap
    1.54  		ret
    1.55  
    1.56          endp    _malloc_or_die