wok rev 20528
linld: pascal convention calls
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Nov 09 16:37:55 2018 +0100 (2018-11-09) |
parents | 17c0ad41f5bf |
children | 1e49fb3e5dd0 |
files | linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.H linld/stuff/src/HIMEM.CPP linld/stuff/src/ISO9660.CPP linld/stuff/src/ISO9660.H linld/stuff/src/JUMP.ASM linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/MEMTOP.ASM linld/stuff/src/TAZBOOT.CPP linld/stuff/src/XMM.ASM linld/stuff/src/_BEG.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/stuff/src/COMMON.H Thu Nov 08 23:37:09 2018 +0100 1.2 +++ b/linld/stuff/src/COMMON.H Fri Nov 09 16:37:55 2018 +0100 1.3 @@ -56,10 +56,10 @@ 1.4 extern int skip_alloc; 1.5 extern u32 base_himem; 1.6 1.7 -extern "C" void memcpy_image(struct image_himem *m); 1.8 -extern "C" void storepage(u32 *dst, u16 src); 1.9 +extern pascal void memcpy_image(struct image_himem *m); 1.10 +extern pascal void storepage(u32 *dst, u16 src); 1.11 #ifdef LARGE_IMAGES 1.12 -extern "C" void reset_bufv(unsigned long *p); 1.13 +extern pascal void reset_bufv(unsigned long *p); 1.14 extern "C" unsigned long* prev_bufv(); 1.15 extern "C" unsigned long* next_bufv(); 1.16 #define next(p) p = next_bufv() 1.17 @@ -73,10 +73,10 @@ 1.18 extern const char* kernel_name; 1.19 extern const char* initrd_name; 1.20 extern const char* cmdline; 1.21 -extern u16 root_dev; 1.22 -extern u16 vid_mode; 1.23 +extern u32 root_dev; 1.24 +extern u32 vid_mode; 1.25 // External asm helpers 1.26 -extern "C" void xmm_alloc(struct image_himem *m); 1.27 +extern pascal void xmm_alloc(struct image_himem *m); 1.28 extern u32 topmem; 1.29 extern "C" u32 memtop(); 1.30 extern "C" void enable_a20_or_die(); 1.31 @@ -89,8 +89,8 @@ 1.32 #endif 1.33 1.34 void load_image(struct image_himem *m); 1.35 -extern "C" void open_image(const char *name, struct image_himem *m); 1.36 -extern "C" int read_image(struct image_himem *m, void* data, int sz); 1.37 +extern pascal void open_image(const char *name, struct image_himem *m); 1.38 +extern pascal int read_image(struct image_himem *m, void* data, int sz); 1.39 char* load_kernel(); 1.40 void load_initrd(); 1.41 extern "C" void boot_kernel();
2.1 --- a/linld/stuff/src/CRTL.ASM Thu Nov 08 23:37:09 2018 +0100 2.2 +++ b/linld/stuff/src/CRTL.ASM Fri Nov 09 16:37:55 2018 +0100 2.3 @@ -47,29 +47,27 @@ 2.4 segment _TEXT byte public use16 'CODE' 2.5 2.6 ;*************************************************************** 2.7 -;char* strcpy(const char* a, const char* b); 2.8 -;char* strcat(const char* a, const char* b); 2.9 -;char* strcatb(const char* a, const char* b); 2.10 +;pascal void strcpy(const char* a, const char* b); 2.11 +;pascal void strcat(const char* a, const char* b); 2.12 +;pascal void strcatb(const char* a, const char* b); 2.13 ;*************************************************************** 2.14 - global _strcatb:near 2.15 - proc _strcatb near 2.16 + global @strcatb$qpxzct1:near 2.17 + proc @strcatb$qpxzct1 near 2.18 2.19 ifdef EXTRA 2.20 mov cl,7Fh 2.21 db 0bbh ; mov bx,imm opcode 2.22 - global _strcat:near 2.23 -_strcat: 2.24 + global @strcat$qpxzct1:near 2.25 +@strcat$qpxzct1: 2.26 mov cl,80h 2.27 db 0bbh ; mov bx,imm opcode 2.28 - global _strcpy:near 2.29 -_strcpy: 2.30 + global @strcpy$qpxzct1:near 2.31 +@strcpy$qpxzct1: 2.32 xor cx,cx 2.33 endif 2.34 pop ax ;caller return address 2.35 + pop bx ; b 2.36 pop dx ; a 2.37 - pop bx ; b 2.38 - push bx 2.39 - push dx 2.40 push ax 2.41 push si 2.42 mov si,dx 2.43 @@ -102,22 +100,20 @@ 2.44 pop si 2.45 ret 2.46 2.47 - endp _strcatb 2.48 + endp @strcatb$qpxzct1 2.49 2.50 2.51 ifdef EXTRA 2.52 p8086 2.53 ;*************************************************************** 2.54 -;char strstr(const char* a,const char* b); 2.55 +;pascal char strstr(const char* a,const char* b); 2.56 ;*************************************************************** 2.57 - global _strstr:near 2.58 - proc _strstr near 2.59 + global @strstr$qpxzct1:near 2.60 + proc @strstr$qpxzct1 near 2.61 2.62 pop ax ;caller return address 2.63 + pop cx ; b 2.64 pop dx ; a 2.65 - pop cx ; b 2.66 - push cx 2.67 - push dx 2.68 push ax 2.69 push si 2.70 @@loop: 2.71 @@ -136,20 +132,18 @@ 2.72 inc dx 2.73 jmp @@loop 2.74 2.75 - endp _strstr 2.76 + endp @strstr$qpxzct1 2.77 2.78 2.79 ;*************************************************************** 2.80 -;int strcmp(const char* a,const char* b); 2.81 +;pascal int strcmp(const char* a,const char* b); 2.82 ;*************************************************************** 2.83 - global _strcmp:near 2.84 - proc _strcmp near 2.85 + global @strcmp$qpxzct1:near 2.86 + proc @strcmp$qpxzct1 near 2.87 2.88 pop cx ;caller return address 2.89 + pop ax ; b 2.90 pop bx ; a 2.91 - pop ax ; b 2.92 - push ax 2.93 - push bx 2.94 push cx 2.95 push si 2.96 xchg ax,si 2.97 @@ -166,19 +160,18 @@ 2.98 pop si 2.99 ret 2.100 2.101 - endp _strcmp 2.102 + endp @strcmp$qpxzct1 2.103 endif 2.104 2.105 2.106 ;*************************************************************** 2.107 -;void puts(const char* s): 2.108 +;pascal void puts(const char* s): 2.109 ;*************************************************************** 2.110 - global _puts:near 2.111 - proc _puts near 2.112 + global @puts$qpxzc:near 2.113 + proc @puts$qpxzc near 2.114 2.115 pop ax ;caller return address 2.116 pop bx ; s 2.117 - push bx 2.118 push ax 2.119 ; global puts:near ; puts(bx) 2.120 puts: 2.121 @@ -195,36 +188,34 @@ 2.122 jne @@putcz ; ZF=1 (for malloc failure) 2.123 ret 2.124 2.125 - endp _puts 2.126 + endp @puts$qpxzc 2.127 2.128 2.129 ;*************************************************************** 2.130 -;int fileattr(const char* name); 2.131 +;pascal int fileattr(const char* name); 2.132 ;*************************************************************** 2.133 - global _fileattr:near 2.134 - proc _fileattr near 2.135 + global @fileattr$qpxzc:near 2.136 + proc @fileattr$qpxzc near 2.137 2.138 pop ax ;caller return address 2.139 pop dx ; name 2.140 - push dx 2.141 push ax 2.142 mov ax,4300h 2.143 int 21h 2.144 xchg ax,cx 2.145 jmp chkc 2.146 2.147 - endp _fileattr 2.148 + endp @fileattr$qpxzc 2.149 2.150 2.151 ;*************************************************************** 2.152 -;int open(const char* name, int flags=O_RDONLY); 2.153 +;pascal int open(const char* name, int flags=O_RDONLY); 2.154 ;*************************************************************** 2.155 - global _open:near 2.156 - proc _open near 2.157 + global @open$qpxzc:near 2.158 + proc @open$qpxzc near 2.159 2.160 pop ax ;caller return address 2.161 pop bx ; name 2.162 - push bx 2.163 push ax 2.164 global open:near ; open(bx) 2.165 open: 2.166 @@ -246,18 +237,25 @@ 2.167 endif 2.168 ret 2.169 2.170 - endp _open 2.171 + global openargs:near ; openargs(bx) 2.172 +openargs: 2.173 + cmp [byte bx],'@' 2.174 + stc 2.175 + jne fail 2.176 + inc bx 2.177 + jmp open 2.178 + 2.179 + endp @open$qpxzc 2.180 2.181 2.182 ;*************************************************************** 2.183 -;int close(int fd); 2.184 +;pascal int close(int fd); 2.185 ;*************************************************************** 2.186 - global _close:near 2.187 - proc _close near 2.188 + global @close$qi:near 2.189 + proc @close$qi near 2.190 2.191 pop ax ;caller return address 2.192 pop bx ; fd 2.193 - push bx 2.194 push ax 2.195 global close:near ; close(bx) 2.196 close: 2.197 @@ -266,56 +264,53 @@ 2.198 jnz dos 2.199 ret 2.200 2.201 - endp _close 2.202 + endp @close$qi 2.203 2.204 2.205 ;*************************************************************** 2.206 -;int read(int fd, void* data, int sz); 2.207 -;int write(int fd, const void* data, int sz); 2.208 +;pascal int read(int fd, void* data, int sz); 2.209 +;pascal int write(int fd, const void* data, int sz); 2.210 ;*************************************************************** 2.211 - global _read:near 2.212 - proc _read near 2.213 + global @read$qipvi:near 2.214 + proc @read$qipvi near 2.215 2.216 ifdef WRITE 2.217 stc 2.218 db 0B0h ; mov al,im 2.219 - global _write:near 2.220 + global @write$qipvi:near 2.221 +@write$qipvi: 2.222 clc 2.223 endif 2.224 pop ax ;caller return address 2.225 + pop cx ; sz 2.226 + pop dx ; data 2.227 pop bx ; fd 2.228 - pop dx ; data 2.229 - pop cx ; sz 2.230 - push cx 2.231 - push dx 2.232 - push bx 2.233 push ax 2.234 ifdef WRITE 2.235 mov ah,40h 2.236 sbb ah,0 2.237 else 2.238 + global @read$cxdxbx:near 2.239 +@read$cxdxbx: 2.240 mov ah,3Fh 2.241 endif 2.242 jcxz fail 2.243 jmp dos 2.244 2.245 - endp _read 2.246 + endp @read$qipvi 2.247 2.248 - proc _lseekset near 2.249 ;ifdef EXTRA 2.250 ;*************************************************************** 2.251 -;long lseekset(int fd, unsigned long sz); 2.252 +;pascal long lseekset(int fd, unsigned long sz); 2.253 ;*************************************************************** 2.254 2.255 - global _lseekset:near 2.256 + global @lseekset$qiul:near 2.257 + proc @lseekset$qiul near 2.258 2.259 pop ax ;caller return address 2.260 - pop bx ; fd 2.261 pop dx ; sz lo 2.262 pop cx ; sz hi 2.263 - push cx 2.264 - push dx 2.265 - push bx 2.266 + pop bx ; fd 2.267 push ax 2.268 ;endif 2.269 ; global lseekset:near 2.270 @@ -332,7 +327,7 @@ 2.271 xor cx,cx 2.272 jmp dos 2.273 2.274 - endp _lseekset 2.275 + endp @lseekset$qiul 2.276 2.277 ifdef EXTRA 2.278 struc isostate ; struct isostate { 2.279 @@ -348,36 +343,36 @@ 2.280 curpos dd ? ;28 unsigned long curpos; 2.281 ends ; } isostate; 2.282 ;*************************************************************** 2.283 -;unsigned long isolseek(const unsigned long *offset); 2.284 +;pascal int isolseek(const unsigned long *offset); 2.285 ;*************************************************************** 2.286 - global _isolseek:near 2.287 - proc _isolseek near 2.288 + global @isolseek$qpxul:near 2.289 + proc @isolseek$qpxul near 2.290 2.291 pop ax 2.292 pop bx 2.293 - push bx 2.294 push ax 2.295 mov dx,[bx] 2.296 mov cx,[bx+2] 2.297 extrn _isostate:isostate 2.298 mov bx,[_isostate.fd] 2.299 - jmp lseekset ; (bx=fd, sz=cx:dx) 2.300 + call lseekset ; (bx=fd, sz=cx:dx) 2.301 + and ax,dx 2.302 + inc ax 2.303 + ret 2.304 2.305 - endp _isolseek 2.306 + endp @isolseek$qpxul 2.307 endif 2.308 2.309 2.310 ;*************************************************************** 2.311 -;int strhead(const char* a,const char* b); 2.312 +;pascal int strhead(const char* a,const char* b); 2.313 ;*************************************************************** 2.314 - global _strhead:near 2.315 - proc _strhead near 2.316 + global @strhead$qpxzct1:near 2.317 + proc @strhead$qpxzct1 near 2.318 2.319 pop cx ;caller return address 2.320 + pop ax ; b 2.321 pop bx ; a 2.322 - pop ax ; b 2.323 - push ax 2.324 - push bx 2.325 push cx 2.326 @@loop: 2.327 xchg ax,bx 2.328 @@ -392,18 +387,17 @@ 2.329 jz @@loop 2.330 ret ; return b (is not 0) 2.331 2.332 - endp _strhead 2.333 + endp @strhead$qpxzct1 2.334 2.335 2.336 ;*************************************************************** 2.337 -;char* malloc_or_die(unsigned size); 2.338 +;pascal char* malloc_or_die(unsigned size); 2.339 ;*************************************************************** 2.340 - global _malloc_or_die:near 2.341 - proc _malloc_or_die near 2.342 + global @malloc_or_die$qui:near 2.343 + proc @malloc_or_die$qui near 2.344 2.345 pop ax ;caller return address 2.346 pop cx ; size 2.347 - push cx 2.348 push ax 2.349 global malloc_or_die:near ; malloc_or_die(cx) 2.350 malloc_or_die: 2.351 @@ -417,20 +411,19 @@ 2.352 add [_heap_top],cx ; _BEG has zero'd heap 2.353 ret 2.354 2.355 - endp _malloc_or_die 2.356 + endp @malloc_or_die$qui 2.357 2.358 2.359 ;*************************************************************** 2.360 -;int die(const char* msg); 2.361 +;pascal int die(const char* msg); 2.362 ;int exit(); 2.363 ;int abort(); 2.364 ;*************************************************************** 2.365 - global _die:near 2.366 - proc _die near 2.367 - 2.368 + global @die$qpxzc:near 2.369 + proc @die$qpxzc near 2.370 +@die$qpxzc: 2.371 pop ax ;caller return address 2.372 pop bx ; s 2.373 - ;push bx 2.374 ;push ax 2.375 global die:near ; die(bx) 2.376 die: 2.377 @@ -453,7 +446,7 @@ 2.378 hlt 2.379 jmp @@stop 2.380 2.381 - endp _die 2.382 + endp @die$qpxzc 2.383 2.384 struc image_himem ;struct image_himem { 2.385 fd dw ? ; 0 int fd; 2.386 @@ -546,15 +539,14 @@ 2.387 endif 2.388 2.389 ;*************************************************************** 2.390 -;u32* malloc_bufv_or_die(struct image_himem *m); 2.391 +;pascal u32* malloc_bufv_or_die(struct image_himem *m); 2.392 ;*************************************************************** 2.393 - global _malloc_bufv_or_die:near 2.394 - proc _malloc_bufv_or_die near 2.395 + global @malloc_bufv_or_die$qp11image_himem:near 2.396 + proc @malloc_bufv_or_die$qp11image_himem near 2.397 2.398 p386 2.399 pop bx ;caller return address 2.400 pop ax 2.401 - push ax 2.402 push bx 2.403 push si 2.404 xchg ax,si 2.405 @@ -666,18 +658,17 @@ 2.406 p8086 2.407 endif 2.408 2.409 - endp _malloc_bufv_or_die 2.410 + endp @malloc_bufv_or_die$qp11image_himem 2.411 2.412 2.413 ;*************************************************************** 2.414 -; void memcpy_image(struct image_himem *m); 2.415 +;pascal void memcpy_image(struct image_himem *m); 2.416 ;*************************************************************** 2.417 - global _memcpy_image:near 2.418 - proc _memcpy_image near 2.419 + global @memcpy_image$qp11image_himem:near 2.420 + proc @memcpy_image$qp11image_himem near 2.421 2.422 pop ax ;caller return address 2.423 pop bx 2.424 - push bx 2.425 push ax 2.426 ifndef NO386 2.427 mov edx,[(image_himem bx).fallback] 2.428 @@ -727,25 +718,22 @@ 2.429 endif 2.430 endif 2.431 @@memcpy: 2.432 - extrn _memcpy32:near 2.433 - call near _memcpy32 2.434 - add sp,14 2.435 + extrn memcpy32:near 2.436 + call near memcpy32 2.437 @@skip: 2.438 ret 2.439 2.440 - endp _memcpy_image 2.441 + endp @memcpy_image$qp11image_himem 2.442 2.443 ;*************************************************************** 2.444 -;void storepage(u32 *dst, u16 src); 2.445 +;pascal void storepage(u32 *dst, u16 src); 2.446 ;*************************************************************** 2.447 - global _storepage:near 2.448 - proc _storepage near 2.449 + global @storepage$qpulus:near 2.450 + proc @storepage$qpulus near 2.451 2.452 pop ax ;caller return address 2.453 + pop cx 2.454 pop bx 2.455 - pop cx 2.456 - push cx 2.457 - push bx 2.458 push ax 2.459 ifndef NO386 2.460 mov edx,[bx] 2.461 @@ -770,26 +758,25 @@ 2.462 push ds 2.463 jmp call_memcpy32 2.464 2.465 - endp _storepage 2.466 + endp @storepage$qpulus 2.467 2.468 2.469 ifdef LARGE_IMAGES 2.470 p386 2.471 ;*************************************************************** 2.472 -;void reset_bufv(u32 *p); 2.473 +;pascal void reset_bufv(u32 *p); 2.474 ;*************************************************************** 2.475 - global _reset_bufv:near 2.476 - proc _reset_bufv near 2.477 + global @reset_bufv$qpul:near 2.478 + proc @reset_bufv$qpul near 2.479 2.480 pop ax ;caller return address 2.481 pop bx 2.482 - push bx 2.483 push ax 2.484 mov [curdata],bx 2.485 and [dword (data_himem bx).cacheidx],0 2.486 ret 2.487 2.488 - endp _reset_bufv 2.489 + endp @reset_bufv$qpul 2.490 2.491 ;*************************************************************** 2.492 ;u32* prev_bufv(); 2.493 @@ -803,12 +790,12 @@ 2.494 db 73h ; jnc 2.495 _next_bufv: 2.496 clc 2.497 + push si 2.498 + mov si,[curdata] 2.499 sbb ax,ax 2.500 cmc 2.501 adc ax,[(data_himem si).cacheidx] ; -1/+1 2.502 xor ecx,ecx 2.503 - push si 2.504 - mov si,[curdata] 2.505 test ax,0fc00h 2.506 jz @@gotpage 2.507 push ax ; FFFF / 0400 2.508 @@ -854,16 +841,14 @@ 2.509 endif 2.510 2.511 ;*************************************************************** 2.512 -;void open_image(const char *name, struct image_himem *m); 2.513 +;pascal void open_image(const char *name, struct image_himem *m); 2.514 ;*************************************************************** 2.515 - global _open_image:near 2.516 - proc _open_image near 2.517 + global @open_image$qpxzcp11image_himem:near 2.518 + proc @open_image$qpxzcp11image_himem near 2.519 2.520 pop cx ;caller return address 2.521 + pop ax ; m 2.522 pop bx ; name 2.523 - pop ax ; m 2.524 - push ax 2.525 - push bx 2.526 push cx 2.527 push di 2.528 xchg ax,di 2.529 @@ -891,37 +876,34 @@ 2.530 pop di 2.531 ret 2.532 2.533 - endp _open_image 2.534 + endp @open_image$qpxzcp11image_himem 2.535 2.536 2.537 ;*************************************************************** 2.538 -;int read_image(struct image_himem *m, char* data, int sz); 2.539 +;pascal int read_image(struct image_himem *m, char* data, int sz); 2.540 ;*************************************************************** 2.541 - global _read_image:near 2.542 - proc _read_image near 2.543 + global @read_image$qp11image_himempvi:near 2.544 + proc @read_image$qp11image_himempvi near 2.545 2.546 - arg m :word, \ 2.547 + arg sz :word, \ 2.548 data :word, \ 2.549 - sz :word = PARAM_SIZE 2.550 + m :word = PARAM_SIZE 2.551 2.552 push bp 2.553 mov bp,sp 2.554 - push di 2.555 - ifndef NO386 2.556 - push 0 ; return value 2.557 - else 2.558 - xor ax,ax 2.559 - push ax 2.560 - endif 2.561 + push si di 2.562 mov di,[m] 2.563 + mov si,[data] 2.564 + mov bp,[sz] 2.565 + push bp ; original size 2.566 @@loop: 2.567 ifndef NO386 2.568 - movzx ecx,[word sz] 2.569 + movzx ecx,bp 2.570 mov eax,[(image_himem di).chunk_size] 2.571 cmp ecx,eax 2.572 jb @@szok 2.573 else 2.574 - mov cx,[word sz] 2.575 + mov cx,bp 2.576 mov ax,[word (image_himem di).chunk_size] 2.577 cmp cx,ax 2.578 jb @@szok 2.579 @@ -931,15 +913,11 @@ 2.580 xchg ax,cx 2.581 @@szok: 2.582 jcxz image_done 2.583 - push cx 2.584 - push [word data] 2.585 - push [word di] 2.586 - call _read 2.587 - pop dx 2.588 - pop bx 2.589 - pop cx 2.590 + mov dx,si 2.591 + mov bx,[word di] 2.592 + call @read$cxdxbx 2.593 jc image_done 2.594 - add bx,ax 2.595 + add si,ax 2.596 xor cx,cx 2.597 ifndef NO386 2.598 cwde ; ax < 8000h 2.599 @@ -952,12 +930,12 @@ 2.600 cmp [word (image_himem di).chunk_size],dx 2.601 endif 2.602 jnz @@fill 2.603 - dec cx 2.604 + inc cx 2.605 @@fill: 2.606 test al,3 2.607 je @@filled 2.608 - mov [bx],dh 2.609 - inc bx 2.610 + mov [si],ch 2.611 + inc si 2.612 inc ax 2.613 jmp @@fill 2.614 @@filled: 2.615 @@ -967,9 +945,7 @@ 2.616 sub [word (image_himem di).remaining],ax 2.617 sbb [word ((image_himem di).remaining)+2],dx 2.618 endif 2.619 - add [bp-2-2],ax 2.620 - add [word data],ax 2.621 - sub [word sz],ax 2.622 + sub bp,ax 2.623 pushf 2.624 jcxz @@same_chunk 2.625 call [(image_himem di).next_chunk] 2.626 @@ -977,24 +953,24 @@ 2.627 popf 2.628 jnz @@loop 2.629 image_done: 2.630 - pop ax 2.631 - pop di bp 2.632 - ret 2.633 + pop ax ; original size 2.634 + sub ax,bp 2.635 + pop di si bp 2.636 + ret 6 2.637 2.638 - endp _read_image 2.639 + endp @read_image$qp11image_himempvi 2.640 2.641 2.642 ;*************************************************************** 2.643 -;unsigned long strtol(const char *s); 2.644 +;pascal unsigned long strtol(const char *s); 2.645 ;*************************************************************** 2.646 - global _strtol:near 2.647 - proc _strtol near 2.648 + global @strtol$qpxzc:near 2.649 + proc @strtol$qpxzc near 2.650 2.651 - ifndef NO386 2.652 pop ax ;caller return address 2.653 pop cx ; s 2.654 - push cx 2.655 push ax 2.656 + ifndef NO386 2.657 xor ebx,ebx 2.658 push si 2.659 jcxz @@end 2.660 @@ -1080,10 +1056,6 @@ 2.661 @@popsiret: 2.662 pop si 2.663 else 2.664 - pop ax ;caller return address 2.665 - pop cx ; s 2.666 - push cx 2.667 - push ax 2.668 push si 2.669 push di 2.670 xor ax,ax 2.671 @@ -1189,9 +1161,10 @@ 2.672 pop di 2.673 pop si 2.674 endif 2.675 +strtol_ret: 2.676 ret 2.677 2.678 - endp _strtol 2.679 + endp @strtol$qpxzc 2.680 2.681 2.682 ifdef NO386 2.683 @@ -1262,14 +1235,13 @@ 2.684 2.685 2.686 ;*************************************************************** 2.687 -;void chdirname(char *path) 2.688 +;pascal void chdirname(char *path) 2.689 ;*************************************************************** 2.690 - global _chdirname:near 2.691 - proc _chdirname near 2.692 + global @chdirname$qpzc:near 2.693 + proc @chdirname$qpzc near 2.694 2.695 pop ax 2.696 pop bx 2.697 - push bx 2.698 push ax 2.699 2.700 cmp [byte bx+1],3Ah ; ':' 2.701 @@ -1308,54 +1280,50 @@ 2.702 @@end: 2.703 ret 2.704 2.705 - endp _chdirname 2.706 + endp @chdirname$qpzc 2.707 2.708 2.709 ;*************************************************************** 2.710 -;char *ultoa(unsigned long n); 2.711 +;pascal char *ultoa(unsigned long n); 2.712 ;*************************************************************** 2.713 - global _ultoa:near 2.714 - proc _ultoa near 2.715 + global @ultoa$qul:near 2.716 + proc @ultoa$qul near 2.717 2.718 + pop dx 2.719 + pop cx 2.720 pop ax 2.721 - pop cx 2.722 - pop dx 2.723 - push dx 2.724 - push cx 2.725 - push ax ; DX:CX = n 2.726 + push dx ; AX:CX = n 2.727 push si 2.728 mov si,10 2.729 mov bx,offset ultoabuf+11 2.730 @@loop: 2.731 dec bx 2.732 - xchg ax,dx 2.733 xor dx,dx 2.734 div si ; DX:AX = 0000:hi(n) 2.735 xchg ax,cx ; CX = hi(n)/10 2.736 div si ; DX:AX = hi(n)%10:lo(n) 2.737 xchg ax,cx ; CX = lo(n/10) 2.738 - xchg ax,dx ; DX = hi(n)/10 = hi(n/10) 2.739 - add al,'0' 2.740 - mov [bx],al 2.741 - mov ax,cx 2.742 - or ax,dx 2.743 + ; AX = hi(n)/10 = hi(n/10) 2.744 + mov [byte bx],'0' 2.745 + add [bx],dl ; DL = n%10 2.746 + mov dx,ax 2.747 + or dx,cx 2.748 jnz @@loop 2.749 xchg ax,bx 2.750 pop si 2.751 ret 2.752 2.753 - endp _ultoa 2.754 + endp @ultoa$qul 2.755 2.756 2.757 ;*************************************************************** 2.758 -;unsigned long kver2ul(char *kernel_version); 2.759 +;pascal unsigned long kver2ul(char *kernel_version); 2.760 ;*************************************************************** 2.761 - global _kver2ul:near 2.762 - proc _kver2ul near 2.763 + global @kver2ul$qpzc:near 2.764 + proc @kver2ul$qpzc near 2.765 2.766 pop bx 2.767 pop ax 2.768 - push ax 2.769 push bx 2.770 push si 2.771 xchg ax,si 2.772 @@ -1381,12 +1349,16 @@ 2.773 kver2ulret: 2.774 ret 2.775 2.776 - endp _kver2ul 2.777 + endp @kver2ul$qpzc 2.778 2.779 + endif 2.780 2.781 ;*************************************************************** 2.782 ;void try_default_args(); 2.783 +;pascal void set_cmdline(const char *filename); 2.784 ;*************************************************************** 2.785 + ifdef EXTRA 2.786 + 2.787 global _try_default_args:near 2.788 proc _try_default_args near 2.789 2.790 @@ -1395,13 +1367,12 @@ 2.791 jc kver2ulret 2.792 mov cx,4096 2.793 mov di,[_heap_top] 2.794 - push cx 2.795 extrn read_cmdline:near 2.796 jmp near read_cmdline ; read_cmdline(ax,di,cx) 2.797 2.798 endp _try_default_args 2.799 2.800 - endif 2.801 + endif 2.802 2.803 ends _TEXT 2.804
3.1 --- a/linld/stuff/src/CRTL.H Thu Nov 08 23:37:09 2018 +0100 3.2 +++ b/linld/stuff/src/CRTL.H Fri Nov 09 16:37:55 2018 +0100 3.3 @@ -5,6 +5,7 @@ 3.4 #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) 3.5 #define FP_SEG(fp) ((unsigned) (void _seg*) (void far*)(fp)) 3.6 #define FP_OFF(fp) ((unsigned) (fp)) 3.7 +#define NULL 0 3.8 3.9 const unsigned MIN_STACK = 0x400; 3.10 const unsigned MAX_MALLOC = 0xF000; 3.11 @@ -26,16 +27,16 @@ 3.12 extern char* heap_top; 3.13 3.14 void parse_cmdline(); 3.15 -extern "C" char* strcatb(const char* a,const char* b); 3.16 -extern "C" int strhead(const char* a,const char* b); 3.17 -extern "C" int fileattr(const char* name); 3.18 +extern pascal void strcatb(const char* a,const char* b); 3.19 +extern pascal int strhead(const char* a,const char* head); 3.20 +extern pascal int fileattr(const char* name); 3.21 //extern "C" int open(const char* name, int flags); 3.22 -extern "C" int open(const char* name); 3.23 -extern "C" int close(int fd); 3.24 -extern "C" int read(int fd, void* data, int sz); 3.25 -extern "C" long lseekset(int fd, unsigned long sz); 3.26 -extern "C" int puts(const char* s); 3.27 -extern "C" unsigned long strtol(const char *s); 3.28 +extern pascal int open(const char* name); 3.29 +extern pascal int close(int fd); 3.30 +extern pascal int read(int fd, void* data, int sz); 3.31 +extern pascal long lseekset(int fd, unsigned long sz); 3.32 +extern pascal int puts(const char* s); 3.33 +extern pascal unsigned long strtol(const char *s); 3.34 3.35 // Extensions 3.36 #define cli() do { asm { cli } } while(0) 3.37 @@ -43,6 +44,9 @@ 3.38 #define int3() do { asm { db 0cch } } while(0) 3.39 #define nop() do { asm { db 90h } } while(0) 3.40 extern char no_exit; 3.41 -extern "C" int die(const char* msg); 3.42 -extern "C" char* malloc_or_die(unsigned size); 3.43 -extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); 3.44 +extern pascal int die(const char* msg); 3.45 +//extern "C" char* malloc_or_die(unsigned size); 3.46 +//extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); 3.47 +extern pascal int malloc_or_die(unsigned size); 3.48 +extern pascal int malloc_bufv_or_die(struct image_himem *m); 3.49 +extern pascal void set_cmdline(const char *filename);
4.1 --- a/linld/stuff/src/CRTLX.H Thu Nov 08 23:37:09 2018 +0100 4.2 +++ b/linld/stuff/src/CRTLX.H Fri Nov 09 16:37:55 2018 +0100 4.3 @@ -1,14 +1,16 @@ 4.4 // This file is distributed under GPL 4.5 // 4.6 -#define NULL 0 4.7 -extern "C" char* strcpy(const char* a,const char* b); 4.8 -extern "C" char* strcat(const char* a,const char* b); 4.9 -extern "C" int strcmp(const char* a,const char* b); 4.10 -extern "C" char* strstr(const char* a,const char* b); 4.11 +extern pascal void strcpy(const char* a,const char* b); 4.12 +extern pascal void strcat(const char* a,const char* b); 4.13 +extern pascal int strcmp(const char* a,const char* b); 4.14 +//extern "C" char* strstr(const char* a,const char* b); 4.15 +extern pascal int strstr(const char* a,const char* b); 4.16 extern "C" char *progname(void); 4.17 -extern "C" void chdirname(char *path); 4.18 -extern "C" unsigned long kver2ul(char *kernel_version); 4.19 -extern "C" char *ultoa(unsigned long n); 4.20 +extern pascal void chdirname(char *path); 4.21 +extern pascal unsigned long kver2ul(char *kernel_version); 4.22 +//extern "C" char *ultoa(unsigned long n); 4.23 +extern pascal int ultoa(unsigned long n); 4.24 extern "C" void try_default_args(); 4.25 extern char cpu_features[]; 4.26 -#define cpuhaslm() (cpu_features[3]&0x20) 4.27 +#define CPUMASKLM (0x20) 4.28 +#define cpuhaslm() (cpu_features[3]&CPUMASKLM)
5.1 --- a/linld/stuff/src/HIMEM.CPP Thu Nov 08 23:37:09 2018 +0100 5.2 +++ b/linld/stuff/src/HIMEM.CPP Fri Nov 09 16:37:55 2018 +0100 5.3 @@ -61,7 +61,7 @@ 5.4 u32* bufv= &buf; 5.5 if(((u16 *)&m->fallback)[1] >= 0x10 && !skip_alloc) { // >= _1m ? 5.6 if(vcpi) { 5.7 - bufv = malloc_bufv_or_die(m); // update m->bufv 5.8 + bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv 5.9 } 5.10 else { 5.11 xmm_alloc(m); // update m->buf
6.1 --- a/linld/stuff/src/ISO9660.CPP Thu Nov 08 23:37:09 2018 +0100 6.2 +++ b/linld/stuff/src/ISO9660.CPP Fri Nov 09 16:37:55 2018 +0100 6.3 @@ -10,7 +10,7 @@ 6.4 6.5 static int readsector(const unsigned long *offset) 6.6 { 6.7 - return (isolseek(offset) != -1 6.8 + return (isolseek(offset) != 0 6.9 && read(isostate.fd, buffer, sizeof(buffer)) >= SECTORSZ); 6.10 } 6.11 6.12 @@ -113,7 +113,7 @@ 6.13 char _64bits = cpuhaslm(); 6.14 struct isostate *x=&isostate; 6.15 6.16 - retry32: 6.17 + do { 6.18 for (s = (char *) filename; *s == '/' ; s++) { 6.19 isoreset(NULL); 6.20 } 6.21 @@ -138,9 +138,6 @@ 6.22 isolseek(&x->fileofs); 6.23 return 0; 6.24 } 6.25 - if (_64bits) { 6.26 - _64bits = 0; 6.27 - goto retry32; 6.28 - } 6.29 + } while ((_64bits ^= CPUMASKLM) == 0); 6.30 return -1; 6.31 }
7.1 --- a/linld/stuff/src/ISO9660.H Thu Nov 08 23:37:09 2018 +0100 7.2 +++ b/linld/stuff/src/ISO9660.H Fri Nov 09 16:37:55 2018 +0100 7.3 @@ -22,7 +22,7 @@ 7.4 #define isofilesize isostate.filesize 7.5 #define isofilemod isostate.filemod 7.6 #define isofilename isostate.filename 7.7 -extern "C" unsigned long isolseek(const unsigned long *offset); 7.8 +extern pascal int isolseek(const unsigned long *offset); 7.9 extern int isoreset(char *name); 7.10 extern int isoopen(const char *name); 7.11 extern int isoreaddir(int restart);
8.1 --- a/linld/stuff/src/JUMP.ASM Thu Nov 08 23:37:09 2018 +0100 8.2 +++ b/linld/stuff/src/JUMP.ASM Fri Nov 09 16:37:55 2018 +0100 8.3 @@ -196,9 +196,8 @@ 8.4 push 1 ; dst ofs hi 8.5 endif 8.6 push di ; dst ofs lo : 64k 8.7 - extrn _memcpy32:near 8.8 - call _memcpy32 8.9 - add sp,14 8.10 + extrn memcpy32:near 8.11 + call memcpy32 8.12 8.13 ifndef noelks 8.14 ifndef NO386
9.1 --- a/linld/stuff/src/LINLD.CPP Thu Nov 08 23:37:09 2018 +0100 9.2 +++ b/linld/stuff/src/LINLD.CPP Fri Nov 09 16:37:55 2018 +0100 9.3 @@ -8,11 +8,12 @@ 9.4 const char* kernel_name = "bzImage"; 9.5 const char* initrd_name; 9.6 const char* cmdline = "auto"; 9.7 -u16 root_dev; 9.8 -u16 vid_mode; // -3 = ask 9.9 - // -2 = Extended VGA 9.10 - // -1 = Normal VGA 9.11 - // n = as "n" was pressed 9.12 +u32 root_dev; 9.13 +u32 vid_mode; // -3 = ask 9.14 + // -2 = Extended VGA 9.15 + // -1 = Normal VGA 9.16 + // n = as "n" was pressed 9.17 +u32 topmem; 9.18 9.19 inline void syntax() { 9.20 die("Syntax:" NL
10.1 --- a/linld/stuff/src/LOAD.CPP Thu Nov 08 23:37:09 2018 +0100 10.2 +++ b/linld/stuff/src/LOAD.CPP Fri Nov 09 16:37:55 2018 +0100 10.3 @@ -140,7 +140,7 @@ 10.4 { 10.5 struct first1k_t *first1k; 10.6 struct kernelparams_t *kernelparams; 10.7 - kernelparams = &(((first1k_t*) (rm_buf = malloc_or_die(_32k)))->params); 10.8 + kernelparams = &(((first1k_t*) (rm_buf = (u8 *)malloc_or_die(_32k)))->params); 10.9 #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) 10.10 { 10.11 u16 rm_seek; 10.12 @@ -177,8 +177,8 @@ 10.13 10.14 // Tell rm loader some info 10.15 10.16 - if(vid_mode) kernelparams->vid_mode = vid_mode; 10.17 - if(root_dev) kernelparams->root_dev = root_dev; 10.18 + if((int)vid_mode) kernelparams->vid_mode = vid_mode; 10.19 + if((int)root_dev) kernelparams->root_dev = root_dev; 10.20 version_string = ""; 10.21 10.22 #if 1
11.1 --- a/linld/stuff/src/MEMCPY32.ASM Thu Nov 08 23:37:09 2018 +0100 11.2 +++ b/linld/stuff/src/MEMCPY32.ASM Fri Nov 09 16:37:55 2018 +0100 11.3 @@ -21,8 +21,8 @@ 11.4 ;*************************************************************** 11.5 ;****** Uses: Flags 11.6 ;*************************************************************** 11.7 - global _memcpy32:near 11.8 - proc _memcpy32 near 11.9 + global memcpy32:near 11.10 + proc memcpy32 near 11.11 11.12 ; rm32,imm16 helper 11.13 macro addzx_e rm,i 11.14 @@ -91,9 +91,8 @@ 11.15 xor si,si 11.16 mov ax,[srcseg] 11.17 xor dx,dx 11.18 - mov cl,4 11.19 - extrn N_LXLSH@:near 11.20 - call near N_LXLSH@ 11.21 + extrn N_LXLSH@4:near 11.22 + call near ptr N_LXLSH@4 11.23 add [word srcofs],ax 11.24 adc [word srcofs+2],dx 11.25 @@2flat: 11.26 @@ -213,7 +212,7 @@ 11.27 mov sp,bp 11.28 pop bp 11.29 endif 11.30 - ret 11.31 + ret 14 11.32 11.33 ;****** Const data ********************************************* 11.34 org $-8 ;save 8 bytes - they are unused anyway 11.35 @@ -226,7 +225,7 @@ 11.36 ; base_med P S D A G ??l_hi base_hi 11.37 ; Pl E W D 11.38 11.39 - endp _memcpy32 11.40 + endp memcpy32 11.41 11.42 ends _TEXT 11.43
12.1 --- a/linld/stuff/src/MEMTOP.ASM Thu Nov 08 23:37:09 2018 +0100 12.2 +++ b/linld/stuff/src/MEMTOP.ASM Fri Nov 09 16:37:55 2018 +0100 12.3 @@ -90,6 +90,10 @@ 12.4 shld dx,ax,cl 12.5 shl ax,cl ; (kbytes -> bytes) 12.6 else 12.7 + db 0A9h ; test ax,04B1h 12.8 + global N_LXLSH@4:near 12.9 +N_LXLSH@4: 12.10 + mov cl,4 12.11 global N_LXLSH@:near 12.12 N_LXLSH@: 12.13 mov ch,0 12.14 @@ -153,7 +157,11 @@ 12.15 cmp dx,cx 12.16 jb @@set 12.17 extrn _topmem:dword 12.18 - mov cx,[word _topmem+2] ; max 256m ? 12.19 + mov cx,[word _topmem+2] 12.20 + inc cx ; jcxnz 12.21 + loop @@topmemset 12.22 + mov ch,10h ; default = max 256m 12.23 +@@topmemset: 12.24 ; Kernel can have trouble with initrd at very high addr: 12.25 ; limit mem top to 256m 12.26 cmp dh,ch
13.1 --- a/linld/stuff/src/TAZBOOT.CPP Thu Nov 08 23:37:09 2018 +0100 13.2 +++ b/linld/stuff/src/TAZBOOT.CPP Fri Nov 09 16:37:55 2018 +0100 13.3 @@ -129,7 +129,7 @@ 13.4 if (isoopen(initrdfilename) >= 0) { 13.5 addinitrd(); 13.6 } 13.7 - if (*init && isolseek(&initrddesc) != -1) { 13.8 + if (*init && isolseek(&initrddesc) != 0) { 13.9 read(x->fd, &x->filemod, 10); // + x->fileofs & x->filesize 13.10 magic = x->filemod; 13.11 x->fileofs &= 0xFFFFL; 13.12 @@ -143,7 +143,7 @@ 13.13 strcatb(buf_cmdline,"mode="); 13.14 strcat(buf_cmdline,mode); 13.15 strcatb(buf_cmdline,"magic="); 13.16 - strcat(buf_cmdline,ultoa(magic)); 13.17 + strcat(buf_cmdline,(char *)ultoa(magic)); 13.18 } 13.19 load_initrds(); 13.20 if (isknoppix) { 13.21 @@ -157,13 +157,15 @@ 13.22 boot_kernel(); 13.23 } 13.24 13.25 -u16 root_dev; 13.26 -u16 vid_mode; 13.27 +u32 root_dev; 13.28 +u32 vid_mode; 13.29 +u32 topmem; 13.30 const char* kernel_name = "bzImage"; 13.31 const char* initrd_name; 13.32 +char* iso; 13.33 + 13.34 int main(int argc, char *argv[]) 13.35 { 13.36 - char *iso = NULL; 13.37 argv[0] = progname(); 13.38 bootiso(argv); // iso ? parsing is /init.exe stuff ! 13.39
14.1 --- a/linld/stuff/src/XMM.ASM Thu Nov 08 23:37:09 2018 +0100 14.2 +++ b/linld/stuff/src/XMM.ASM Fri Nov 09 16:37:55 2018 +0100 14.3 @@ -93,16 +93,15 @@ 14.4 ends ;}; 14.5 14.6 ;*************************************************************** 14.7 -;void xmm_alloc(struct image_himem *m) 14.8 +;pascal void xmm_alloc(struct image_himem *m) 14.9 ;*************************************************************** 14.10 - global _xmm_alloc:near 14.11 - proc _xmm_alloc near 14.12 + global @xmm_alloc$qp11image_himem:near 14.13 + proc @xmm_alloc$qp11image_himem near 14.14 14.15 - ret ; TO BE FIXED 14.16 pop ax 14.17 pop bx 14.18 - push bx 14.19 push ax 14.20 + ret ; TO BE FIXED 14.21 ifndef NO386 14.22 mov edx,[(image_himem bx).size] ; m->size 14.23 ;dec edx 14.24 @@ -138,7 +137,7 @@ 14.25 @@err: 14.26 ret 14.27 14.28 - endp _xmm_alloc 14.29 + endp @xmm_alloc$qp11image_himem 14.30 14.31 ends _TEXT 14.32
15.1 --- a/linld/stuff/src/_BEG.ASM Thu Nov 08 23:37:09 2018 +0100 15.2 +++ b/linld/stuff/src/_BEG.ASM Fri Nov 09 16:37:55 2018 +0100 15.3 @@ -21,9 +21,7 @@ 15.4 endif 15.5 global _vcpi:byte 15.6 _vcpi db 0 15.7 -msg_badmapping db "VCPI: low 640k need 1:1 mapping" 15.8 - global _topmem:dword 15.9 -_topmem dd 10000000h ; max 256m 15.10 +msg_badmapping db "VCPI: low 640k need 1:1 mapping",0 15.11 15.12 ends _DATA 15.13 15.14 @@ -230,25 +228,22 @@ 15.15 push bx ; argc 15.16 ifndef filearg 15.17 mov bx,[di+2] ; argv[1] 15.18 - cmp [byte bx],'@' 15.19 - jne argend 15.20 - inc bx 15.21 - extrn open:near 15.22 - call near open 15.23 + extrn openargs:near 15.24 + call near openargs 15.25 jc argend 15.26 pop bx ; trash argc, argv >> 1Kb ! 15.27 - ifdef EXTRA 15.28 global read_cmdline:near 15.29 - endif 15.30 + pop cx ; sizemax=argv 15.31 read_cmdline: 15.32 - push di 15.33 + mov dx,di 15.34 + push dx 15.35 push ax 15.36 - extrn _read:near 15.37 - call near _read 15.38 + xchg ax,bx 15.39 + extrn @read$cxdxbx:near ; read(fd=bx,buffer=dx,size=cx) 15.40 + call near @read$cxdxbx 15.41 pop bx ; fd for close 15.42 pop si ; si=buffer=argv 15.43 add di,ax 15.44 - pop ax ; trash sizemax=argv 15.45 extrn close:near 15.46 call near close 15.47 jmp argbuild
16.1 --- a/linld/stuff/src/pipehole.awk Thu Nov 08 23:37:09 2018 +0100 16.2 +++ b/linld/stuff/src/pipehole.awk Fri Nov 09 16:37:55 2018 +0100 16.3 @@ -59,6 +59,11 @@ 16.4 print " call near ptr N_LXURSH@4" 16.5 next 16.6 } 16.7 + if (/^ call near ptr N_LXLSH@$/) { 16.8 + print " extrn N_LXLSH@4:near" 16.9 + print " call near ptr N_LXLSH@4" 16.10 + next 16.11 + } 16.12 print s 16.13 } 16.14 s=$0