wok-current view syslinux/stuff/iso2exe/bootiso.S @ rev 19429

syslinux/bootiso.S: typos
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 01 10:57:42 2016 +0200 (2016-10-01)
parents 087d71ec38ce
children 7a16da2c93b9
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 fdcnt: // Overlay number
28 .byte 0 // Bootstrap floppy sector count
29 .ascii "slitaz"
31 /////////////////////// Master Boot Record code //////////////////////////////
33 moved = 0x8000
34 start0:
35 pushw %dx // restore %sp
36 incw %bp // restore %bp
37 xorw %bx, %bx
38 movw %bx, %ds
39 movb $0x7C, %bh
40 pushw %bx // return address
41 pushaw
42 movw %sp, %bp
43 pushw %es // save %es:%di
44 cld
45 sti
46 pushw %ds
47 popw %es
48 call setreg
49 rep
50 movsw
51 movw $0x80, %dx
52 ljmp $0, $moved+start2
53 .byte 0
54 // .org 60
55 // .long 0x0080 // PE header offset
56 .org 64
57 end_header:
58 comstart:
59 .word 0
61 .org 66
62 dxloop:
63 start2:
64 call readsector1 // look for the boot device
65 repe
66 cmpsw
67 je dxfound
68 movb $0, %cl // ch = 0
69 addb $0x7D, %dl // try every hard disk
70 jno dxloop
72 dxfound:
73 call readsectorX // read isolinux boot sector
74 movw %dx, 10(%bp)
75 cmpw (%bx), %cx
76 jnc puts // read fail or no isohydrid boot sector
77 popw %es
78 popa // isolinux boot needs %es:%di and %dx
79 putsret:
80 ret
82 putstrlp:
83 movw $7, %bx
84 movb $0xE, %ah
85 int $0x10
86 error:
87 lodsb
88 cmp $1, %al
89 jg putstrlp
90 jz putsret
91 puts:
92 movb $0x80, %ah
93 xchgw %ax, %si
94 jnc error
95 halt:
96 hlt
97 jmp halt
98 nobsmsg:
99 .asciz "No isolinux."
101 .org 0x0080
102 ////////////////////////////// EXE/PE header //////////////////////////////////
104 .org 0x01A0
105 readsectorX: // read isolinux boot sector
106 movb $0xA5, %cl // patched by installer
107 readsector1:
108 andb $0x83, %dl // disk and floppy disk
109 movw %cx, (%bx)
110 incw %cx
111 movw $0x201, %ax
112 int $0x13
113 setreg:
114 movw %bx, %si
115 movw $moved, %di
116 movw $0x0100, %cx
117 movb $nobsmsg, %al
118 ret
119 .org 0x01B8
121 .org 0x7F48
122 ////////////////////////////// DOS EXE code ///////////////////////////////////
124 exestart:
125 cld
126 movw $EXEADRS(puts), %bp
127 movw 129, %ax
128 cmpb $0x2F, %al
129 je ishelp
130 cmpw $0x2F20, %ax
131 ishelp:
132 movw $0x3000+EXESTR(help), %ax
133 cwd // clear dx
134 pushw %dx // dos exit()
135 je abort
136 int $0x21 // get DOS version
137 addb $-3, %al
138 movw $0x1000+EXESTR(noDOS3), %ax
139 jc tst386
140 abort:
141 jmp *%bp
143 tst386:
144 pushfw // save flags
145 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
146 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
147 // movb $0x10, %ah
148 pushw %ax
149 popfw // < 286 : flags[12..15] are forced 1
150 pushfw // = 286 : flags[12..15] are forced 0
151 popw %bx // > 286 : only flags[15] is forced 0
152 popfw // restore flags (IOPL)
153 addb %ah, %bh // test F0 and 00 cases
154 cmpb %ah, %bh
155 movw $0x100, %di
156 jbe is86 // C=8086/80186, Z=80286
157 is386:
158 smsww %ax // not privileged
159 andb $1, %al
160 movw $10, %si
161 jne tstvcpi
162 movl %cr0, %eax // privileged
163 incl %eax
164 movb $EXESTR(rmPaging), %al
165 js abort
166 inc %ax
167 //movb $EXESTR(realmodemsg), %al
168 realmode:
169 call *%bp
170 is86:
171 movw comstart-end_header(%di), %si // .com address
172 pushw %di
173 movb $0x7C/2, %ch // 31K-31.5K, > com length
174 rep
175 movsw
176 ret
178 CallVCPI:
179 int $0x67
180 testb %ah, %ah
181 xchgw %ax, %cx
182 pushw %si
183 ScanVCPI:
184 popw %si
185 ChkVCPI:
186 NoVCPI:
187 movb $EXESTR(ERRvcpi), %al
188 jne abort
189 lodsb
190 shlw $8, %ax
191 jne CallVCPI
192 VersionVCPI:
193 xchgw %ax, %si // movb $EXESTR(vm86modemsg), %al
194 cmpb $0x40, %cl // EMM386 / VCPI 4.0 mini
195 jnc realmode // %si = 0
196 tstvcpi:
197 pushw %ds
198 movw %si, %ds // %si = 10
199 movw (0x67*4)+2-(16*10)-0x100(%di), %ds
200 lodsw
201 xorw $0x4D45, %ax // EM(MX) or EM(MQ)
202 lodsw
203 lodsw
204 popw %ds
205 jne NoVCPI
206 xorb $0x58, %al // X(XX0)
207 call ScanVCPI
208 CmdVCPI:
209 .byte 0x40 // status
210 .byte 0xDE // vcpi present ?
211 .byte 0x46 // version
212 .byte 0
214 vm86modemsg:
215 // --------------- Must be in 7F40 7FFF range ------------------------
216 .ascii "86" // 86 mode
217 .byte EXESTR(mode)
218 ERRvcpi:
219 .ascii "VCPI4" // VCPI4?
220 .byte EXESTR(need)
221 rmPaging:
222 .ascii "X" // Xreal mode
223 realmodemsg:
224 .ascii "real" // real mode
225 // --------------- Must be in 7FC0 7FFF range ------------------------
226 mode:
227 .ascii " m"
228 ode:
229 .ascii "ode"
230 .byte EXESTR(eol)
231 noDOS3:
232 .ascii "DOS3" // DOS3?
233 need:
234 .ascii "?"
235 .byte EXESTR(eol)
236 help:
237 .ascii "SliTaz iso boot" // SliTaz iso boot
238 eol:
239 .ascii "\r\n"
240 .byte 1 // puts will return
242 .space 16,0 // ISO md5
243 .org 0x8000
244 ////////////////////////// ISO9660 header /////////////////////////////////////