wok-current diff linld/stuff/src/CRTL.ASM @ rev 21757

tazboot: spave 40k+ for zImage
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jun 24 16:31:09 2019 +0200 (2019-06-24)
parents 8b9f768b711e
children a3046db1ef94
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Wed Jun 19 17:26:14 2019 +0200
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Mon Jun 24 16:31:09 2019 +0200
     1.3 @@ -19,8 +19,7 @@
     1.4  		global	_heap_top
     1.5  		extrn	_bss_end
     1.6  _heap_top	dw	_bss_end
     1.7 -msg_hang	db      "High mem corrupted - not exiting to DOS"
     1.8 -msg_lf		db	10,0
     1.9 +msg_hang	db      "High mem corrupted - not exiting to DOS",0
    1.10  vcpi_alloc_err	db	"VCPI "
    1.11  msg_malloc      db      "malloc error",0
    1.12  	ifdef	EXTRA
    1.13 @@ -86,18 +85,14 @@
    1.14          global  @strcatb$qpxzct1:near
    1.15          proc	@strcatb$qpxzct1 near
    1.16  
    1.17 -	ifdef	EXTRA
    1.18  		mov	cl,7Fh
    1.19  		db	0bah			; mov	dx,imm opcode
    1.20          global	@strcpy$qpxzct1:near
    1.21  @strcpy$qpxzct1:
    1.22  		xor	cx,cx
    1.23 -	endif
    1.24                  push	si
    1.25                  xchg	ax,si			; b
    1.26 -	ifdef	EXTRA
    1.27  		jcxz	@@nocat
    1.28 -	endif
    1.29  		dec	bx
    1.30  @@catlp:
    1.31                  inc	bx
    1.32 @@ -185,29 +180,32 @@
    1.33  ;_fastcall void puts(bx:const char* s):
    1.34  ;***************************************************************
    1.35          global  @puts$qpxzc:near
    1.36 -        proc    @puts$qpxzc near
    1.37  
    1.38  ;        global  puts:near			; puts(bx)
    1.39 +@putsz:
    1.40 +		call	@putc
    1.41 +@puts$qpxzc:
    1.42  puts:
    1.43 -		call	@@putsz
    1.44 -                mov	bx,offset msg_lf
    1.45 -		mov	dl,13
    1.46 -@@putcz:
    1.47 -		mov	ah,2
    1.48 -		int	21h
    1.49 -@@putsz:
    1.50  		mov	dl,[bx]
    1.51  		inc	bx
    1.52  		or	dl,dl
    1.53 -		jne	@@putcz			; ZF=1  (for malloc failure)
    1.54 +		jne	@putsz
    1.55 +		mov	dl,10
    1.56 +@putc:
    1.57 +		cmp	dl,10
    1.58 +		jne	@putcz
    1.59 +		call	@putcz2
    1.60 +@putcz2:
    1.61 +		xor	dl,7		; 10^13  1010^1101
    1.62 +@putcz:
    1.63 +		mov	ah,2
    1.64 +		int	21h
    1.65  		ret
    1.66  
    1.67 -        endp    @puts$qpxzc
    1.68 -
    1.69 -
    1.70  
    1.71  ;***************************************************************
    1.72  ;_fastcall int open(bx:const char* name, int flags=O_RDONLY);
    1.73 +;_fastcall int openargs(bx:const char* name, int flags=O_RDONLY);
    1.74  ;***************************************************************
    1.75          global  openargs:near			; openargs(bx)
    1.76  openargs:
    1.77 @@ -508,8 +506,19 @@
    1.78  		endif
    1.79  
    1.80  ;***************************************************************
    1.81 +;_fastcall char* strdup(bx:const char* a);
    1.82  ;_fastcall char* malloc_or_die(ax:unsigned size);
    1.83  ;***************************************************************
    1.84 +	global	@strdup$qpxzc:near
    1.85 +@strdup$qpxzc:
    1.86 +		mov	ax,[_heap_top]
    1.87 +		xchg	ax,bx
    1.88 +		call	@strcpy$qpxzct1
    1.89 +		xchg	ax,bx
    1.90 +xchg_heap_top:
    1.91 +		xchg	ax,[_heap_top]
    1.92 +		ret
    1.93 +
    1.94          global  @malloc_or_die$qui:near
    1.95          proc    @malloc_or_die$qui near
    1.96  
    1.97 @@ -520,11 +529,10 @@
    1.98  		mov	bx,sp
    1.99  		add	bh,-14h			; MIN_STACK=_1k+PAGE_SIZE
   1.100  		sub	bx,ax			; can't overflow
   1.101 +		add	ax,cx
   1.102  		cmp	bx,cx
   1.103  		mov	bx,offset msg_malloc
   1.104 -		jb	die
   1.105 -		add	[_heap_top],cx		; _BEG has zero'd heap
   1.106 -		ret
   1.107 +		ja	xchg_heap_top
   1.108  
   1.109          endp    @malloc_or_die$qui
   1.110  
   1.111 @@ -545,9 +553,8 @@
   1.112  		mov	al,[_no_exit]
   1.113  		or	al,al
   1.114  		jne	@@hang
   1.115 -		extrn	exit:near
   1.116 -		inc	ax
   1.117 -		jmp	near exit
   1.118 +                mov	ah,4Ch
   1.119 +                int	21h
   1.120  @@hang:
   1.121  		mov	bx, offset msg_hang
   1.122  		call	puts
   1.123 @@ -1330,7 +1337,7 @@
   1.124          global  _progname:near
   1.125          proc    _progname near
   1.126  
   1.127 -		push	si di es
   1.128 +		push	si di
   1.129  		mov	ah,30h
   1.130  		int	21h
   1.131  		xor	di,di
   1.132 @@ -1363,7 +1370,7 @@
   1.133  		push	es
   1.134  		pop	ds
   1.135  @@skip:
   1.136 -		pop	es di si
   1.137 +		pop	di si
   1.138  		ret
   1.139  
   1.140          endp    _progname