wok-current diff linld/stuff/src/CRTL.ASM @ rev 19546
linld/tazboot: default conf in tazboot.cmd
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 06 18:49:44 2016 +0100 (2016-12-06) |
parents | 7f92b23984dc |
children | e428345df29a |
line diff
1.1 --- a/linld/stuff/src/CRTL.ASM Fri Dec 02 12:37:59 2016 +0100 1.2 +++ b/linld/stuff/src/CRTL.ASM Tue Dec 06 18:49:44 2016 +0100 1.3 @@ -12,17 +12,18 @@ 1.4 1.5 segment _DATA byte public use16 'DATA' 1.6 1.7 -msg_hang db "High mem corrupted - not exiting to DOS",0 1.8 + global _heap_top:word 1.9 + extrn _bss_end 1.10 +_heap_top dw _bss_end 1.11 +msg_hang db "High mem corrupted - not exiting to DOS" 1.12 +msg_crlf db 13,10,0 1.13 vcpi_alloc_err db "vcpi " 1.14 msg_malloc db "malloc() failure",0 1.15 -msg_crlf db 13,10,0 1.16 1.17 ends _DATA 1.18 1.19 segment _BSS byte public use16 'BSS' 1.20 1.21 - global _heap_top:word 1.22 -_heap_top dw ? 1.23 global _no_exit:byte 1.24 _no_exit db ? 1.25 filecnt db ? ; in fact 0 minus file count... 1.26 @@ -187,21 +188,19 @@ 1.27 1.28 1.29 ;*************************************************************** 1.30 -;int open(const char* name, int flags); 1.31 +;int open(const char* name, int flags=O_RDONLY); 1.32 ;*************************************************************** 1.33 global _open:near 1.34 proc _open near 1.35 1.36 - pop cx ;caller return address 1.37 + pop ax ;caller return address 1.38 pop bx ; name 1.39 - pop ax ; flags 1.40 + push bx 1.41 push ax 1.42 - push bx 1.43 - push cx 1.44 - global open:near ; open(bx,al) 1.45 + global open:near ; open(bx) 1.46 open: 1.47 mov dx,bx 1.48 - mov ah,3dh 1.49 + mov ax,3d00h 1.50 dos: 1.51 int 21h 1.52 chkc: 1.53 @@ -431,6 +430,19 @@ 1.54 1.55 endp _die 1.56 1.57 +struc image_himem ;struct image_himem { 1.58 +fd dw ? ; 0 int fd; 1.59 +fallback dd ? ; 2 u32 fallback; 1.60 +size dd ? ; 6 u32 size; 1.61 +remaining dd ? ;10 u32 remaining; 1.62 +buf dd ? ;14 u32 buf; 1.63 +bufv dw ? ;18 u32 *bufv; 1.64 +errmsg dw ? ;20 char *errmsg; 1.65 +chunk_size dd ? ;22 u32 chunk_size; 1.66 +next_chunk dw ? ;26 void (*next_chunk)(struct image_himem *); 1.67 +state dw ? ;28 u16 state; 1.68 +fd2close dw ? ;30 u16 fd2close; 1.69 +ends ;}; 1.70 1.71 ;*************************************************************** 1.72 ;u32* malloc_bufv_or_die(struct image_himem *m); 1.73 @@ -444,7 +456,7 @@ 1.74 push bx 1.75 push si 1.76 xchg ax,si 1.77 - mov ecx,[si+6] ; m->size 1.78 + mov ecx,[(image_himem si).size] 1.79 dec ecx 1.80 shr ecx,12 1.81 inc cx ; cnt = (m->size+PAGE_MASK)/PAGE_SIZE; 1.82 @@ -457,7 +469,7 @@ 1.83 pop cx 1.84 push cx ; _sort:nel 1.85 push ax ; _sort:base 1.86 - mov [si+18],ax ; m->bufv 1.87 + mov [(image_himem si).bufv],ax 1.88 xchg ax,bx 1.89 @@vcpi_alloc: 1.90 xor edx,edx 1.91 @@ -489,8 +501,8 @@ 1.92 shl bx,2 1.93 add bx,ax ; m->bufv 1.94 mov edx,[bx] ; m->bufv[i] 1.95 - sub edx,[si+2] ; m->fallback 1.96 - cmp edx,[si+6] ; m->size 1.97 + sub edx,[(image_himem si).fallback] 1.98 + cmp edx,[(image_himem si).size] 1.99 jae @@chknext 1.100 shr edx,12 1.101 cmp dx,cx 1.102 @@ -524,7 +536,7 @@ 1.103 push bx 1.104 push si di 1.105 xchg ax,di 1.106 - mov bx,[di] ; m->fd 1.107 + mov bx,[(image_himem di).fd] 1.108 call close 1.109 ifndef NO386 1.110 xor eax,eax 1.111 @@ -532,8 +544,8 @@ 1.112 xor ax,ax 1.113 endif 1.114 cwd 1.115 - mov [di],ax ; m->fd 1.116 - mov bx,[di+28] ; m->state 1.117 + mov [(image_himem di).fd],ax 1.118 + mov bx,[(image_himem di).state] 1.119 cmp al,[bx] ; "" 1.120 jz @@end 1.121 mov si,bx 1.122 @@ -546,16 +558,15 @@ 1.123 jnz @@scan 1.124 dec cx 1.125 @@eos: 1.126 - mov [di+28],cx ; m->state 1.127 + mov [(image_himem di).state],cx 1.128 dec si 1.129 push [word si] 1.130 mov [byte si],dl ; set temp eos 1.131 - xchg ax,dx ; O_RDONLY 1.132 call open 1.133 pop [word si] ; restore string 1.134 jc @@die 1.135 - mov [di],ax ; m->fd 1.136 - mov [di+30],ax ; m->fd2close 1.137 + mov [(image_himem di).fd],ax 1.138 + mov [(image_himem di).fd2close],ax 1.139 mov dx,2 ; SEEK_END 1.140 xchg ax,bx 1.141 ifndef NO386 1.142 @@ -566,9 +577,9 @@ 1.143 endif 1.144 call lseek 1.145 @@die: 1.146 - mov bx,[di+20] ; m->errmsg 1.147 + mov bx,[(image_himem di).errmsg] 1.148 jc die 1.149 - mov bx,[di] ; m->fd 1.150 + mov bx,[(image_himem di).fd] 1.151 ifndef NO386 1.152 push eax 1.153 xor ecx,ecx 1.154 @@ -576,7 +587,7 @@ 1.155 call lseek ; rewind 1.156 pop eax 1.157 @@end: 1.158 - mov [di+22],eax ; m->chunk_size 1.159 + mov [(image_himem di).chunk_size],eax 1.160 else 1.161 push ax 1.162 push dx 1.163 @@ -587,8 +598,8 @@ 1.164 pop dx 1.165 pop ax 1.166 @@end: 1.167 - mov [di+22],ax ; m->chunk_size 1.168 - mov [di+24],dx 1.169 + mov [word (image_himem di).chunk_size],ax 1.170 + mov [word ((image_himem di).chunk_size)+2],dx 1.171 endif 1.172 pop di si 1.173 ret 1.174 @@ -598,19 +609,6 @@ 1.175 1.176 ;*************************************************************** 1.177 ;void open_image(const char *name, struct image_himem *m); 1.178 -;struct image_himem { 1.179 -; 0 int fd; 1.180 -; 2 u32 fallback; 1.181 -; 6 u32 size; 1.182 -;10 u32 remaining; 1.183 -;14 u32 buf; 1.184 -;18 u32 *bufv; 1.185 -;20 char *errmsg; 1.186 -;22 u32 chunk_size; 1.187 -;26 void (*next_chunk)(struct image_himem *); 1.188 -;28 u16 state; 1.189 -;30 u16 fd2close; 1.190 -;}; 1.191 ;*************************************************************** 1.192 global _open_image:near 1.193 proc _open_image near 1.194 @@ -627,25 +625,25 @@ 1.195 xor ax,ax ; 1st loop flag + eos 1.196 endif 1.197 mov di,[m] 1.198 - cmp [di],ax ; m->fd 1.199 + cmp [(image_himem di).fd],ax 1.200 jnz @@alreadydone 1.201 ifndef NO386 1.202 - mov [di+6],eax ; m->size = 0L 1.203 + mov [(image_himem di).size],eax ; m->size = 0L 1.204 else 1.205 - mov [di+6],ax ; m->size = 0L 1.206 - mov [di+8],ax 1.207 + mov [word (image_himem di).size],ax ; m->size = 0L 1.208 + mov [word ((image_himem di).size)+2],ax 1.209 endif 1.210 - mov [word di+26],offset _next_chunk 1.211 + mov [(image_himem di).next_chunk],offset _next_chunk 1.212 mov si,[fname] 1.213 - mov [di+28],si ; m->state 1.214 + mov [(image_himem di).state],si 1.215 @@next: 1.216 push di 1.217 - call [word di+26] ; m->next_chunk() 1.218 + call [(image_himem di).next_chunk] ; m->next_chunk() 1.219 pop di 1.220 ifndef NO386 1.221 add eax,3 1.222 and al,0FCh 1.223 - add [di+6],eax ; m->size += m->chunk_size 1.224 + add [(image_himem di).size],eax ; m->size += m->chunk_size 1.225 or eax,eax 1.226 jnz @@next 1.227 else 1.228 @@ -654,14 +652,14 @@ 1.229 add ax,3 1.230 adc dx,0 1.231 and al,0FCh 1.232 - add [di+6],ax ; m->size += m->chunk_size 1.233 - adc [di+8],dx 1.234 + add [word (image_himem di).size],ax ; m->size += m->chunk_size 1.235 + adc [word ((image_himem di).size)+2],dx 1.236 inc cx ; jcxnz 1.237 loop @@next 1.238 endif 1.239 - mov [di+28],si ; m->state 1.240 + mov [(image_himem di).state],si 1.241 push di 1.242 - call [word di+26] ; m->next_chunk() 1.243 + call [(image_himem di).next_chunk] ; m->next_chunk() 1.244 pop di 1.245 @@alreadydone: 1.246 push ax 1.247 @@ -698,17 +696,17 @@ 1.248 xor ecx,ecx 1.249 mov cx,[word sz] 1.250 @@chksz: 1.251 - mov eax,[di+22] ; m->chunk_size 1.252 + mov eax,[(image_himem di).chunk_size] 1.253 cmp ecx,eax 1.254 jb @@szok 1.255 xchg eax,ecx 1.256 else 1.257 mov cx,[word sz] 1.258 @@chksz: 1.259 - mov ax,[di+22] ; lo m->chunk_size 1.260 + mov ax,[word (image_himem di).chunk_size] 1.261 cmp cx,ax 1.262 jb @@szok 1.263 - cmp [word di+24],0 ; hi m->chunk_size 1.264 + cmp [word ((image_himem di).chunk_size)+2],0 ; hi m->chunk_size 1.265 jne @@szok 1.266 xchg ax,cx 1.267 endif 1.268 @@ -727,13 +725,13 @@ 1.269 ifndef NO386 1.270 cwde ; ax < 8000h 1.271 cwd 1.272 - sub [di+22],eax 1.273 + sub [(image_himem di).chunk_size],eax 1.274 else 1.275 cwd ; ax < 8000h 1.276 - sub [di+22],ax 1.277 - sbb [di+24],dx 1.278 + sub [word (image_himem di).chunk_size],ax 1.279 + sbb [word ((image_himem di).chunk_size)+2],dx 1.280 jnz @@fill 1.281 - cmp [di+22],dx 1.282 + cmp [word (image_himem di).chunk_size],dx 1.283 endif 1.284 jnz @@fill 1.285 dec cx 1.286 @@ -746,16 +744,16 @@ 1.287 jmp @@fill 1.288 @@filled: 1.289 ifndef NO386 1.290 - sub [di+10],eax ; m->remaining 1.291 + sub [(image_himem di).remaining],eax 1.292 else 1.293 - sub [di+10],ax ; m->remaining 1.294 - sbb [di+12],dx 1.295 + sub [word (image_himem di).remaining],ax 1.296 + sbb [word ((image_himem di).remaining)+2],dx 1.297 endif 1.298 add [bp-4-2],ax 1.299 add [word data],ax 1.300 sub [word sz],ax 1.301 pushf 1.302 - and cx,[di+26] ; m->next_chunk 1.303 + and cx,[(image_himem di).next_chunk] 1.304 jz @@same_chunk 1.305 push di 1.306 call cx ; m->next_chunk()