wok-6.x diff linld/stuff/src/CRTL.ASM @ rev 19634
linld: some fixes for strtoul
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jan 16 10:15:15 2017 +0100 (2017-01-16) |
parents | 23fc786c04e8 |
children | 76087975885f |
line diff
1.1 --- a/linld/stuff/src/CRTL.ASM Sat Dec 24 19:16:59 2016 +0100 1.2 +++ b/linld/stuff/src/CRTL.ASM Mon Jan 16 10:15:15 2017 +0100 1.3 @@ -39,6 +39,7 @@ 1.4 ;*************************************************************** 1.5 ;char* strcpy(const char* a, const char* b); 1.6 ;char* strcat(const char* a, const char* b); 1.7 +;char* strcatb(const char* a, const char* b); 1.8 ;*************************************************************** 1.9 global _strcpy:near 1.10 proc _strcpy near 1.11 @@ -48,7 +49,10 @@ 1.12 global _strcat:near 1.13 _strcat: 1.14 mov dl,1 1.15 -cat: 1.16 + db 0bbh ; mov bx,imm opcode 1.17 + global _strcatb:near 1.18 +_strcatb: 1.19 + mov dl,3 1.20 pop ax ;caller return address 1.21 pop cx ; a 1.22 pop bx ; b 1.23 @@ -86,18 +90,6 @@ 1.24 1.25 1.26 ;*************************************************************** 1.27 -;char* strcatb(const char* a, const char* b); 1.28 -;*************************************************************** 1.29 - global _strcatb:near 1.30 - proc _strcatb near 1.31 - 1.32 - mov dl,3 1.33 - jmp cat 1.34 - 1.35 - endp _strcatb 1.36 - 1.37 - 1.38 -;*************************************************************** 1.39 ;void* malloc(unsigned sz); 1.40 ;*************************************************************** 1.41 global _malloc:near 1.42 @@ -129,7 +121,6 @@ 1.43 1.44 ;*************************************************************** 1.45 ;void puts(const char* s): 1.46 -;void putsz(const char* s): 1.47 ;*************************************************************** 1.48 global _puts:near 1.49 proc _puts near 1.50 @@ -142,14 +133,7 @@ 1.51 puts: 1.52 call putsz 1.53 mov bx,offset msg_crlf 1.54 - jmp putsz 1.55 1.56 - global _putsz:near 1.57 -_putsz: 1.58 - pop ax ;caller return address 1.59 - pop bx ; s 1.60 - push bx 1.61 - push ax 1.62 global putsz:near ; putsz(bx) 1.63 putsz: 1.64 push bx 1.65 @@ -243,7 +227,7 @@ 1.66 proc _read near 1.67 1.68 stc 1.69 - db 73h ; jnc 1.70 + db 0B0h ; mov al,im 1.71 global _write:near 1.72 clc 1.73 pop ax ;caller return address 1.74 @@ -256,7 +240,6 @@ 1.75 push ax 1.76 mov ah,40h 1.77 sbb ah,0 1.78 - clc 1.79 jcxz fail 1.80 jmp dos 1.81 1.82 @@ -280,8 +263,10 @@ 1.83 global lseekset:near 1.84 lseekset: 1.85 clc 1.86 + db 0B0h ; mov al,im 1.87 global rewind:near 1.88 -rewind: ; rewind(bx,C=1) 1.89 +rewind: ; rewind(bx) 1.90 + stc 1.91 mov ax,4200h 1.92 jnc dos 1.93 lseek0: ; lseek0(bx,ax=dir) 1.94 @@ -326,24 +311,23 @@ 1.95 proc _strhead near 1.96 1.97 pop cx ;caller return address 1.98 - pop ax ; a 1.99 - pop bx ; b 1.100 + pop bx ; a 1.101 + pop ax ; b 1.102 + push ax 1.103 push bx 1.104 - push ax 1.105 push cx 1.106 @@loop: 1.107 + xchg ax,bx 1.108 mov cl,[bx] ; cl = *b++ 1.109 inc bx 1.110 or cl,cl ; clear C 1.111 jz fail ; return 0 1.112 xchg ax,bx 1.113 xor cl,[bx] ; cl -= *a++ 1.114 + inc bx 1.115 and cl,0dfh ; case insensitive 1.116 - stc 1.117 - jnz fail ; return -1 1.118 - inc bx 1.119 - xchg ax,bx 1.120 - jmp @@loop 1.121 + jz @@loop 1.122 + ret ; return b (is not 0) 1.123 1.124 endp _strhead 1.125 1.126 @@ -653,12 +637,11 @@ 1.127 global _reset_bufv:near 1.128 proc _reset_bufv near 1.129 1.130 - pop bx ;caller return address 1.131 - pop ax 1.132 + pop ax ;caller return address 1.133 + pop bx 1.134 + push bx 1.135 push ax 1.136 - push bx 1.137 - mov [curdata],ax 1.138 - xchg ax,bx 1.139 + mov [curdata],bx 1.140 and [dword (data_himem bx).cacheidx],0 1.141 ret 1.142 1.143 @@ -725,7 +708,7 @@ 1.144 1.145 1.146 ;*************************************************************** 1.147 -;void next_chunk(struct image_himem *m); 1.148 +;void next_chunk(struct image_himem *di); 1.149 ;*************************************************************** 1.150 proc next_chunk near 1.151 1.152 @@ -770,7 +753,6 @@ 1.153 mov bx,[(image_himem di).fd] 1.154 ifndef NO386 1.155 push eax 1.156 - stc 1.157 call rewind 1.158 pop eax 1.159 @@end: 1.160 @@ -778,7 +760,6 @@ 1.161 else 1.162 push ax 1.163 push dx 1.164 - stc 1.165 call rewind 1.166 pop dx 1.167 pop ax 1.168 @@ -909,7 +890,6 @@ 1.169 xor cx,cx 1.170 ifndef NO386 1.171 cwde ; ax < 8000h 1.172 - cwd 1.173 sub [(image_himem di).chunk_size],eax 1.174 else 1.175 cwd ; ax < 8000h 1.176 @@ -963,29 +943,30 @@ 1.177 push cx 1.178 push ax 1.179 xor ebx,ebx 1.180 - jcxz @@jncend 1.181 push si 1.182 + jcxz @@end 1.183 mov si,cx 1.184 xor ecx,ecx 1.185 xor eax,eax 1.186 lodsb 1.187 - mov dl,20h 1.188 - or dl,al 1.189 - cmp dl,'n' ; vga=normal 1.190 + mov dx,ax 1.191 + or al,20h 1.192 + cmp al,'n' ; vga=normal 1.193 je @@vga 1.194 dec cx 1.195 - cmp dl,'e' ; vga=extended 1.196 + cmp al,'e' ; vga=extended 1.197 je @@vga 1.198 dec cx 1.199 - cmp dl,'a' ; vga=ask 1.200 + cmp al,'a' ; vga=ask 1.201 jne @@notvga 1.202 @@vga: 1.203 dec cx 1.204 xchg ax,cx 1.205 cwd 1.206 - jmp popsiret 1.207 + jmp @@popsiret 1.208 @@notvga: 1.209 mov cx,10 ; radix 1.210 + xchg ax,dx 1.211 cmp al,'+' 1.212 je @@radixskip 1.213 cmp al,'-' 1.214 @@ -1000,19 +981,18 @@ 1.215 jne @@radixok 1.216 mov cl,8 1.217 lodsb 1.218 - mov dl,20h 1.219 - or dl,al 1.220 - cmp dl,'x' 1.221 + or al,20h 1.222 + cmp al,'x' 1.223 jne @@radixok 1.224 mov cl,16 1.225 @@strtollp: 1.226 lodsb 1.227 @@radixok: 1.228 + or al,20h 1.229 sub al,'0' 1.230 jb @@endstrtol 1.231 cmp al,9 1.232 jbe @@digitok 1.233 - or al,20h 1.234 cmp al,'a'-'0' 1.235 jb @@endstrtol 1.236 sub al,'a'-'0'-10 1.237 @@ -1038,14 +1018,13 @@ 1.238 shl ebx,cl 1.239 @@noshift: 1.240 popf 1.241 -@@jncend: 1.242 jnc @@end 1.243 neg ebx 1.244 @@end: 1.245 push ebx 1.246 pop ax 1.247 pop dx 1.248 -popsiret: 1.249 +@@popsiret: 1.250 pop si 1.251 else 1.252 pop ax ;caller return address 1.253 @@ -1056,29 +1035,28 @@ 1.254 push di 1.255 xor ax,ax 1.256 cwd 1.257 + jcxz @@goend 1.258 xchg ax,di 1.259 - jcxz @@goend 1.260 mov si,cx 1.261 lodsb 1.262 - mov dl,20h 1.263 - or dl,al 1.264 + mov bx,ax 1.265 + or al,20h 1.266 mov cx,-1 1.267 - cmp dl,'n' ; vga=normal 1.268 + cmp al,'n' ; vga=normal 1.269 je @@vga 1.270 dec cx 1.271 - cmp dl,'e' ; vga=extended 1.272 + cmp al,'e' ; vga=extended 1.273 je @@vga 1.274 dec cx 1.275 - cmp dl,'a' ; vga=ask 1.276 + cmp al,'a' ; vga=ask 1.277 jne @@notvga 1.278 @@vga: 1.279 xchg ax,cx 1.280 - cwd 1.281 - jmp popsiret 1.282 @@goend: 1.283 - jmp @@end 1.284 + jmp @@popdisiret 1.285 @@notvga: 1.286 mov cx,10 ; radix 1.287 + xchg ax,bx 1.288 cmp al,'+' 1.289 je @@radixskip 1.290 cmp al,'-' 1.291 @@ -1093,19 +1071,18 @@ 1.292 jne @@radixok 1.293 mov cl,8 1.294 lodsb 1.295 - mov ah,20h 1.296 - or ah,al 1.297 - cmp ah,'x' 1.298 + mov al,20h 1.299 + cmp al,'x' 1.300 jne @@radixok 1.301 mov cl,16 1.302 @@strtollp: 1.303 lodsb 1.304 @@radixok: 1.305 + or al,20h 1.306 sub al,'0' 1.307 jb @@endstrtol 1.308 cmp al,9 1.309 jbe @@digitok 1.310 - or al,20h 1.311 cmp al,'a'-'0' 1.312 jb @@endstrtol 1.313 sub al,'a'-'0'-10 1.314 @@ -1155,8 +1132,8 @@ 1.315 inc dx 1.316 @@end: 1.317 xchg ax,di 1.318 +@@popdisiret: 1.319 pop di 1.320 -popsiret: 1.321 pop si 1.322 endif 1.323 ret 1.324 @@ -1175,7 +1152,7 @@ 1.325 jnc @@max640k 1.326 mov ax,640 ; 9000 1.327 @@max640k: 1.328 - sub ax,028h 1.329 + dec ax 1.330 and al,0C0h 1.331 mov cl,6 1.332 shl ax,cl