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

linld: 32 bits lseeks for tazboot
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jan 05 17:23:23 2019 +0100 (2019-01-05)
parents d3d2a15d3d0d
children 57d97be431f4
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Thu Jan 03 12:04:23 2019 +0100
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Sat Jan 05 17:23:23 2019 +0100
     1.3 @@ -180,19 +180,6 @@
     1.4          endp    @puts$qpxzc
     1.5  
     1.6  
     1.7 -;***************************************************************
     1.8 -;_fastcall int fileattr(bx:const char* name);
     1.9 -;***************************************************************
    1.10 -        global  @fileattr$qpxzc:near
    1.11 -        proc    @fileattr$qpxzc near
    1.12 -
    1.13 -                mov	ax,4300h
    1.14 -		call	dos_filename
    1.15 -		xchg	ax,cx
    1.16 -		jmp	chkc
    1.17 -
    1.18 -        endp    @fileattr$qpxzc
    1.19 -
    1.20  
    1.21  ;***************************************************************
    1.22  ;_fastcall int open(bx:const char* name, int flags=O_RDONLY);
    1.23 @@ -211,19 +198,18 @@
    1.24  open:
    1.25  	ifdef	LONG_FILENAME
    1.26  		mov	ax,716Ch
    1.27 -		push	bx si di
    1.28 -		mov	di,di			; alias hint
    1.29 +		push	bx di si
    1.30  		mov	si,bx
    1.31  		xor	bx,bx			; R/O
    1.32  		xor	cx,cx			; attributes
    1.33 +		xor	di,di			; alias hint
    1.34  		cwd				; action = open
    1.35                  int	21h
    1.36 -		pop	di si bx
    1.37 +		pop	si di bx
    1.38                  jnc	doret
    1.39  	endif
    1.40                  mov	ax,3d00h		; read-only+compatibility
    1.41  		;mov	cl,0			; attribute mask
    1.42 -dos_filename:
    1.43                  mov	dx,bx
    1.44  dos:
    1.45                  int	21h
    1.46 @@ -244,6 +230,14 @@
    1.47  
    1.48  
    1.49  ;***************************************************************
    1.50 +;_fastcall int fileexist(bx:const char* name);
    1.51 +;***************************************************************
    1.52 +	global	@fileexist$qpxzc:near
    1.53 +@fileexist$qpxzc:
    1.54 +		call	@open$qpxzc
    1.55 +		jc	fail
    1.56 +
    1.57 +;***************************************************************
    1.58  ;_fastcall int close(ax:int fd);
    1.59  ;***************************************************************
    1.60          global  @close$qi:near
    1.61 @@ -274,6 +268,7 @@
    1.62  @write$qipvi:
    1.63                  clc
    1.64  		endif
    1.65 +@read$dxbxax:
    1.66  		xchg	ax,bx			; fd
    1.67  		xchg	ax,dx			; data
    1.68  		xchg	ax,cx			; sz
    1.69 @@ -291,36 +286,25 @@
    1.70          endp    @read$qipvi
    1.71  
    1.72  ;***************************************************************
    1.73 -;_fastcall long lseekset(ax:int fd, dx:unsigned whence);
    1.74  ;_fastcall long lseekcur(ax:int fd, dx:int whence);
    1.75  ;***************************************************************
    1.76  
    1.77          global  @lseekcur$qii:near		; fd=ax whence=dx
    1.78          proc    @lseekcur$qii near
    1.79  
    1.80 +		mov	cl,1
    1.81  		xchg	ax,bx
    1.82  		xchg	ax,dx
    1.83  		cwd
    1.84  		xchg	ax,dx
    1.85  		xchg	ax,cx
    1.86 -		mov	al,1
    1.87  		jmp	lseek
    1.88 -		ifdef EXTRA
    1.89 -        global  @lseekset$qiui:near
    1.90 -@lseekset$qiui:
    1.91 -		mov	bl,0
    1.92 -		jmp	lseek0x
    1.93 -lseekset:
    1.94 -		mov	bl,0
    1.95 -		jmp	lseekx
    1.96 -		endif
    1.97  rewind:						; rewind(ax)
    1.98  		mov	bl,0
    1.99 -lseek0:						; lseek0(bx,ax=dir)
   1.100 +lseek0:						; lseek0(ax,bl=dir)
   1.101  		xor	dx,dx
   1.102 -lseek0x:
   1.103  		xor	cx,cx
   1.104 -lseekx:
   1.105 +lseekset:
   1.106  		xchg	ax,bx
   1.107  lseek:
   1.108  		mov	ah,42h			; bx=fd cx:dx=offset al=whence
   1.109 @@ -346,15 +330,19 @@
   1.110  ends					; } isostate;
   1.111  ;***************************************************************
   1.112  ;_fastcall long isolseek(bx:const unsigned long *offset);
   1.113 +;_fastcall long lseekset2(ax:int fd, bx:unsigned long* whence);
   1.114  ;***************************************************************
   1.115          global  @isolseek$qpxul:near
   1.116          proc    @isolseek$qpxul near
   1.117  
   1.118  isolseek:
   1.119 +		extrn	_isostate:isostate
   1.120 +		mov	ax,[_isostate.fd]
   1.121 +	global	@lseekset2$qipul
   1.122 +@lseekset2$qipul:
   1.123  		mov	dx,[bx]
   1.124  		mov	cx,[bx+2]
   1.125 -		extrn	_isostate:isostate
   1.126 -		mov	ax,[_isostate.fd]
   1.127 +		mov	bl,0
   1.128  		jmp	lseekset
   1.129  
   1.130  	endp	@isolseek$qpxul
   1.131 @@ -366,17 +354,11 @@
   1.132          proc    @isoreadsector$qpxul near
   1.133  
   1.134  		call	isolseek
   1.135 -		and	ax,dx
   1.136 -		inc	ax
   1.137 -		jz	@@fail
   1.138 -		mov	cx,2560
   1.139 -		mov	dx,offset _isostate.buffer
   1.140 -		mov	bx,[_isostate.fd]
   1.141 -		call	@read$cxdxbx		; read(fd,buffer,2560)
   1.142 -@@fail:
   1.143 -		cmp	ax,2048
   1.144 -		sbb	ax,ax
   1.145 -		ret
   1.146 +		jc	doret
   1.147 +		mov	dx,2560
   1.148 +		mov	bx,offset _isostate.buffer
   1.149 +		mov	ax,[_isostate.fd]
   1.150 +		jmp	@read$dxbxax		; read(fd,buffer,2560)
   1.151  
   1.152          endp    @isoreadsector$qpxul
   1.153