wok-next view memtest/stuff/unpack.S @ rev 13288
memtest: lzma compression (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Aug 26 00:28:25 2012 +0200 (2012-08-26) |
parents | 18d1dc85701e |
children | e76c37f7bfe6 |
line source
1 #define TOP 0x8FD00
2 #define SYSTEM 0x10000
3 #define SETUP 4
5 #define CHANGE_STACK 1
7 .text
8 .code16
9 .org 0
11 .globl _start
12 _start:
13 pushf
14 pushw %cs
15 call getip
16 getip:
17 pushal
18 movw $0, %bx // packed sizes
19 movw %sp, %bp
20 #define START_IP 32(%bp)
21 pushw %ds
22 pushw %es
23 subw $getip-_start, START_IP
25 cld
26 pushw %cs
27 popw %ds
28 movw $TOP/16, %ax
29 movw %ax, %es
30 subw %bx, %ax // moved packed data
31 movw START_IP, %si
32 movw $moved-_start, %di
33 addw %si, %di
34 pushw %ds // save setup seg
35 pushw %es // moved
36 pushw %di // unpack code
37 movw %si, %di
38 movw $end-_start, %cx
39 rep
40 movsb // move upack code to $TOP
41 pushw %si // data offset
42 movw %ax, %es
43 movw $SETUP*512, %cx
44 subw $SETUP*32, %bx
45 xorw %si, %si
46 xorw %di, %di
47 rep
48 movsb // move header part
49 pushw $SYSTEM/16
50 popw %ds
51 movlp:
52 xorw %si, %si
53 movw $8, %cx
54 rep
55 movsw // move system part
56 subw $16, %di
57 movw %ds, %cx
58 incw %cx
59 movw %cx, %ds
60 movw %es, %cx
61 incw %cx
62 movw %cx, %es
63 decw %bx
64 jns movlp
65 popw %si // data offset
66 movw %ax, %ds
67 retf
69 moved:
70 popw %es // restore setup seg
71 movw START_IP, %di
72 #if CHANGE_STACK
73 movw $0xFFFE, %ax
74 movw %ss, %bx
75 pushw $0
76 popw %ss
77 xchgw %ax, %sp
78 pushw %bx // %ss
79 pushw %ax // %sp
80 #endif
81 call unpack // unpack setup
82 pushw $SYSTEM/16
83 popw %es
84 xorw %di,%di
85 call unpack // unpack system
86 #if CHANGE_STACK
87 popw %ax // %sp
88 popw %ss
89 xchgw %ax, %sp
90 #endif
91 popw %es
92 popw %ds
93 popal
94 iret
96 unpack:
97 #include "unlzma.S"
99 end: