wok-current rev 20142

linld: tiny shrink
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 11 10:57:19 2017 +0100 (2017-11-11)
parents eb2ccd9e093c
children 0863dbc8e921
files linld/stuff/src/CRTL.ASM linld/stuff/src/JUMP.ASM linld/stuff/src/MEMTOP.ASM linld/stuff/src/XMM.ASM linld/stuff/src/_BEG.ASM
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Sun Nov 05 22:04:17 2017 +0100
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Sat Nov 11 10:57:19 2017 +0100
     1.3 @@ -55,27 +55,26 @@
     1.4          proc    _strcatb near
     1.5  
     1.6  	ifdef	EXTRA
     1.7 -		mov	dl,3
     1.8 +		mov	cl,7Fh
     1.9  		db	0bbh			; mov	bx,imm opcode
    1.10          global  _strcat:near
    1.11  _strcat:
    1.12 -		mov	dl,1
    1.13 +		mov	cl,80h
    1.14  		db	0bbh			; mov	bx,imm opcode
    1.15          global  _strcpy:near
    1.16  _strcpy:
    1.17 -		mov	dl,0
    1.18 +		xor	cx,cx
    1.19  	endif
    1.20  		pop	ax			;caller return address
    1.21 -                pop	cx			; a
    1.22 +                pop	dx			; a
    1.23                  pop	bx			; b
    1.24                  push	bx
    1.25 -                push	cx
    1.26 +                push	dx
    1.27                  push	ax
    1.28                  push	si
    1.29 -                mov	si,cx
    1.30 +                mov	si,dx
    1.31  	ifdef	EXTRA
    1.32 -		shr	dl,1
    1.33 -		jnc	@@nocat
    1.34 +		jcxz	@@nocat
    1.35  	endif
    1.36  @@catlp:
    1.37  		lodsb
    1.38 @@ -83,24 +82,25 @@
    1.39                  jne	@@catlp
    1.40  		dec	si
    1.41  	ifdef	EXTRA
    1.42 -		shr	dl,1
    1.43 -		jnc	@@nocat
    1.44 +		cmp	dx,si
    1.45 +		adc	al,cl		; set S when dx != si or cl = 80
    1.46 +		mov	al,20h
    1.47 +		jns	@@cpyhead
    1.48  	endif
    1.49 -		cmp	cx,si
    1.50 -		jz	@@nocat
    1.51 -		mov	[word si],20h
    1.52 -		inc	si
    1.53  @@nocat:
    1.54 -                sub	bx,si
    1.55  @@cpylp:
    1.56 -                mov	al,[bx+si]
    1.57 +                mov	al,[bx]
    1.58 +                inc	bx
    1.59 +@@cpyhead:
    1.60                  mov	[si],al
    1.61                  inc	si
    1.62  		cmp	al,0
    1.63                  jne	@@cpylp
    1.64 -		mov	ax,cx
    1.65 +strfound:
    1.66 +		xchg	ax,dx
    1.67 +strend:
    1.68                  pop	si
    1.69 -                ret
    1.70 +		ret
    1.71  
    1.72          endp    _strcatb
    1.73  
     2.1 --- a/linld/stuff/src/JUMP.ASM	Sun Nov 05 22:04:17 2017 +0100
     2.2 +++ b/linld/stuff/src/JUMP.ASM	Sat Nov 11 10:57:19 2017 +0100
     2.3 @@ -36,6 +36,7 @@
     2.4  	global	_boot_kernel:near
     2.5          proc    _boot_kernel near
     2.6          
     2.7 +                p8086
     2.8  ; Shrink stack: we won't need much of it now and have no malloc() plans
     2.9  		extrn	_heap_top:word
    2.10  		mov	ax,[_heap_top]
    2.11 @@ -53,6 +54,7 @@
    2.12  		mov	ax,sp
    2.13  		shr	ax,cl
    2.14  		else
    2.15 +                p386
    2.16  		mov	bx,9000h
    2.17  		mov	es,bx
    2.18  		mov	ax,sp
     3.1 --- a/linld/stuff/src/MEMTOP.ASM	Sun Nov 05 22:04:17 2017 +0100
     3.2 +++ b/linld/stuff/src/MEMTOP.ASM	Sat Nov 11 10:57:19 2017 +0100
     3.3 @@ -77,12 +77,10 @@
     3.4  
     3.5                  mov     ah,88h
     3.6                  int     15h             ;ax=kbs above 1m
     3.7 -                jnc     @@ok            ;  error: cf=1 or ax=0
     3.8 -                xor     ax,ax           ;
     3.9 -@@ok:
    3.10 -;                xor     dx,dx
    3.11 -                test    ax,ax           ;happens on big mem systems
    3.12 -                jnz      tokb
    3.13 +                cmc                     ;  error: cf=1 or ax=0
    3.14 +		sbb	dx,dx
    3.15 +                and     ax,dx           ;
    3.16 +                jnz     tokb            ;happens on big mem systems
    3.17  
    3.18  ;***************************************************************
    3.19  ;u32 memtop_cmos()
    3.20 @@ -90,7 +88,6 @@
    3.21  
    3.22  ;memtop_cmos:
    3.23                  pushf
    3.24 -                cli
    3.25                  call	rdcmos17
    3.26                  popf
    3.27  tokb:
    3.28 @@ -98,12 +95,12 @@
    3.29                  add     ah,4h           ;account for 1024 low kb
    3.30                  adc     dx,dx           ;  (optimized to death)
    3.31  		mov	cl,10		;multiply by 1024
    3.32 -        global  N_LXLSH@:near
    3.33 -N_LXLSH@:
    3.34  		ifndef	NO386
    3.35  		shld    dx,ax,cl
    3.36  		shl     ax,cl		;  (kbytes -> bytes)
    3.37  		else
    3.38 +        global  N_LXLSH@:near
    3.39 +N_LXLSH@:
    3.40  		mov	ch,0
    3.41  @@lp:
    3.42  		shl	ax,1
    3.43 @@ -141,7 +138,8 @@
    3.44  ;		jnz	@@ok
    3.45  ;		jmp	memtop_cmos
    3.46  
    3.47 -rdcmos17:       mov     al,18h		; read bytes 17-18 from CMOS
    3.48 +rdcmos17:       cli
    3.49 +                mov     al,18h		; read bytes 17-18 from CMOS
    3.50                  call    @@rdcmos
    3.51                  mov     ah,al
    3.52                  mov     al,17h
     4.1 --- a/linld/stuff/src/XMM.ASM	Sun Nov 05 22:04:17 2017 +0100
     4.2 +++ b/linld/stuff/src/XMM.ASM	Sat Nov 11 10:57:19 2017 +0100
     4.3 @@ -38,7 +38,7 @@
     4.4  
     4.5  ;***************************************************************
     4.6  ;Call xmm driver addr or 0 if no xmm
     4.7 -;void xmm_driver()
     4.8 +;void xmm_driver(ah)
     4.9  ;***************************************************************
    4.10          global  xmm_driver:near
    4.11          proc    xmm_driver near
    4.12 @@ -46,7 +46,7 @@
    4.13  		push	si
    4.14  		mov	si,offset xmm_handler
    4.15  		ifndef	NO386
    4.16 -		cmp	[si],0
    4.17 +		cmp	[dword si],0
    4.18  		else
    4.19  		mov	ax,[word si]
    4.20  		or	ax,[word si+2]
    4.21 @@ -54,14 +54,14 @@
    4.22  		jne	@@gotit
    4.23  
    4.24  		xchg	ax,cx			; save cmd
    4.25 -                mov     ax,4300h
    4.26 +                mov     ax,4300h		; installation check in al
    4.27                  int     2fh
    4.28                  mov     bx,offset xmm_fail
    4.29                  push    cs
    4.30                  pop     es
    4.31                  cmp     al,80h
    4.32                  jne     @@err
    4.33 -                mov     ax,4310h
    4.34 +                mov     ax,4310h		; get driver address in es:bx
    4.35                  int     2fh
    4.36  @@err:
    4.37  		xchg	ax,cx			; restore cmd
    4.38 @@ -70,6 +70,7 @@
    4.39  		pop	[dword si]
    4.40  @@gotit:
    4.41  		call	[dword si]
    4.42 +                dec     ax			; Z=1=OK
    4.43  		pop	si
    4.44                  ret
    4.45  xmm_fail:
    4.46 @@ -80,21 +81,22 @@
    4.47          endp    xmm_driver
    4.48  
    4.49  
    4.50 +struc   image_himem		;struct image_himem {
    4.51 +fd		dw	?	; 0    int fd;
    4.52 +fallback	dd	?	; 2    u32 fallback;
    4.53 +size		dd	?	; 6    u32 size;
    4.54 +remaining	dd	?	;10    u32 remaining;
    4.55 +buf		dd	?	;14    u32 buf;
    4.56 +bufv		dw	?	;18    u32 *bufv;
    4.57 +errmsg		dw	?	;20    char *errmsg;
    4.58 +chunk_size	dd	?	;22    u32 chunk_size;
    4.59 +next_chunk	dw	?	;26    void (*next_chunk)(struct image_himem *);
    4.60 +state		dw	?	;28    u16 state;
    4.61 +fd2close	dw	?	;30    u16 fd2close;
    4.62 +ends				;};
    4.63 +
    4.64  ;***************************************************************
    4.65  ;void xmm_alloc(struct image_himem *m)
    4.66 -;struct image_himem {
    4.67 -; 0    int fd;
    4.68 -; 2    u32 fallback;
    4.69 -; 6    u32 size;
    4.70 -;10    u32 remaining;
    4.71 -;14    u32 buf;
    4.72 -;18    u32 *bufv;
    4.73 -;20    char *errmsg;
    4.74 -;22    u32 chunk_size;
    4.75 -;26    void (*next_chunk)(struct image_himem *);
    4.76 -;28    u16 state;
    4.77 -;30    u16 fd2close;
    4.78 -;};
    4.79  ;***************************************************************
    4.80          global  _xmm_alloc:near
    4.81          proc    _xmm_alloc near
    4.82 @@ -104,35 +106,35 @@
    4.83                  push    bx
    4.84                  push    ax
    4.85  		ifndef	NO386
    4.86 -		mov	edx,[bx+6]		; m->size
    4.87 -                dec     edx
    4.88 +		mov	edx,[(image_himem bx).size]		; m->size
    4.89 +                ;dec     edx
    4.90                  shr     edx,10          ; to Kb
    4.91  		else
    4.92 -		mov	ax,[bx+6]		; lo m->size
    4.93 -		mov	dx,[bx+8]		; hi m->size
    4.94 -		sub	ax,1
    4.95 -		sbb	dx,0
    4.96 -		mov	cl,10
    4.97 -		extrn	N_LXURSH@:near
    4.98 -		call	N_LXURSH@
    4.99 +		;mov	ax,-1
   4.100 +		;cwd
   4.101 +		;add	ax,[word (image_himem bx).size]		; lo m->size
   4.102 +		;adc	dx,[word (image_himem bx+2).size]	; hi m->size
   4.103 +		mov	ax,[word (image_himem bx).size]		; lo m->size
   4.104 +		mov	dx,[word (image_himem bx+2).size]	; hi m->size
   4.105 +		mov	cl,16-10
   4.106 +		extrn	N_LXLSH@:near
   4.107 +		call	N_LXLSH@
   4.108  		endif
   4.109                  inc     dx
   4.110  		push	bx
   4.111 -                mov     ah,09h          ;allocate blk
   4.112 +                mov     ah,09h          ;allocate blk of DX kilobytes
   4.113                  call    xmm_driver      ;
   4.114 -                dec     ax
   4.115                  jnz     @@goerr
   4.116                                          ;now: dx=handle of the blk
   4.117                  mov     ah,0Ch          ;lock blk
   4.118                  call    xmm_driver      ;
   4.119 -                dec     ax
   4.120                                          ;now: dx:bx=addr of blk
   4.121                  xchg    ax,bx
   4.122  @@goerr:
   4.123  		pop	bx
   4.124                  jnz     @@err
   4.125 -		mov	[bx+14],ax	; lo m->buf
   4.126 -		mov	[bx+16],dx	; hi m->buf
   4.127 +		mov	[word (image_himem bx).buf],ax		; lo m->buf
   4.128 +		mov	[word (image_himem bx+2).buf],dx	; hi m->buf
   4.129  @@err:
   4.130                  ret
   4.131  
     5.1 --- a/linld/stuff/src/_BEG.ASM	Sun Nov 05 22:04:17 2017 +0100
     5.2 +++ b/linld/stuff/src/_BEG.ASM	Sat Nov 11 10:57:19 2017 +0100
     5.3 @@ -151,9 +151,9 @@
     5.4  check_rm_paging:
     5.5  ; It's a 386 in real mode, chk for paging (crazy but possible)
     5.6                  p386
     5.7 -                mov     edx,cr0
     5.8 -                shl     edx,1   ;CR0_PG to CF
     5.9 -		jc	no_vcpi
    5.10 +                mov     eax,cr0
    5.11 +                inc     eax             ;CR0_PG to S
    5.12 +		js	no_vcpi
    5.13  endcpu:
    5.14                  p8086
    5.15  
    5.16 @@ -175,6 +175,14 @@
    5.17  		xchg	ax,bx
    5.18                  mov	[bx+si],bh		; set eos
    5.19  argbuild:
    5.20 +		;ifdef	DEBUG
    5.21 +                p386
    5.22 +		pusha
    5.23 +		mov	bx,si
    5.24 +		extrn	puts:near
    5.25 +		call	puts
    5.26 +		popa
    5.27 +		;endif
    5.28                  mov	bx,2			; argc * 2
    5.29  argeos:
    5.30                  mov	dl,1			; look for a start of string