wok view linld/stuff/src/pipehole.awk @ rev 21784

Update powermanga (thanks Rene Rivero)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jul 21 10:32:10 2019 +0200 (2019-07-21)
parents d8f824013cf6
children 04ffefac5707
line source
1 BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0; label="none"; xlabel="" }
2 function isnum(n) { return match(n,/^[0-9+-]/) }
3 {
4 sub(/segment word public/,"segment byte public")
6 if (/^@.*:$/ || / endp$/) afterjmp=0
7 if (/dword ptr/) is386=1
8 sub(/DGROUP:_imgs\+65534/,"[di-2]")
9 if (/fallback\)\[1\] == 0/) isload=8
10 if (isload == 8) { # LOAD.LST
11 if (/load_image/) isload=0
12 else next
13 }
14 if (/cmd_line_ptr =/ && is386 == 0) isload=7
15 if (isload == 7) { # LOAD.LST
16 if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/) next
17 if (/,ax/) {
18 sub(/ax/,"8000h")
19 isload=0
20 }
21 if (/,dx/) {
22 print " mov cl,12"
23 print " shr ax,cl"
24 sub(/dx/,"ax")
25 }
26 }
27 if (/\[0\] = m-\>fallback/) isload=6
28 if (isload == 6) { # LOAD.LST
29 if (/si\+2/) {
30 print " inc si"
31 $0=" inc si"
32 }
33 if (/les/) sub(/bx,/,"ax,")
34 if (/bx\+4/ || /es:/) {
35 if (/bx\+4/) isload=0
36 next
37 }
38 if (/si\+6/) {
39 print " xchg ax,di"
40 print " movsw"
41 print " movsw"
42 print " movsw"
43 print " movsw"
44 print " xchg ax,di"
45 next
46 }
47 }
48 if (/version_string = /) isload=5
49 if (isload == 5) { # LOAD.LST
50 sub(/ax,/,"bx,")
51 if (/_version_string,/) isload=0
52 if (/mov bx,ax/) next
53 }
54 if (/topseg\(\)>>12/) isload=4
55 if (isload == 4 && is386 == 0) { # LOAD.LST
56 if (/push/ || /pop/) next
57 if (/ax,cs/) {
58 print " cwd"
59 sub(/ax,cs/,"bx,cs")
60 }
61 if (/dx,dx/) next
62 sub(/ax,dx/,"ax,bx")
63 if (/call/) {
64 print " cmp ax,0fffh"
65 print " jae @sys@ok"
66 print " mov ax,0fffh"
67 print "@sys@ok:"
68 isload=400
69 }
70 }
71 if (isload == 400 && /,0/) {
72 sub(/,0/,",dh")
73 isload=0
74 }
75 if (isload == 4 && is386) { # LOAD.LST
76 sub(/dx,cs/,"edx,cs")
77 sub(/eax/,"edx")
78 if (/shl/) {
79 print " mov ax,0fffh"
80 print " cmp dx,ax"
81 print " jae @sys@ok"
82 print " xchg ax,dx"
83 print "@sys@ok:"
84 }
85 sub(/ax,9/,"dx,9")
86 if (/,0$/) sub(/,0/,",dh")
87 if (/movzx/) next
88 if (/fallback = base_himem/) { isload=0 }
89 }
90 if (/void load_initrd\(\)/) isload=3
91 if (isload == 3) { # LOAD.LST
92 if(/push di/ || /pop di/) next
93 sub(/\[di/,"[bx")
94 sub(/\di,/,"bx,")
95 }
96 if (/vid_mode = vid_mode/) isload=2
97 if (isload == 2) { # LOAD.LST
98 sub(/,0/,""); sub(/cmp /,"mov cx,")
99 sub(/je/,"jcxz")
100 if (/ax,word/) next
101 sub(/,ax/,",cx")
102 if (/version_string/ || /starting linux 1\.3\.73/) isload=0
103 }
104 if (/_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1
105 if (isload == 1) { # LOAD.LST
106 if (/mov al,byte ptr/ && is386) {
107 print " movzx eax,byte ptr [si]"
108 next
109 }
110 if (/ax,word ptr/) next
111 if (/^ call/) isload=0
112 }
113 if (/CD001/) isiso=7
114 if (isiso == 7) { # ISO9660.LST
115 sub(/mov ax,-1/,"dec ax")
116 if (/jmp/) isiso=0
117 }
118 if (/int len =/) isiso=6
119 if (isiso == 6) { # ISO9660.LST
120 if (/dx,ax/) next
121 sub(/ax/,"dx")
122 sub(/cx,di/,"bx,di")
123 sub(/cx,dx/,"bx,ax")
124 sub(/di,dx/,"di,ax")
125 if (/while/) isiso=2
126 }
127 if (/entrysize =/) isiso=5
128 if (isiso == 5) { # ISO9660.LST
129 if (/ax,ax/) next
130 sub(/ax/,"cx")
131 sub(/je/,"jcxz")
132 if (/return/) isiso=0
133 }
134 if (/x->curdirsize == 0xFFFF/) isiso=4
135 if (isiso == 4) { # ISO9660.LST
136 sub(/DGROUP:_isostate\+18/,"[si+18]")
137 sub(/DGROUP:_isostate\+20/,"[si+20]")
138 if (/goto restarted/) isiso=0
139 }
140 if (/do s\+\+; while/) isiso=3
141 if (/for \(p = s; \*s && \*s \!=/) isiso=3
142 if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST
143 sub(/cmp byte ptr \[.i\]/,"sub al")
144 if (/mov byte ptr \[bp-5\],al/) $0=" push ax"
145 if (/mov al,byte ptr \[bp-5\]/) $0=" pop ax"
146 if (/inc /) { r=$2; print; next }
147 if (/al,0/) print " mov al,[" r "]"
148 if (/al,byte ptr/) sub(/mov/,"xchg")
149 if (/byte ptr \[.*\],0/) next
150 if (/jmp/) print " mov bx,si"
151 if (/word ptr \[bp-4\]/) next
152 if (/\) s\+\+;/ || /\],-1/) isiso=0
153 }
154 if (/endname = NULL/) isiso=2
155 if (isiso == 2) { # ISO9660.LST
156 if (/mov bx,cx/) next
157 gsub(/cx/,"bx")
158 sub(/DGROUP:_isostate\+35/,"[si+35]")
159 }
160 if (/const char \*n = name/) isiso=1
161 if (isiso == 1) { # ISO9660.LST
162 if ((/mov word ptr \[si\+32\],ax/ ) ||
163 (/mov ax,word ptr \[si\+2\]/) ||
164 (/bx,word ptr \[si\+32\]/) || (/ax,dx/)) next
165 if (/dx,/) sub(/dx/,"ax")
166 if ((/sub ax,word ptr \[si\+2\]/) ||
167 (/\[si\+16\]/) || (/ax,di/)) sub(/ax/,"bx")
168 if (/add word ptr \[si\+32\],ax/) $0=" add bx,word ptr [si+16]"
169 if (/al,/ || /,al/) sub(/al/,"cl")
170 if (/cmp byte ptr \[si\+34\],0/) $0=" or cl,cl"
171 if (/jne @@0$/) next
172 if (/jmp @3@58$/) $0=" je @3@58"
173 sub(/mov ax,-1/,"dec ax")
174 }
175 if (/endp/) { xlabel = ""; goto2=0 }
176 if (/isoopen\(s\+7\)/ && xlabel == "") goto2=1
177 if (/_vid_mode,ax/ && xlabel == "") goto2=1
178 if (/_base_himem\+2,/ && xlabel == "@") goto2=1
179 if (/puts\(cmdline\)/ && xlabel == "@@") goto2=1
180 if (goto2 == 1 && /jmp/) { # TAZBOOT.LST && LINLD.LST
181 print $NF xlabel "@:"
182 label=$NF
183 }
184 if (goto2 > 0 && label == $NF) {
185 $0=$0 xlabel
186 if (goto2++ == 1) xlabel=xlabel "@"
187 }
188 if (/cmdline=s\+=3/ || /magic \!= 0/ || /&root_dev =/) { isotazboot=10; j="" }
189 if (isotazboot == 10) { # TAZBOOT.LST && LINLD.LST
190 if (/je/ || /jne/) { j=$1; next }
191 if (/jmp/) {
192 if (j=="jne") sub(/jmp/,"je")
193 else if (j=="je") sub(/jmp/,"jne")
194 isotazboot=0
195 }
196 }
197 if (/static const unsigned long initrddesc = 18L/) isotazboot=9
198 if (isotazboot == 9) { # TAZBOOT.LST
199 if (/,0/) {
200 split($4,y,",")
201 print " mov bx,offset " y[1]
202 }
203 if (/DGROUP:.*\+6,46/) {
204 sub(/DGROUP:.*\+6,/,"[bx+6],")
205 isotazboot=0
206 }
207 if (/mov/) $0=" mov si,bx"
208 sub(/DGROUP:.*,/,"[bx],")
209 }
210 if (/isoopen\(s\+7\) != -1/) isotazboot=8
211 if (isotazboot == 8) { # TAZBOOT.LST
212 if (/ax,si/) next
213 sub(/ax,ax/,"si,si")
214 if (/magic/) isotazboot=0
215 }
216 if (/\+\+isknoppix/) isotazboot=7
217 if (isotazboot == 7) { # TAZBOOT.LST
218 if (/al,byte/) sub (/al,byte ptr DGROUP:/,"bx,offset ")
219 if (/inc/) sub (/al/,"word ptr [bx]")
220 if (/,al/) next
221 if (/isokernel/) isotazboot=0
222 }
223 if (/if \(c\) s\+\+;/) isotazboot=6
224 if (isotazboot == 6) { # TAZBOOT.LST
225 if (/cmp/) {
226 $0=" cmp al,0"
227 isotazboot=0
228 }
229 }
230 if (/static void next_chunk/) isotazboot=5
231 if (isotazboot == 5 || isotazboot == 500) { # TAZBOOT.LST
232 if (/cx,ax/) $0=" xchg ax,bx"
233 if (/ax,word ptr \[si\+28\]/ && isotazboot == 500) next
234 if (/bx,cx/) next
235 if (/push/ || /pop/ || /bp,sp/ || /si,/) next
236 sub(/\[si/,"[di")
237 if (/initrd_info/) isotazboot=500
238 if (/endp/) isotazboot=0
239 }
240 if (/0x7FF0/) isotazboot=4
241 if (isotazboot == 4) { # TAZBOOT.LST
242 if (/ax,word ptr/) {
243 print " mov ax,32752"
244 print " cwd"
245 sub(/mov/,"sub")
246 }
247 if (/bx,/ || /cx,/ || /dx,/) next
248 sub(/,0/,",dx")
249 sub(/,bx/,",dx")
250 sub(/,cx/,",ax")
251 if (/@addinitrd\$qv/) isotazboot=0
252 }
253 if (/c = x->filename/) isotazboot=3
254 if (isotazboot == 3) { # TAZBOOT.LST
255 if (/ax,/) $0=" xchg ax,bx"
256 if (/\]$/) next
257 if (/@strcpy\$qpxzct1/) isotazboot=0
258 }
259 if (/base_himem = memtop/) isotazboot=2
260 if (isotazboot == 2) { # TAZBOOT.LST
261 if (/@6@226/ || /mov ax,1/ || /@6@254/ || /xor ax,ax/) next
262 if (/word ptr \[bx\+2\],0/) {
263 print s; hold=0
264 print " mov bx,word ptr [bx+2]"
265 $0=" or bx,bx"
266 }
267 if (/\[bp-4\],ax/) sub(/ax/,"bx")
268 if (/ax,word ptr \[bx\+2\]/ || /bx,ax/) next
269 if (/@strcmp\$qpxzct1/) isotazboot=0
270 }
271 if (/static void addinitrd/) isotazboot=100
272 if (isotazboot == 100) { # TAZBOOT.LST
273 if (/cx,ax/) {
274 print " mov si,offset _isostate+8"
275 print " push ds"
276 print " pop es"
277 print " xchg ax,di"
278 print " movsw"
279 print " movsw"
280 print " movsw"
281 print " movsw"
282 $0=" xchg ax,di"
283 }
284 if (/mov/ && !/si/ && !/cl/) next
285 if (/void load_initrds/) isotazboot=101
286 }
287 if (isotazboot == 101 || isotazboot == 102) { # TAZBOOT.LST
288 sub(/\[si/,"[di"); sub(/si,/,"di,"); sub(/si$/,"di")
289 sub(/DGROUP:_imgs\+38$/,"[di+38-32]")
290 sub(/DGROUP:_imgs\+40$/,"[di+40-32]")
291 if (/isofd/) isotazboot=102
292 if (/push/ && isotazboot == 102) next
293 if (/pop/ && isotazboot == 102) next
294 if (/load_initrd/) isotazboot=101
295 if (/isokernel/) isotazboot=103
296 }
297 if (isotazboot > 102) { # TAZBOOT.LST
298 if (/push/ || /pop/) next
299 sub(/\[si/,"[bx")
300 sub(/si,/,"bx,")
301 if (/static void bootiso/) isotazboot=0
302 }
303 if (wascall) {
304 if (rcall != "") {
305 if (/,ax$/) print " mov " rcall ",ax"
306 else print " xchg ax," rcall
307 wascall=0
308 }
309 else if (/^ mov .i,ax$/) {
310 split($2,y,",")
311 rcall=y[1]
312 next
313 }
314 else wascall=0
315 }
316 if (/^ call /) { wascall=1; rcall="" }
317 if (hold == 0) {
318 s=$0
319 if (/^ mov .[ix],bx$/ || /^ mov .[ix],.i$/) {
320 r=$2; kept=0
321 hold=1; split($2,regs,","); next
322 }
323 if (/^ inc e?.[ixhl]/ || /^ dec e?.[ixhl]/) {
324 hold=2; r=$2; next
325 }
326 if (/^ mov [abcds][ix],/ && ! /,.s/) {
327 hold=3; split($2,regs,","); next
328 }
329 if (/^ movzx eax,ax$/) { hold=4; next }
330 if (/^ cmp word ptr/ || /^ cmp [bcd]x,/) {
331 split($0,regs,",")
332 if (isnum(regs[2]) && regs[2] != 0 &&
333 (regs[2] % 256) == 0) {
334 hold=5; next
335 }
336 }
337 if (/^ mov ax,cs$/) { hold=6; kept=0; next }
338 if (/^ mov cl,4$/) { hold=7; next }
339 if (/^ cmp word ptr DGROUP:.*,0$/) {
340 hold=8; split($2,regs,","); next
341 }
342 if (/^ cbw/) { hold=11; kept=0; next }
343 if (/^ add [abcds][ix],2$/) {
344 split($2,regs,","); hold=12; next
345 }
346 if (/^ sub [abcds][ix],2$/) {
347 split($2,regs,","); hold=13; next
348 }
349 if (/^ push dx$/) {
350 hold=14; next;
351 }
352 }
353 else if (hold == 1) {
354 if (/^ ;/) { line[kept++]=$0; next }
355 hold=0; split($2,args,","); op=""
356 if ($1 == "add") op="+"
357 if ($1 == "sub") op="-"
358 if ($1 == "inc") { op="+"; args[2]="1"; }
359 if ($1 == "dec") { op="-"; args[2]="1"; }
360 if (op != "" && regs[1] == args[1]) {
361 if (isnum(args[2])) {
362 for (i = kept++; i > 0; i--) line[i] = line[i-1]
363 line[0] = "\tlea\t" regs[1] ",[" regs[2] op args[2] "]"
364 hold=10; next
365 }
366 line[kept++]=$0
367 hold=1
368 next
369 }
370 if (/^ pop [ds]i/ && regs[2] ~ /^[ds]i$/) {
371 print " xchg " r
372 }
373 else print s
374 for (i = 0; i < kept; i++) print line[i]; kept=0
375 }
376 else if (hold == 2) {
377 split($0,args,",")
378 if (/^ mov / && r == args[2]) { print s; s=$0; next }
379 split($2,args,",")
380 hold=0; print s
381 if ($1 == "or" && r == args[1] && r == args[2]) next # don't clear C ...
382 }
383 else if (hold == 3) {
384 hold=0
385 if (/^ call / && regs[2] == "ax") s=" xchg ax," regs[1]
386 if (/^ add [abcds][ix],/) {
387 split($2,regs2,",")
388 if (regs[1] == regs2[1] && (regs2[2] == "offset" || isnum(regs2[2]))) {
389 t=$0; sub(/mov/,$1,s); sub(/add/,"mov",t)
390 print t; print s; next
391 }
392 }
393 print s
394 }
395 else if (hold == 4) {
396 hold=0
397 if (/^ push eax$/) {
398 print " push 0"; print " push ax"; next
399 } else { print s }
400 }
401 else if (hold == 5) {
402 hold=0
403 if ($1 == "jae" || $1 == "jb") {
404 sub(/word ptr/,"byte ptr",s); sub(/x,/,"h,",s) ||
405 sub(/\],/,"+1],",s) || sub(/,/,"+1,",s)
406 s = s "/256"
407 }
408 print s
409 }
410 else if (hold == 6) {
411 if (($1 == "and" || $1 == "add") && $2 ~ /^ax,/) {
412 line[kept++]=$0
413 next
414 }
415 p=$0
416 if (/^ movzx eax,ax$/) {
417 s=" mov eax,cs"; p=""
418 }
419 print s
420 for (i = 0; i < kept; i++) print line[i]; kept=0
421 if (p != "") print p
422 hold=0; next
423 }
424 else if (hold == 7) {
425 hold=0
426 if (/^ call near ptr N_LXURSH@$/) {
427 print " extrn N_LXURSH@4:near"
428 print " call near ptr N_LXURSH@4"
429 next
430 }
431 if (/^ call near ptr N_LXLSH@$/) {
432 print " extrn N_LXLSH@4:near"
433 print " call near ptr N_LXLSH@4"
434 next
435 }
436 print s
437 }
438 else if (hold == 8) {
439 if ($1 == "je" || $1 == "jne") { p=$0; hold=9; next }
440 hold=0
441 print s
442 }
443 else if (hold == 9) {
444 hold=0; split($2,args,",")
445 if (/^ mov ax,/ && args[2] == regs[1]) {
446 print; print " or ax,ax"; print p; next
447 }
448 print s; print p;
449 }
450 else if (hold == 10) {
451 split($2,args,","); op=""
452 if ($1 == "add") op="+"
453 if ($1 == "sub") op="-"
454 if ($1 == "inc") { op="+"; args[2]="1"; }
455 if ($1 == "dec") { op="-"; args[2]="1"; }
456 if (op != "" && isnum(args[2])) {
457 split(line[0],reg,",")
458 if (substr(reg[1],length(reg[1])-1,2) == args[1]) {
459 line[0] = substr(line[0],1,length(line[0])-1) op args[2] "]"
460 next
461 }
462 }
463 hold=0
464 if (/^ mov [sd]i,ax$/) {
465 split($2,args,",")
466 for (i = 0; i < kept; i++) {
467 sub(/ax/,args[1],line[i]); print line[i]
468 }
469 next
470 }
471 for (i = 0; i < kept; i++) print line[i]
472 }
473 else if (hold == 11) {
474 if (/^ inc ax$/ || /^ dec ax$/) {
475 line[kept++]=$0; next
476 }
477 split($2,args,",")
478 if (/^ mov cl,/) {
479 split($2,args,",")
480 if (args[2] >= 8) {
481 line[kept++]=$0; next
482 }
483 }
484 if (!/^ shl ax,/ || (args[2] != "cl" && args[2] < 8)) {
485 print " cbw "
486 }
487 for (i = 0; i < kept; i++) print line[i]
488 hold=kept=0
489 }
490 else if (hold == 12) {
491 hold=0
492 if ($1 != "adc" && $1 != "sbb" && ! /^ jn?[abc]/) {
493 print " inc " regs[1]
494 print " inc " regs[1]
495 }
496 else print " add " regs[1] ",2"
497 }
498 else if (hold == 13) {
499 hold=0
500 if ($1 != "adc" && $1 != "sbb" && ! /^ jn?[abc]/) {
501 print " dec " regs[1]
502 print " dec " regs[1]
503 }
504 else print " sub " regs[1] ",2"
505 }
506 else if (hold == 14) {
507 if (/^ push ax$/) { hold++; next; }
508 print " push dx";
509 hold=0;
510 }
511 else if (hold == 15) {
512 if (/^ pop eax$/) { hold++; next; }
513 print " push dx";
514 print " push ax";
515 hold=0;
516 }
517 else if (hold == 16) {
518 hold=0;
519 if (/^ shr eax,16$/) { print " xchg ax,dx"; next; }
520 print " push dx";
521 print " push ax";
522 print " pop eax";
523 }
524 else if (hold == 17) {
525 hold=0;
526 if (/^ cmp ax,-1$/) { print " inc ax"; next; }
527 }
528 if (/^ call near ptr @fileexist\$/ || # return boolean :
529 /^ call near ptr @isoreaddir\$/ || # 0=true, -1=false
530 /^ call near ptr @isoreset\$/ ||
531 /^ call near ptr @isoopen\$/ ||
532 /^ call near ptr @isoreadsector\$/ ||
533 /^ call near ptr @strhead\$/ ||
534 /^ call near ptr @argstr\$/ ||
535 /^ call near ptr @argnum\$/) { print; hold=17; next; }
536 s=$0
537 # These optimisation may break ZF or CF
538 if (/^ sub sp,2$/) { print " push ax"; next }
539 if (/^ sub sp,4$/) { print " push ax"; print " push ax"; next }
540 if (/^ add sp,4$/) { print " pop cx"; print " pop cx"; next }
541 if (/^ mov d*word ptr .*,0$/ || /^ mov dword ptr .*,large 0$/) {
542 sub(/mov/,"and",s); print s; next # slower
543 }
544 if (/^ mov d*word ptr .*,-1$/ || /^ mov dword ptr .*,large -1$/) {
545 sub(/mov/,"or",s); print s; next # slower
546 }
547 if (/^ or .*,0$/ || /^ and .*,-1$/) next
548 if (/^ or [abcd]x,/) {
549 split($2,args,",")
550 if (isnum(args[2]) && args[2] >= 0 && args[2] < 256) {
551 print " or " substr(args[1],1,1) "l," args[2]; next
552 }
553 }
554 if (/^ and [abcd]x,/) {
555 split($2,args,",")
556 if (isnum(args[2]) && args[2] >= -256 && args[2] < 0) {
557 print " and " substr(args[1],1,1) "l," args[2]; next
558 }
559 }
560 if (/^ or e[abcd]x,/) {
561 split($2,args,",")
562 if (args[2] == "large") { args[2] = $3 }
563 if (isnum(args[2]) && args[2] >= 0 && args[2] < 256) {
564 print " or " substr(args[1],2,1) "l," args[2]; next
565 }
566 }
567 if (/^ and e[abcd]x,/) {
568 split($2,args,",")
569 if (args[2] == "large") { args[2] = $3 }
570 if (isnum(args[2]) && args[2] >= -256 && args[2] < 0) {
571 print " and " substr(args[1],2,1) "l," args[2]; next
572 }
573 }
574 if (/^ or e[abcds][ix],/) {
575 split($2,args,",")
576 if (args[2] == "large") { args[2] = $3 }
577 if (isnum(args[2]) && args[2] >= 0 && args[2] < 65536) {
578 print " or " substr(args[1],2) "," args[2]; next
579 }
580 }
581 if (/^ and e[abcds][ix],/) {
582 split($2,args,",")
583 if (args[2] == "large") { args[2] = $3 }
584 if (isnum(args[2]) && args[2] >= -65536 && args[2] < 0) {
585 print " and " substr(args[1],2) "," args[2]; next
586 }
587 }
588 if (/^ add word ptr/ || /^ sub word ptr/ ||
589 /^ add [bcd]x,/ || /^ sub [bcd]x,/) {
590 split($0,args,",")
591 if (isnum(args[2]) && (args[2] % 256 == 0)) {
592 sub(/word ptr/,"byte ptr",s); sub(/x,/,"h,",s) ||
593 sub(/\],/,"+1],",s) || sub(/,/,"+1,",s)
594 print s "/256"; next
595 }
596 }
597 if (/^ add dword ptr/ || /^ sub dword ptr/) {
598 split($0,args,",")
599 if (args[2] == "large") { args[2] = $3 }
600 if (isnum(args[2])) {
601 if (args[2] % 16777216 == 0) {
602 sub(/dword/,"byte",s)
603 sub(/\],/,"+3],",s) || sub(/,/,"+3,",s)
604 print s "/16777216"; next
605 }
606 if (args[2] % 65536 == 0) {
607 sub(/dword/,"word",s)
608 sub(/\],/,"+2],",s) || sub(/,/,"+2,",s)
609 print s "/65536"; next
610 }
611 }
612 }
613 if (/^ mov e.x,/) {
614 split($2,args,",")
615 r=args[1]
616 if (args[2] == "large") { args[2] = $3 }
617 if (isnum(args[2]) && args[2] % 65536 == args[2]) {
618 if (args[2] % 256 == args[2] || args[2] % 256 == 0) {
619 print " xor " r "," r
620 if (args[2] == 0) next
621 x=" mov " substr(r,2,1)
622 if (args[2] % 256 == 0) {
623 print x "h," args[2] "/256"
624 }
625 else { print x "l," args[2] }
626 next
627 }
628 }
629 }
630 if (afterjmp) print ";" $0
631 else print
632 if (/^ jmp / || /^ call near ptr _boot_kernel/ ||
633 /^ call near ptr @die$qpxzc/) afterjmp=1
634 }