# HG changeset patch # User Pascal Bellard # Date 1510394239 -3600 # Node ID 04feaffdc0d910b74cfef5199e4db477a62edda8 # Parent eb2ccd9e093c526649d4463e7707280c4ab68636 linld: tiny shrink diff -r eb2ccd9e093c -r 04feaffdc0d9 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sun Nov 05 22:04:17 2017 +0100 +++ b/linld/stuff/src/CRTL.ASM Sat Nov 11 10:57:19 2017 +0100 @@ -55,27 +55,26 @@ proc _strcatb near ifdef EXTRA - mov dl,3 + mov cl,7Fh db 0bbh ; mov bx,imm opcode global _strcat:near _strcat: - mov dl,1 + mov cl,80h db 0bbh ; mov bx,imm opcode global _strcpy:near _strcpy: - mov dl,0 + xor cx,cx endif pop ax ;caller return address - pop cx ; a + pop dx ; a pop bx ; b push bx - push cx + push dx push ax push si - mov si,cx + mov si,dx ifdef EXTRA - shr dl,1 - jnc @@nocat + jcxz @@nocat endif @@catlp: lodsb @@ -83,24 +82,25 @@ jne @@catlp dec si ifdef EXTRA - shr dl,1 - jnc @@nocat + cmp dx,si + adc al,cl ; set S when dx != si or cl = 80 + mov al,20h + jns @@cpyhead endif - cmp cx,si - jz @@nocat - mov [word si],20h - inc si @@nocat: - sub bx,si @@cpylp: - mov al,[bx+si] + mov al,[bx] + inc bx +@@cpyhead: mov [si],al inc si cmp al,0 jne @@cpylp - mov ax,cx +strfound: + xchg ax,dx +strend: pop si - ret + ret endp _strcatb diff -r eb2ccd9e093c -r 04feaffdc0d9 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sun Nov 05 22:04:17 2017 +0100 +++ b/linld/stuff/src/JUMP.ASM Sat Nov 11 10:57:19 2017 +0100 @@ -36,6 +36,7 @@ global _boot_kernel:near proc _boot_kernel near + p8086 ; Shrink stack: we won't need much of it now and have no malloc() plans extrn _heap_top:word mov ax,[_heap_top] @@ -53,6 +54,7 @@ mov ax,sp shr ax,cl else + p386 mov bx,9000h mov es,bx mov ax,sp diff -r eb2ccd9e093c -r 04feaffdc0d9 linld/stuff/src/MEMTOP.ASM --- a/linld/stuff/src/MEMTOP.ASM Sun Nov 05 22:04:17 2017 +0100 +++ b/linld/stuff/src/MEMTOP.ASM Sat Nov 11 10:57:19 2017 +0100 @@ -77,12 +77,10 @@ mov ah,88h int 15h ;ax=kbs above 1m - jnc @@ok ; error: cf=1 or ax=0 - xor ax,ax ; -@@ok: -; xor dx,dx - test ax,ax ;happens on big mem systems - jnz tokb + cmc ; error: cf=1 or ax=0 + sbb dx,dx + and ax,dx ; + jnz tokb ;happens on big mem systems ;*************************************************************** ;u32 memtop_cmos() @@ -90,7 +88,6 @@ ;memtop_cmos: pushf - cli call rdcmos17 popf tokb: @@ -98,12 +95,12 @@ add ah,4h ;account for 1024 low kb adc dx,dx ; (optimized to death) mov cl,10 ;multiply by 1024 - global N_LXLSH@:near -N_LXLSH@: ifndef NO386 shld dx,ax,cl shl ax,cl ; (kbytes -> bytes) else + global N_LXLSH@:near +N_LXLSH@: mov ch,0 @@lp: shl ax,1 @@ -141,7 +138,8 @@ ; jnz @@ok ; jmp memtop_cmos -rdcmos17: mov al,18h ; read bytes 17-18 from CMOS +rdcmos17: cli + mov al,18h ; read bytes 17-18 from CMOS call @@rdcmos mov ah,al mov al,17h diff -r eb2ccd9e093c -r 04feaffdc0d9 linld/stuff/src/XMM.ASM --- a/linld/stuff/src/XMM.ASM Sun Nov 05 22:04:17 2017 +0100 +++ b/linld/stuff/src/XMM.ASM Sat Nov 11 10:57:19 2017 +0100 @@ -38,7 +38,7 @@ ;*************************************************************** ;Call xmm driver addr or 0 if no xmm -;void xmm_driver() +;void xmm_driver(ah) ;*************************************************************** global xmm_driver:near proc xmm_driver near @@ -46,7 +46,7 @@ push si mov si,offset xmm_handler ifndef NO386 - cmp [si],0 + cmp [dword si],0 else mov ax,[word si] or ax,[word si+2] @@ -54,14 +54,14 @@ jne @@gotit xchg ax,cx ; save cmd - mov ax,4300h + mov ax,4300h ; installation check in al int 2fh mov bx,offset xmm_fail push cs pop es cmp al,80h jne @@err - mov ax,4310h + mov ax,4310h ; get driver address in es:bx int 2fh @@err: xchg ax,cx ; restore cmd @@ -70,6 +70,7 @@ pop [dword si] @@gotit: call [dword si] + dec ax ; Z=1=OK pop si ret xmm_fail: @@ -80,21 +81,22 @@ endp xmm_driver +struc image_himem ;struct image_himem { +fd dw ? ; 0 int fd; +fallback dd ? ; 2 u32 fallback; +size dd ? ; 6 u32 size; +remaining dd ? ;10 u32 remaining; +buf dd ? ;14 u32 buf; +bufv dw ? ;18 u32 *bufv; +errmsg dw ? ;20 char *errmsg; +chunk_size dd ? ;22 u32 chunk_size; +next_chunk dw ? ;26 void (*next_chunk)(struct image_himem *); +state dw ? ;28 u16 state; +fd2close dw ? ;30 u16 fd2close; +ends ;}; + ;*************************************************************** ;void xmm_alloc(struct image_himem *m) -;struct image_himem { -; 0 int fd; -; 2 u32 fallback; -; 6 u32 size; -;10 u32 remaining; -;14 u32 buf; -;18 u32 *bufv; -;20 char *errmsg; -;22 u32 chunk_size; -;26 void (*next_chunk)(struct image_himem *); -;28 u16 state; -;30 u16 fd2close; -;}; ;*************************************************************** global _xmm_alloc:near proc _xmm_alloc near @@ -104,35 +106,35 @@ push bx push ax ifndef NO386 - mov edx,[bx+6] ; m->size - dec edx + mov edx,[(image_himem bx).size] ; m->size + ;dec edx shr edx,10 ; to Kb else - mov ax,[bx+6] ; lo m->size - mov dx,[bx+8] ; hi m->size - sub ax,1 - sbb dx,0 - mov cl,10 - extrn N_LXURSH@:near - call N_LXURSH@ + ;mov ax,-1 + ;cwd + ;add ax,[word (image_himem bx).size] ; lo m->size + ;adc dx,[word (image_himem bx+2).size] ; hi m->size + mov ax,[word (image_himem bx).size] ; lo m->size + mov dx,[word (image_himem bx+2).size] ; hi m->size + mov cl,16-10 + extrn N_LXLSH@:near + call N_LXLSH@ endif inc dx push bx - mov ah,09h ;allocate blk + mov ah,09h ;allocate blk of DX kilobytes call xmm_driver ; - dec ax jnz @@goerr ;now: dx=handle of the blk mov ah,0Ch ;lock blk call xmm_driver ; - dec ax ;now: dx:bx=addr of blk xchg ax,bx @@goerr: pop bx jnz @@err - mov [bx+14],ax ; lo m->buf - mov [bx+16],dx ; hi m->buf + mov [word (image_himem bx).buf],ax ; lo m->buf + mov [word (image_himem bx+2).buf],dx ; hi m->buf @@err: ret diff -r eb2ccd9e093c -r 04feaffdc0d9 linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Sun Nov 05 22:04:17 2017 +0100 +++ b/linld/stuff/src/_BEG.ASM Sat Nov 11 10:57:19 2017 +0100 @@ -151,9 +151,9 @@ check_rm_paging: ; It's a 386 in real mode, chk for paging (crazy but possible) p386 - mov edx,cr0 - shl edx,1 ;CR0_PG to CF - jc no_vcpi + mov eax,cr0 + inc eax ;CR0_PG to S + js no_vcpi endcpu: p8086 @@ -175,6 +175,14 @@ xchg ax,bx mov [bx+si],bh ; set eos argbuild: + ;ifdef DEBUG + p386 + pusha + mov bx,si + extrn puts:near + call puts + popa + ;endif mov bx,2 ; argc * 2 argeos: mov dl,1 ; look for a start of string