wok-6.x view memtest/stuff/unpack.S @ rev 19608
Up firefox-official (50.1.0)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Jan 06 03:32:05 2017 +0200 (2017-01-06) |
parents | fd3dadf90ba9 |
children | e4d1fb5556df |
line source
1 #define TOP (0x90000+_start-end)
2 #define SYSTEM 0x10000
3 #define SETUP 14
4 #define SYSSIZE 0x1F4
5 #define SETUPSIZE 0x1F1
7 #define LINUX_HEADER 0
8 #define UPDATE_SYSSIZE 1
9 #define HARDCODED_SYSSIZE 1
10 #define HARDCODED_SETUPSIZE 1
11 #define FLAT16 1
12 //#define FLAT16OUT 0
13 #define SAVEREGS 0
15 .text
16 .code16
17 .org 0
19 .globl _start
20 _start:
21 #if LINUX_HEADER
22 jmp start2
23 .ascii "HdrS" // 202 magic
24 .word 0x200 // 206 version 2.00
25 .long 0 // 208 realmode_swtch
26 .word SYSTEM/16 // 20C start_sys_seg
27 .word 0 // 20E kernel_version
28 .byte 0 // 210 type_of_loader
29 .byte 0 // 211 loadflags
30 .word 0 // 212 setup_move_size
31 .long SYSTEM // 214 code32_start
32 .long 0 // 218 ramdisk_image
33 .long 0 // 21C ramdisk_size
34 .long 0 // 220 bootsect_kludge
35 start2:
36 #endif
37 #if SAVEREGS
38 pushfw
39 pushw %cs
40 pushw $0
41 pushal
42 pushw %ds
43 #else
44 pushw %cs
45 pushw $0
46 #endif
47 #if UPDATE_SYSSIZE
48 pushw %ds
49 #else
50 pushw %es
51 pushw %cs
52 #endif
53 cld
54 #if FLAT16
55 # 1- move 9020..9020+stp -> 8000
56 # if HARDCODED_SETUPSIZE
57 setup_word:
58 movw $SETUP*256, %cx
59 # else
60 xorw %cx, %cx
61 movb SETUPSIZE, %ch
62 movw %cx, %dx
63 # endif
64 pushw %cx
65 pushw $0x8000
66 popw %es
67 xorw %si, %si
68 xorw %di, %di
69 rep
70 movsw %cs:(%si),%es:(%di)
71 pushw %es
72 // pushw $cont
73 .byte 0x6A, cont
74 lret
75 cont:
76 # 2- move 1000..1000+sys -> 8000+stp
77 pushw $0x1000
78 popw %ds
79 xorw %si, %si
80 subw %di, %cx
81 rep
82 movsb
83 # 3- unlz(8000+stp:end, 1000-stp:0)
84 pushw %es
85 # if HARDCODED_SETUPSIZE
86 setup_seg:
87 # if UPDATE_SYSSIZE
88 pushw $0x1000-(SETUP*32)-32
89 # else
90 pushw $0x1000-(SETUP*32)
91 # endif
92 popw %es
93 # else
94 # if UPDATE_SYSSIZE
95 incb %dh
96 # endif
97 shrw $3, %dx
98 movw %ds, %ax
99 subw %dx, %ax
100 movw %ax, %es
101 # endif
102 #else
103 # 1- move 1000..1000+sys -> 9000-sys
104 # if HARDCODED_SYSSIZE
105 packed_syssize:
106 movw $0x1000+0, %ax
107 # else
108 movw SYSSIZE, %ax
109 addw $0x1000, %ax
110 # endif
111 movw %ds, %dx
112 mvsys:
113 decw %ax
114 decw %dx
115 movw %ax, %ds
116 movw %dx, %es
117 xorw %si, %si
118 xorw %di, %di
119 movw $8, %cx
120 rep
121 movsw
122 cmpw $0x1000, %ax
123 jne mvsys
124 # 2- move 9020..9020+stp -> 9000-sys-stp
126 # if HARDCODED_SETUPSIZE
127 setup_byte:
128 movb $SETUP, %ch
129 setup_para:
130 subw $SETUP*32, %dx
131 # else
132 movb %ss:SETUPSIZE, %ch
133 movw %cx, %ax
134 shrw $3, %ax
135 subw %ax, %dx
136 # endif
137 pushw %cx
138 movw %dx, %es
139 xorw %si, %si
140 xorw %di, %di
141 rep
142 movsw %cs:(%si),%es:(%di)
143 pushw %es
144 # 3- reloc itself in 0x7C00
145 pushw $0x07C0
146 popw %es
147 xorw %si, %si
148 xorw %di, %di
149 movw $end-_start, %cx
150 rep
151 movsb %cs:(%si),%es:(%di)
152 pushw %es
153 // pushw $cont
154 .byte 0x6A, cont
155 lret
156 cont:
157 # 4- unlz(9000-sys-stp:end, 1000-stp:0)
158 # if HARDCODED_SETUPSIZE
159 setup_seg:
160 # if UPDATE_SYSSIZE
161 pushw $0x1000-(SETUP*32)-32
162 # else
163 pushw $0x1000-(SETUP*32)
164 # endif
165 popw %es
166 # else
167 negw %ax
168 # if UPDATE_SYSSIZE
169 addw $0x1000-32, %ax
170 # else
171 addw $0x1000, %ax
172 # endif
173 movw %ax, %es
174 # endif
175 #endif
176 popw %ds
177 movw $end-_start, %si
178 #if UPDATE_SYSSIZE
179 movw $SYSSIZE, %di
180 #else
181 xorw %di, %di
182 #endif
183 pushw %di
184 pushw %es
185 call unpack
186 popw %ds
187 popw %si
188 movw %si, %di
189 popw %cx
190 #if UPDATE_SYSSIZE
191 // not need with memtest movb $(512-SYSSIZE)/2, %cl
192 #endif
193 popw %es
194 # 5- move 1000-stp..1000 -> 9020
195 rep
196 movsw
197 #if UPDATE_SYSSIZE == 0
198 popw %es
199 #endif
200 #if SAVEREGS
201 popw %ds
202 popal
203 iret
204 #else
205 lret
206 #endif
208 unpack:
209 #define NO_LZMA_HEADER
210 #include "unlzma.S"
212 end: