wok-6.x view memtest/stuff/unpack.S @ rev 21705
updated proot (3.2.2 -> 5.1.0)
author | Hans-G?nter Theisgen |
---|---|
date | Thu Jun 06 17:38:24 2019 +0100 (2019-06-06) |
parents | 1421f93cc28a |
children | 608a017317a8 |
line source
1 #define SYSTEM 0x10000
2 #define SETUP 14
3 #define SYSSIZE 0x1F4
4 #define SETUPSIZE 0x1F1
6 #define LINUX_HEADER 0
7 #define UPDATE_SYSSIZE 1
8 #define HARDCODED_SYSSIZE 1
9 #define HARDCODED_SETUPSIZE 1
10 #define FLAT16 1
11 //#define FLAT16OUT 0
12 #define SAVEREGS 0
13 #define ELKS 0
15 .text
16 .code16
17 .org 0
19 #if ELKS
20 .arch i8086
21 #define FLAT16 1
22 #define LINUX_HEADER 0
23 #define SAVEREGS 0
24 #define TOPSEG 0x2000
25 #else
26 #define TOPSEG 0x8000
27 #endif
29 .globl _start
30 _start:
31 #if LINUX_HEADER
32 jmp start2
33 .ascii "HdrS" // 202 magic
34 .word 0x200 // 206 version 2.00
35 .long 0 // 208 realmode_swtch
36 .word SYSTEM/16 // 20C start_sys_seg
37 .word 0 // 20E kernel_version
38 .byte 0 // 210 type_of_loader
39 .byte 0 // 211 loadflags
40 .word 0 // 212 setup_move_size
41 .long SYSTEM // 214 code32_start
42 .long 0 // 218 ramdisk_image
43 .long 0 // 21C ramdisk_size
44 .long 0 // 220 bootsect_kludge
45 start2:
46 #endif
47 #if SAVEREGS
48 pushfw
49 pushw %cs
50 pushw $0
51 pushal
52 pushw %ds
53 cld
54 #else
55 pushw %cs
56 # if FLAT16
57 xorw %di, %di
58 pushw %di
59 # else
60 pushw $0
61 # endif
62 #endif
63 #if ELKS
64 movw $0x100, %ax
65 pushw %ax
66 #else
67 #if UPDATE_SYSSIZE
68 pushw %ds // <A>
69 #else
70 pushw %cs // <A>
71 #endif
72 #endif
73 #if FLAT16
74 # 1- move 9020..9020+stp -> TOPSEG
75 #if ELKS
76 movb $TOPSEG/256, %ah
77 movw %ax, %es
78 #else
79 pushw $TOPSEG
80 popw %es
81 #endif
82 movw $0x200, %si
83 #if SAVEREGS == 0
84 pushw %es
85 #if ELKS
86 movw $cont, %ax
87 pushw %ax
88 #else
89 // pushw $cont
90 .byte 0x6A, cont
91 #endif
92 jmp jumpinto
93 #else
94 # if HARDCODED_SETUPSIZE
95 setup_word:
96 movw $SETUP*256, %cx
97 # else
98 xorw %cx, %cx
99 movb SETUPSIZE, %ch
100 movw %cx, %dx
101 # endif
102 pushw %cx // <B>
103 pushw %es
104 pushw %di
105 rep
106 movsw
107 lret
108 #endif
109 cont:
110 # 2- move 1000..1000+sys -> TOPSEG+stp
111 #if ELKS
112 movw $0x1000, %ax
113 movw %ax, %ds
114 #else
115 pushw $0x1000
116 popw %ds
117 #endif
118 xorw %si, %si
119 subw %di, %cx
120 rep
121 movsb
122 # 3- unlz(TOPSEG+stp:end, 1000-stp:0)
123 pushw %es // <C>
124 # if HARDCODED_SETUPSIZE
125 setup_seg:
126 #if ELKS
127 # if UPDATE_SYSSIZE
128 movw $0x1000-(SETUP*32)-32, %ax
129 # else
130 movw $0x1000-(SETUP*32), %ax
131 # endif
132 movw %ax, %es
133 #else
134 # if UPDATE_SYSSIZE
135 pushw $0x1000-(SETUP*32)-32
136 # else
137 pushw $0x1000-(SETUP*32)
138 # endif
139 popw %es
140 #endif
141 # else
142 # if UPDATE_SYSSIZE
143 incb %dh
144 # endif
145 #if ELKS
146 shrw $1, %dx
147 shrw $1, %dx
148 shrw $1, %dx
149 #else
150 shrw $3, %dx
151 #endif
152 movw %ds, %ax
153 subw %dx, %ax
154 movw %ax, %es
155 # endif
156 #else // FLAT16
157 # 1- move 1000..1000+sys -> 9000-sys
158 # if HARDCODED_SYSSIZE
159 packed_syssize:
160 movw $0x1000+0, %ax
161 # else
162 movw SYSSIZE, %ax
163 addw $0x1000, %ax
164 # endif
165 movw %ds, %dx
166 mvsys:
167 decw %ax
168 decw %dx
169 movw %ax, %ds
170 movw %dx, %es
171 xorw %si, %si
172 xorw %di, %di
173 movw $8, %cx
174 rep
175 movsw
176 cmpw $0x1000, %ax
177 jne mvsys
178 # 2- move 9020..9020+stp -> 9000-sys-stp
180 # if HARDCODED_SETUPSIZE
181 setup_byte:
182 movb $SETUP, %ch
183 setup_para:
184 subw $SETUP*32, %dx
185 # else
186 movb %ss:SETUPSIZE, %ch
187 movw %cx, %ax
188 #if ELKS
189 shrw $1, %ax
190 shrw $1, %ax
191 shrw $1, %ax
192 #else
193 shrw $3, %ax
194 #endif
195 subw %ax, %dx
196 # endif
197 pushw %cx // <B>
198 movw %dx, %es
199 xorw %si, %si
200 xorw %di, %di
201 rep
202 movsw %cs:(%si),%es:(%di)
203 pushw %es
204 # 3- reloc itself in 0x7C00
205 pushw $0x07C0
206 popw %es
207 movw $cont, %si
208 movw %si, %di
209 movw $end-_start, %cx
210 pushw %es
211 pushw %di
212 rep
213 movsb %cs:(%si),%es:(%di)
214 lret
215 cont:
216 # 4- unlz(9000-sys-stp:end, 1000-stp:0)
217 # if HARDCODED_SETUPSIZE
218 setup_seg:
219 # if UPDATE_SYSSIZE
220 pushw $0x1000-(SETUP*32)-32
221 # else
222 pushw $0x1000-(SETUP*32)
223 # endif
224 popw %es
225 # else
226 negw %ax
227 # if UPDATE_SYSSIZE
228 addw $0x1000-32, %ax
229 # else
230 addw $0x1000, %ax
231 # endif
232 movw %ax, %es
233 # endif
234 #endif // FLAT16
235 popw %ds // <C>
236 movw $end-_start, %si
237 #if UPDATE_SYSSIZE
238 movw $SYSSIZE, %di
239 #else
240 xorw %di, %di
241 #endif
242 pushw %di
243 pushw %es
244 call unpack
245 popw %ds
246 popw %si
247 movw %si, %di
248 # if SAVEREGS != 0
249 popw %cx // <B>
250 #if UPDATE_SYSSIZE
251 // not need with memtest movb $(512-SYSSIZE)/2, %cl
252 #endif
253 popw %es // <A>
254 # 5- move 1000-stp..1000 -> 9020
255 # else
256 popw %es // <A>
257 jumpinto:
258 # if HARDCODED_SETUPSIZE
259 setup_word:
260 movw $SETUP*256, %cx
261 # else
262 xorw %cx, %cx
263 movb %ss:SETUPSIZE, %ch
264 movw %cx, %dx
265 # endif
266 # endif
267 rep
268 movsw
269 #if SAVEREGS
270 popw %ds
271 popal
272 iret
273 #else
274 lret
275 #endif
277 unpack:
278 #define NO_LZMA_HEADER
279 #if ELKS
280 #define ONLY8086 1
281 #endif
282 #include "unlzma.S"
284 end: