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

syslinux/iso2exe: tiny typo
author Paul Issott <paul@slitaz.org>
date Sun Apr 07 20:27:24 2013 +0100 (2013-04-07)
parents 5ed4d6b2d690
children 3e7ad70145ce
line source
1 .text
2 .code16
3 .org 0
5 CODESZ = 0x8000 // 16 sectors = 32Kb
6 #define EXEADRS(x) x+0xC0
7 #define EXELOC(x) x-0x40
8 #define EXESTR(x) x-0x7F40
10 .globl _start
11 _start:
12 decw %bp // Magic number: MZ
13 popw %dx
14 jmp start0 // Bytes on last page of file
15 .word (CODESZ+511)/512 // Pages in file
16 .word 0 // Relocations
17 .word (end_header-_start)/16 // Size of header in paragraphs
18 .word 4064-(CODESZ/16) // Minimum extra paragraphs needed
19 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed
20 .word 0xFFF0 // Initial (relative) SS value
21 .word 0xFFFE // Initial SP value
22 .word 0 // Checksum
23 .word EXEADRS(exestart) // Initial IP value
24 .word 0xFFF0 // Initial (relative) CS value
25 initramfssize:
26 .word 0 // File address of relocation table
27 id:
28 .word 0 // Overlay number
29 fdcnt:
30 .byte 0 // Bootstrap floppy sector count
32 /////////////////////// Master Boot Record code //////////////////////////////
34 start0: // File address of relocation table
35 pushw %dx // restore SP
36 incw %bp // restore %bp
37 pushw $0
38 popw %ds
39 movw $0x7C00, %bx
40 pushfw
41 pushw %ds
42 pushw %bx
43 pushaw
44 movw %sp, %bp
45 pushw %es
46 cld
47 pushw %ds
48 popw %es
49 call setreg
50 rep
51 movsw
52 movw $0x80, %dx
53 ljmp $0, $0x0600+start2
55 .org 60
56 .long 0x0080 // PE header offset
57 end_header:
58 chksum:
59 .word 0
60 comstart:
61 .word 0
63 readsectorX:
64 movb $0, %cl
65 readsector1:
66 movw %cx, (%bx)
67 incw %cx
68 movw $0x201, %ax
69 int $0x13
70 setreg:
71 movw %bx, %si
72 movw $0x0600, %di
73 movw $0x0100, %cx
74 return:
75 ret
76 start2:
77 dxloop:
78 call readsector1
79 repe
80 cmpsw
81 je dxfound
82 next:
83 xorw %cx, %cx
84 xchgw %ax, %dx
85 addb $0x7D, %al // try every hard disk
86 andb $0x83, %al // and floppy disk
87 cmpb $0x80, %al
88 xchgw %ax, %dx
89 jnz dxloop
90 dxfound:
91 movw %dx, 10(%bp)
92 call checkboot
93 noboot:
94 .ascii "No isolinux mbr."
95 noboot_end:
97 .org 0x0080
98 ////////////////////////////// EXE/PE header //////////////////////////////////
100 .org 0x01A0
101 checkboot:
102 call readsectorX
103 lodsw
104 popw %si
105 shrw $1, %ax
106 jz error // read fail or not isohydrid
107 popw %es
108 popa
109 iret
111 error:
112 movw $noboot_end-noboot, %cx
113 putsloop:
114 lodsb
115 movw $7, %bx
116 movb $0xE, %ah
117 int $0x10
118 loop putsloop
119 halt:
120 hlt
121 jmp halt
122 .org 0x01BE
124 .org 0x7EE0
125 ////////////////////////////// DOS EXE code ///////////////////////////////////
127 exestart:
128 cld
129 movw $0x100, %si
130 movw -127(%si), %ax
131 cwd // clear dx
132 pushw %dx // dos exit
133 cmpw $0x2F20, %ax
134 movw $0x1000+EXESTR(help), %ax
135 je abort
136 pushfw // save flags
137 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
138 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
139 // movb $0x10, %ah
140 pushw %ax
141 popfw // < 286 : flags[12..15] are forced 1
142 pushfw // = 286 : flags[12..15] are forced 0
143 popw %cx // > 286 : only flags[15] is forced 0
144 popfw // restore flags
145 addb %ah, %ch // test F0 and 00 cases
146 cmpb %ah, %ch
147 movb $EXESTR(no386), %al
148 jbe abort // C=8086/80186, Z=80286
149 #if 1
150 movw (%si), %cx
151 jcxz is386
152 #endif
153 movw $(EXELOC(0x8000))/2, %cx
154 chklp:
155 lodsw
156 addw %ax, %dx
157 loop chklp
158 movb $EXESTR(chkerr), %al
159 je is386 // dx == 0 ?
160 abort:
161 puts:
162 movb $0x80, %ah
163 xchgw %ax, %si
164 putslp:
165 lodsb
166 orb %al, %al
167 jz moveret
168 js puts
169 movw $7, %bx
170 movb $0xE, %ah
171 int $0x10
172 jmp putslp
174 is386:
175 movl %cr0, %eax
176 andb $1, %al
177 jne tstvcpi
178 incl %eax
179 movb $EXESTR(rmPaging), %al
180 js abort
181 movb $EXESTR(realmodemsg), %al
182 realmode:
183 call puts
184 movb $0x30, %ah
185 int $0x21
186 cmpb $3, %al
187 movb $EXESTR(noDOS3), %al
188 jb abort
189 movw $0x0100, %di
190 movw comstart-end_header(%di), %si // .com address
191 pushw %di
192 movb $0x7D, %ch
193 rep
194 movsb
195 moveret:
196 ret
198 VersionVCPI:
199 cmpb $0x40, %dl // >= 4.0 ?
200 jb NoVCPI
201 movb $EXESTR(vm86modemsg), %al
202 jmp realmode
203 tstvcpi:
204 pushw %ds
205 movw %cx, %ds // %cx = 0
206 movw 0x67*4+2, %ds
207 movw $10, %si
208 lodsl
209 xorw $0x4D45, %ax // EM(MX) or EM(MQ)
210 lodsl
211 popw %ds
212 jne NoVCPI
213 xorl $0x30585858, %eax // XXX0
214 movw $EXEADRS(CmdVCPI), %si
215 ChkVCPI:
216 NoVCPI:
217 movb $EXESTR(ERRvcpi), %al
218 jne abort
219 lodsb
220 shlw $8, %ax
221 je VersionVCPI
222 int $0x67
223 testb %ah, %ah
224 xchgw %ax, %dx
225 jmp ChkVCPI
226 CmdVCPI:
227 .byte 0x40 // status
228 .byte 0xDE // vcpi present ?
229 .byte 0x46 // version
230 .byte 0
232 // -------------------------------------------------------------------
234 help:
235 .ascii "SliTaz GNU/L" // SliTaz GNU/Linux boot loader
236 .byte EXESTR(iloader)
237 no386:
238 .ascii "No 386" // No 386+
239 .byte EXESTR(plus)
240 ERRvcpi:
241 .ascii "No EMM386/VCPI 4" // No EMM386/VCPI 4.0+
242 .byte EXESTR(dot0)
243 chkerr:
244 .ascii "Broken ISO image fil" // Broken ISO image file.
245 .byte EXESTR(eeol)
246 vm86modemsg:
247 .ascii "vm86" // vm86 mode.
248 .byte EXESTR(mode)
249 rmPaging:
250 .ascii "Invalid: paging + " // Invalid: paging + real mode.
251 realmodemsg:
252 .ascii "real" // real mode.
253 // --------------- Must be in 00C0 013F range ------------------------
254 mode:
255 .ascii " mod"
256 eeol:
257 .ascii "e"
258 .byte EXESTR(eol)
259 //noloader:
260 // .ascii "No isol" // No isolinux boot loader
261 iloader:
262 .ascii "inux boot loader"
263 eol:
264 .ascii "."
265 eol2:
266 .asciz "\r\n"
267 noDOS3:
268 .ascii "No DOS 3" // No DOS 3.0+
269 dot0:
270 .ascii ".0"
271 plus:
272 .ascii "+"
273 .byte EXESTR(eol2)
275 .org 0x8000
276 ////////////////////////// ISO9660 header /////////////////////////////////////