wok view linld/stuff/src/JUMP.ASM @ rev 20477

Rebuild perl in 32 bits
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Oct 17 20:44:06 2018 +0200 (2018-10-17)
parents 8e449fe1df2e
children 12f4a776eaa7
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 ifdef NO386
9 p8086
10 else
11 p386
12 endif
14 group DGROUP _TEXT,_DATA,_BSS
15 assume cs:DGROUP,ds:DGROUP
17 segment _DATA byte public use16 'DATA'
19 overflow db "Loaded too close to 9000:0",0
21 ends _DATA
23 segment _BSS byte public use16 'BSS'
25 global _imgs:dword
27 ends _BSS
30 segment _TEXT byte public use16 'CODE'
32 ;***************************************************************
33 ;void dos_shutdown()
34 ;***************************************************************
36 macro dos_shutdown
37 xor bx,bx
38 mov ds,bx
39 ifndef NO386
40 push [dword bx+4] ; save step
41 mov [word bx+4],offset step19
42 else
43 mov ax,offset step19
44 xchg ax,[word bx+4]
45 push [word bx+6]
46 push ax ; save step
47 endif
48 mov [word cs:sssp],sp
49 ;cmp [byte bx+7],0F0h
50 ;jnc notdos
51 mov [bx+6],cs
52 pushf
53 pushf
54 pop ax
55 inc ah ; set TF
56 push ax
57 popf
58 call [dword bx+4*19h]
59 notdos:
60 ifndef NO386
61 lss sp,[dword cs:sssp]
62 else
63 lds ax,[dword cs:sssp]
64 push ds
65 pop ss
66 xchg ax,sp
67 endif
68 xor bx,bx
69 mov ds,bx
70 ifndef NO386
71 pop [dword bx+4] ; restore step
72 else
73 pop [word bx+4] ; restore step
74 pop [word bx+6]
75 endif
76 endm
77 macro step19code
78 step19:
79 push bx
80 push ds
81 mov bx,sp
82 lds bx,[dword ss:bx+4] ; read cs:ip
83 cmp [word bx],19CDh ; int 19h ?
84 pop ds
85 pop bx
86 je notdos
87 iret
88 endm
91 ;***************************************************************
92 ;void boot_kernel();
93 ;****** Never returns
94 ;***************************************************************
95 global _boot_kernel:near
96 proc _boot_kernel near
98 p8086
99 extrn _heap_top:word
100 global sssp
101 ifdef NO386
102 sssp:
103 extrn _topseg:near
104 call near _topseg
105 mov [word sssp+2],ax
106 xchg ax,bx
107 mov ax,[_heap_top]
108 inc ah
109 mov cl,4
110 shr ax,cl
111 else
112 p386
113 mov ax,[_heap_top]
114 inc ah
115 ;shr ax,4
116 db 0C1h,0E8h
117 sssp:
118 db 4
119 mov bx,9000h
120 endif
121 mov es,bx
122 mov dx,cs
123 add ax,dx
124 cmp ax,bx
125 jb @@nooverflow
126 ; Oops! We can stomp on our toes... better stop now
127 mov bx,offset overflow
128 extrn die:near
129 call near die
130 @@nooverflow:
131 ;cli ; we start doing destructive things to DOS
132 push es
133 pop ss
134 mov sp,0A000h
135 extrn _csip:dword
136 push [dword _csip]
137 extrn _rm_size:word
138 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
139 lodsw
140 xchg ax,cx ; _rm_size
141 lodsb ; _pm_high
142 mov si,[si] ; _rm_buf
143 xor di,di
144 ;cld
145 rep
146 movsb
147 extrn _cmdline:word
148 mov si,[_cmdline]
149 mov di,8000h
150 mov ch,10h ; 4k
151 rep
152 movsb
153 cmp al,cl ; load high ?
154 ifdef noelks
155 jne @@isbzimage
156 else
157 jne @@isbzimagez
158 endif
159 ifdef NO386
160 add bh,9
161 push bx ; topseg()+0x0900
162 else
163 push 9800h+(4096/16) ; 4096 bytes for cmdline
164 endif
165 ; finish loading
166 extrn @last_ditch$qv:near
167 push cs
168 call @last_ditch$qv
169 ; self move
170 ;cld
171 pop es ; min 2048 bytes for stack
172 xor si,si ; A000 -9000 -0800(>movedend)
173 xor di,di ; set ZF
174 mov cx,offset movedend
175 rep
176 movsb
177 mov ax,[word _imgs+2+2] ; get pm->fallback high word
179 ; prepare memcpy32 size & srcofs param to move zImage pm
180 mov dx,8
181 cmp ax,dx ; buf > 80000h ?
182 ja @@bufhigh
183 sub dx,ax
184 inc dx ; up to 90000h-1
185 @@bufhigh:
186 push dx ; size hi
187 push cx ; size lo=up to 512k
188 push ax ; src ofs ho = pm.fallback
190 push es
191 dos_shutdown ; clear bx
192 call near @@isbzimage ; pop cs ; ds=es=ss
193 ;in al,70h
194 ;or al,80h ; disable NMI
195 ;out 70h,al
197 push bx ; src ofs lo
198 push bx ; src seg=0
199 ifdef NO386
200 inc bx
201 push bx ; dst ofs hi
202 dec bx
203 else
204 push 1 ; dst ofs hi
205 endif
206 push bx ; dst ofs lo : 64k
207 extrn _memcpy32:near
208 call _memcpy32
209 add sp,14
211 ifndef noelks
212 ifndef NO386
213 cmp [dword 1E6h],'SKLE'
214 jne @@notelks
215 @@isbzimagez:
216 jne @@isbzimage
217 else
218 cmp [word 1E6h],'LE'
219 jne @@notelks
220 @@isbzimagez:
221 jne @@isbzimage
222 cmp [word 1E8h],'SK'
223 jne @@notelks
224 endif
225 mov cx,100h ; DS=ES=SS=0100
226 mov es,cx
227 mov ch,05h ; 500h mini
228 xor si,si
229 xor di,di
230 rep
231 movsw
232 push es
233 pop ss
234 ifdef NO386
235 mov ax,120h ; CS=0120
236 push ax
237 else
238 push 120h ; CS=0120
239 endif
240 push cx ; IP=0000
241 @@notelks:
242 endif
243 @@isbzimage:
244 push ss
245 pop ds
246 push ss
247 pop es
248 ifndef NO386
249 push ss
250 pop fs
251 push ss
252 pop gs
253 endif
254 assume nothing
255 assume cs:DGROUP
256 retf
258 step19code
260 endp _boot_kernel
262 movedend:
264 ends _TEXT
266 end
268 ;###### END OF FILE ############################################