wok view syslinux/stuff/iso2exe/bootiso.S @ rev 20869

syslinux/iso2exe: add cdrom icon
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 23 13:25:31 2019 +0100 (2019-02-23)
parents e05d978e5ab8
children 04ffefac5707
line source
1 .text
2 .code16
3 .arch i8086
4 .org 0
6 CODESZ = 0x8000 // 16 sectors = 32Kb
7 #define EXEADRS(x) x+0xC0
8 #define EXELOC(x) x-0x40
9 #define EXESTR(x) x-0x7F40
11 .globl _start
12 _start:
13 decw %bp // Magic number: MZ
14 popw %dx
15 jmp start0 // Bytes on last page of file
16 .word (CODESZ+511)/512 // Pages in file
17 .word 0 // Relocations
18 .word (end_header-_start)/16 // Size of header in paragraphs
19 .word 4064-(CODESZ/16) // Minimum extra paragraphs needed
20 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed
21 .word 0xFFF0 // Initial (relative) SS value
22 .word 0xFFFE // Initial SP value
23 magic:
24 .word 0 // Checksum
25 .word EXEADRS(exestart) // Initial IP value
26 .word 0xFFF0 // Initial (relative) CS value
27 initramfssize:
28 .word 0 // File address of relocation table
29 fdcnt: // Overlay number
30 .byte 0 // Bootstrap floppy sector count
31 .ascii "slitaz"
33 /////////////////////// Master Boot Record code //////////////////////////////
35 moved = 0x8000
36 start0:
37 //pushw %dx // restore %sp
38 //incw %bp // restore %bp
39 xorw %bx, %bx
40 movw %bx, %ds
41 movb $0x7C, %bh
42 pushw %ds
43 popw %ss
44 movw %bx, %sp
45 pushw %bx // return address
46 pushw %di
47 pushw %es // save %es:%di
48 cld
49 sti
50 pushw %ds
51 popw %es
52 call setreg
53 rep
54 movsw
55 movw $0x80, %dx
56 ljmp $0, $moved+start2
57 .byte 0
58 // .org 60
59 // .long 0x0080 // PE header offset
60 .org 64
61 end_header:
62 comstart:
63 .word 0
65 .org 66
66 dxloop:
67 start2:
68 call readsector1 // look for the boot device
69 repe
70 cmpsw
71 je dxfound
72 movb $0, %cl // ch = 0
73 addb $0x7D, %dl // try every hard disk
74 jno dxloop
76 dxfound:
77 call readsectorX // read isolinux boot sector
78 cmpw (%bx), %cx
79 jnc puts // read fail or no isohydrid boot sector
80 movw $patch,%si
81 popw %es
82 popw %di // isolinux boot needs %es:%di and %dx
83 putsret:
84 ret
86 putstrlp:
87 movw $7, %bx
88 movb $0xE, %ah
89 int $0x10
90 error:
91 lodsb
92 cmp $1, %al
93 jg putstrlp
94 jz putsret
95 puts:
96 movb $0x80, %ah
97 xchgw %ax, %si
98 jnc error
99 halt:
100 hlt
101 jmp halt
102 nobsmsg:
103 .asciz "No isolinux."
105 .org 0x0080
106 ////////////////////////////// EXE/PE header //////////////////////////////////
108 .org 0x01A0
109 readsectorX: // read isolinux boot sector
110 movb $0xA5, %cl // patched by installer
111 readsector1:
112 andb $0x83, %dl // disk and floppy disk
113 movw %cx, (%bx)
114 incw %cx
115 movw $0x201, %ax
116 int $0x13
117 setreg:
118 movw %bx, %si
119 movw $moved, %di
120 movw $0x0100, %cx
121 movb $nobsmsg, %al
122 ret
123 .org 0x01B8
125 ////////////////////////// partition boot code ////////////////////////////////
126 // assume DS=SS BX=7C00 CH=01 DL=<drive> SI=7DBE
128 .org 0x7C00
129 jmp bootpartition
130 .org 0x7C03
131 .org 0x7DBE
132 table = moved+0x1BE
133 patch:
134 .byte 0,0,0 // head of original bs
135 partcode:
136 popw %si
137 xchgw %si,%di
138 call movepartition
139 pushw %cx
140 pushw %cx
141 decw %di
142 decw %di
143 movb $4,%cl
144 movw $16,%ax
145 next:
146 subw %ax,%di
147 cmpb %ch,(%di) // boot flag ?
148 loope next
149 pushw 10(%di)
150 pushw 8(%di)
151 pushw %cs
152 pushw %bx
153 movb $1,%cl
154 pushw %cx
155 pushw %ax
156 movw %sp,%si // assume %ds = %ss
157 pushw %bx
158 cmpw $63,2(%di) // empty or isolinux partition ?
159 jbe default
160 movb $0x42,%ah
161 int $0x13
162 default:
163 ret
164 .org 0x7DF0
165 bootpartition:
166 pushw %ds
167 popw %es
168 pushw %si
169 movw %bx,%di
170 movsw
171 movsb
172 movw $table-0x142,%di
173 pushw %di
174 movepartition:
175 movb $66,%cl // 0142 and 0042
176 rep
177 movsb
178 ret
179 .org 0x7E00
181 .org 0x7F78
182 ////////////////////////////// DOS EXE code ///////////////////////////////////
184 exestart:
185 cld
186 movw 129, %ax
187 cmpb $0x2F, %al
188 je ishelp
189 cmpw $0x2F20, %ax
190 ishelp:
191 movw $0x3000+EXESTR(help), %ax
192 cwd // clear dx
193 pushw %dx // dos exit()
194 je abort
195 int $0x21 // get DOS version
196 addb $-3, %al
197 movb $EXESTR(noDOS3), %al
198 movw $0x100, %di
199 jc tst386
200 abort:
201 goputs:
202 mov $EXEADRS(puts), %si
203 jmp *%si
205 tst386:
206 pushw %sp
207 popw %ax
208 xorw %sp, %ax // clear C
209 movb $EXESTR(vm86modemsg), %al
210 jnz is86 // 86/186 not a 286+
211 .arch i486
212 is386:
213 smsww %bx // not privileged
214 andb $1, %bl // clear C
215 jne isvm86
216 movl %cr0, %ebx // privileged
217 incl %ebx
218 .arch i8086
219 movb $EXESTR(rmPaging), %al
220 js abort
221 is86:
222 incw %ax
223 //movb $EXESTR(realmodemsg), %al
224 isvm86:
225 call goputs
226 movw comstart-end_header(%di), %si // .com address
227 pushw %di
228 movb $0x7C/2, %ch // 31K-31.5K, > com length
229 movb $0x80, %bh
230 movw $0xA5F3, (%bx) // rep movsw
231 movb $0xC3, 2(%bx) // ret
232 jmp *%bx
234 vm86modemsg:
235 // --------------- Must be in 7F40 7FFF range ------------------------
236 .ascii "v" // v86 mode
237 .ascii "86" // 86 mode
238 .byte EXESTR(mode)
239 rmPaging:
240 .ascii "X" // Xreal mode
241 realmodemsg:
242 .ascii "real" // real mode
243 // --------------- Must be in 7FC0 7FFF range ------------------------
244 mode:
245 .ascii " m"
246 ode:
247 .ascii "ode"
248 .byte EXESTR(eol)
249 noDOS3:
250 .ascii "DOS3" // DOS3?
251 need:
252 .ascii "?"
253 .byte EXESTR(eol)
254 help:
255 .ascii "SliTaz iso boot." // SliTaz iso boot.
256 eol:
257 .ascii "\r\n"
258 .byte 1 // puts will return
260 .space 16,0 // ISO md5
261 .org 0x8000
262 ////////////////////////// ISO9660 header /////////////////////////////////////