wok-next diff linld/stuff/src/JUMP.ASM @ rev 20462
Combine receipts
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Mar 06 03:00:01 2018 +0200 (2018-03-06) |
parents | 9107c8697bd1 |
children |
line diff
1.1 --- a/linld/stuff/src/JUMP.ASM Fri Mar 17 15:18:10 2017 +0100 1.2 +++ b/linld/stuff/src/JUMP.ASM Tue Mar 06 03:00:01 2018 +0200 1.3 @@ -11,12 +11,18 @@ 1.4 p386 1.5 endif 1.6 1.7 - group DGROUP _TEXT,_BSS 1.8 + group DGROUP _TEXT,_DATA,_BSS 1.9 assume cs:DGROUP,ds:DGROUP 1.10 1.11 + segment _DATA byte public use16 'DATA' 1.12 + 1.13 +overflow db "Loaded too close to 9000:0",0 1.14 + 1.15 + ends _DATA 1.16 + 1.17 segment _BSS byte public use16 'BSS' 1.18 1.19 - global _pm:dword 1.20 + global _imgs:dword 1.21 1.22 ends _BSS 1.23 1.24 @@ -24,31 +30,49 @@ 1.25 segment _TEXT byte public use16 'CODE' 1.26 1.27 ;*************************************************************** 1.28 -;void set_sregs_jump_seg_ofs(u32 csip); 1.29 +;void boot_kernel(); 1.30 ;****** Never returns 1.31 ;*************************************************************** 1.32 - global _set_sregs_jump_seg_ofs:near 1.33 - proc _set_sregs_jump_seg_ofs near 1.34 - 1.35 - extrn dos_shutdown:near 1.36 - 1.37 - pop ax ; caller return address 1.38 + global _boot_kernel:near 1.39 + proc _boot_kernel near 1.40 + 1.41 +; Shrink stack: we won't need much of it now and have no malloc() plans 1.42 + extrn _heap_top:word 1.43 + mov ax,[_heap_top] 1.44 + inc ah 1.45 + cmp ax,sp 1.46 + ja @@samesp 1.47 + xchg ax,sp 1.48 +@@samesp: 1.49 ifdef NO386 1.50 extrn _topseg:near 1.51 call near _topseg 1.52 mov es,ax 1.53 xchg ax,bx 1.54 + mov cl,4 1.55 + mov ax,sp 1.56 + shr ax,cl 1.57 else 1.58 - push 9000h 1.59 - pop es 1.60 + mov bx,9000h 1.61 + mov es,bx 1.62 + mov ax,sp 1.63 + shr ax,4 1.64 endif 1.65 - pop dx ; ip 1.66 - pop cx ; cs 1.67 + mov dx,cs 1.68 + add ax,dx 1.69 + cmp ax,bx 1.70 + jb @@nooverflow 1.71 +; Oops! We can stomp on our toes... better stop now 1.72 + mov bx,offset overflow 1.73 + extrn die:near 1.74 + jmp near die 1.75 +@@nooverflow: 1.76 cli ; we start doing destructive things to DOS 1.77 push es 1.78 pop ss 1.79 mov sp,0A000h 1.80 - push cx dx 1.81 + extrn _csip:dword 1.82 + push [dword _csip] 1.83 extrn _rm_size:word 1.84 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf 1.85 lodsw 1.86 @@ -66,36 +90,34 @@ 1.87 rep 1.88 movsb 1.89 cmp al,cl ; load high ? 1.90 - jne isbzimage 1.91 + jne @@isbzimage 1.92 ifdef NO386 1.93 add bh,9 1.94 push bx ; topseg()+0x0900 1.95 else 1.96 - push 9900h ; 4096 bytes for cmdline 1.97 - ;push 9820h ; 512 bytes for cmdline 1.98 + push 9800h+(4096/16) ; 4096 bytes for cmdline 1.99 endif 1.100 ; finish loading 1.101 extrn @last_ditch$qv:near 1.102 push cs 1.103 call @last_ditch$qv 1.104 - mov ax,[word _pm+2+2] ; get pm->fallback high word 1.105 + mov ax,[word _imgs+2+2] ; get pm->fallback high word 1.106 ; self move 1.107 ;cld 1.108 pop es ; min 2048 bytes for stack 1.109 xor si,si ; A000 -9000 -0800(>movedend) 1.110 xor di,di ; set ZF 1.111 mov cx,offset movedend 1.112 - global _bss_end:byte 1.113 - ;mov cx,offset _bss_end 1.114 rep 1.115 movsb 1.116 push es 1.117 - call near doretf ; mov cs,es 1.118 + call near @@doretf ; mov cs,es 1.119 push ss 1.120 pop es 1.121 push cs 1.122 pop ds 1.123 push ax 1.124 + extrn dos_shutdown:near 1.125 call near dos_shutdown 1.126 ;in al,70h 1.127 ;or al,80h ; disable NMI 1.128 @@ -103,12 +125,12 @@ 1.129 pop bx 1.130 ; move zImage pm 1.131 mov ax,8 1.132 - cwd 1.133 + cwd ; clear dx 1.134 cmp bx,ax 1.135 - ja bufhigh 1.136 + ja @@bufhigh 1.137 sub ax,bx 1.138 inc ax 1.139 -bufhigh: 1.140 +@@bufhigh: 1.141 push ax 1.142 push dx ; size=up to 512k 1.143 push bx ; src ofs= pm.fallback 1.144 @@ -133,10 +155,10 @@ 1.145 cmp [dword 1E6h],'SKLE' 1.146 else 1.147 cmp [word 1E6h],'LE' 1.148 - jne notelks 1.149 + jne @@notelks 1.150 cmp [word 1E8h],'SK' 1.151 endif 1.152 - jne notelks 1.153 + jne @@notelks 1.154 ifdef NO386 1.155 mov cx,120h 1.156 push cx 1.157 @@ -155,10 +177,9 @@ 1.158 push es 1.159 pop ss 1.160 push cx 1.161 -notelks: 1.162 +@@notelks: 1.163 endif 1.164 - 1.165 -isbzimage: 1.166 +@@isbzimage: 1.167 push ss 1.168 pop ds 1.169 ;push ss 1.170 @@ -171,12 +192,11 @@ 1.171 endif 1.172 assume nothing 1.173 assume cs:DGROUP 1.174 - 1.175 -doretf: 1.176 +@@doretf: 1.177 retf 1.178 1.179 movedend: 1.180 - endp _set_sregs_jump_seg_ofs 1.181 + endp _boot_kernel 1.182 1.183 ends _TEXT 1.184