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

upx: patch checkDefaultCompressionRatio()
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Oct 18 22:26:36 2018 +0200 (2018-10-18)
parents cd2def637347
children 71d2f2304826
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 di,di
38 mov ds,di
39 ifndef NO386
40 push [dword di+4] ; save step
41 mov [word di+4],offset step19
42 else
43 mov ax,offset step19
44 xchg ax,[word di+4]
45 push [word di+6]
46 push ax ; save step
47 endif
48 mov [word cs:sssp],sp
49 ;cmp [byte di+7],0F0h
50 ;jnc notdos
51 mov [di+6],cs
52 pushf
53 pushf
54 pop ax
55 inc ah ; set TF
56 push ax
57 popf
58 call [dword di+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 di,di
69 mov ds,di
70 ifndef NO386
71 pop [dword di+4] ; restore step
72 else
73 pop [word di+4] ; restore step
74 pop [word di+6]
75 endif
76 endm
77 macro step19code
78 step19:
79 push di
80 push ds
81 mov di,sp
82 lds di,[dword ss:di+4] ; read cs:ip
83 cmp [word di],19CDh ; int 19h ?
84 pop ds
85 pop di
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 mov cl,4
109 shr ax,cl
110 else
111 p386
112 mov ax,[_heap_top]
113 ;shr ax,4
114 db 0C1h,0E8h
115 sssp:
116 db 4
117 mov bx,9000h
118 endif
119 mov es,bx
120 mov dx,cs
121 add ax,dx
122 cmp ax,bx
123 jb @@nooverflow
124 ; Oops! We can stomp on our toes... better stop now
125 mov bx,offset overflow
126 extrn die:near
127 call near die
128 @@nooverflow:
129 ;cli ; we start doing destructive things to DOS
130 push es
131 pop ss
132 mov sp,0A000h
133 extrn _csip:dword
134 push [dword _csip]
135 extrn _rm_size:word
136 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
137 lodsw
138 xchg ax,cx ; _rm_size
139 lodsb ; _pm_high
140 mov si,[si] ; _rm_buf
141 xor di,di
142 ;cld
143 rep
144 movsb
145 extrn _cmdline:word
146 mov si,[_cmdline]
147 mov di,8000h
148 mov ch,10h ; 4k
149 rep
150 movsb
151 ifdef NO386
152 add bh,9
153 endif
154 cmp al,cl ; load high ?
155 ifdef noelks
156 jne @@isbzimage
157 else
158 jne @@isbzimagez
159 endif
160 ifdef NO386
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 mov cx,offset movedend
173 xor si,si ; A000 -9000 -0800(>movedend)
174 xor di,di ; set ZF
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 di
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 di ; src ofs lo
198 push di ; src seg=0
199 ifdef NO386
200 inc di
201 push di ; dst ofs hi
202 dec di
203 else
204 push 1 ; dst ofs hi
205 endif
206 push di ; 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 xor si,si
216 else
217 mov si,1E6h
218 lodsw
219 cmp ax,'LE'
220 jne @@notelks
221 lodsw
222 xor ax,'SK'
223 jne @@notelks
224 xchg ax,si
225 endif
226 push es
227 pop ss
228 mov cx,120h ; CS=0120
229 push cx
230 push si ; IP=0000
231 mov cl,0 ; DS=ES=SS=0100
232 mov es,cx
233 mov ch,05h ; 500h mini
234 rep
235 @@isbzimagez:
236 movsw
237 @@notelks:
238 endif
239 @@isbzimage:
240 push ss
241 pop ds
242 push ss
243 pop es
244 ifndef NO386
245 push ss
246 pop fs
247 push ss
248 pop gs
249 endif
250 assume nothing
251 assume cs:DGROUP
252 retf
254 step19code
256 endp _boot_kernel
258 movedend:
260 ends _TEXT
262 end
264 ;###### END OF FILE ############################################