ast@cs.vu.nl (Andy Tanenbaum) (06/12/91)
echo x - asld_to_xenix sed '/^X/s///' > asld_to_xenix << '/' X# Conversion from PC/IX assembler to Xenix assembler. X X# asld_to_xenix file.x >file.s X X X X# Check for args Xcase $# in X1) ;; X*) echo "Usage: $0 oldfile >newfile X exit 1 X ;; Xesac X X Xsed -e ' X:start Xs/^\([^|]*\)!/\1~/g X/^[ ]*!/{ Xp Xd X} X/^[_a-zA-Z][_a-zA-Z0-9]*:/!s/^/:/ Xh Xs/^:[ ]*// Xs/^[_a-zA-Z][_a-zA-Z0-9]*:[ ]*// Xs/^\.byte\([ ]\)/.data1\1/ Xs/^\.word\([ ]\)/.data2\1/ Xs/^\.long\([ ]\)/.data4\1/ Xs/;\([ ]*\.\)byte\([ ]\)/;\1data1\2/g Xs/;\([ ]*\.\)word\([ ]\)/;\1data2\2/g Xs/;\([ ]*\.\)long\([ ]\)/;\1data4\2/g Xs/^\.globl\([ ]\)/.extern\1/ Xs/(b\([xp]\)_\([sd]\)i)/(b\1),(\2i)/g Xs/^seg[ ][ ]*\([ecsd]\)s$/\1seg/ Xs/^seg[ ][ ]*\([ecsd]\)s\([ ]\)/\1seg\2/ Xs/^in\([ ]\)/inb\1/ Xs/^in$/inb/ Xs/^out\([ ]\)/outb\1/ Xs/^out$/outb/ Xs/^stob\([ ]\)/stosb\1/ Xs/^stob$/stosb/ Xs/^stow\([ ]\)/stos\1/ Xs/^stow$/stos/ Xs/^lodb\([ ]\)/lodsb\1/ Xs/^lodb$/lodsb/ Xs/^lodw\([ ]\)/1lods\1/ Xs/^lodw$/lods/ Xs/^scab\([ ]\)/scasb\1/ Xs/^scab$/scasb/ Xs/^scaw\([ ]\)/scas\1/ Xs/^scaw$/scas/ Xs/^jc\([ ]\)/jb\1/ Xs/^jnc\([ ]\)/jnb\1/ Xs/^calli\([ ]\)/callf\1/ Xs/^jmpi\([ ]\)/jmpf\1/ Xs/^reti\([ ]\)/retf\1/ Xs/^reti$/retf/ Xs/^j\([ ]\)/jmp\1/ Xs/^br\([ ]\)/jmp\1/ Xs/^beq\([ ]\)/je\1/ Xs/^bge\([ ]\)/jge\1/ Xs/^bgt\([ ]\)/jg\1/ Xs/^bhi\([ ]\)/jnbe\1/ Xs/^bhis\([ ]\)/jnb\1/ Xs/^ble\([ ]\)/jle\1/ Xs/^blo\([ ]\)/jb\1/ Xs/^blos\([ ]\)/jbe\1/ Xs/^blt\([ ]\)/jnge\1/ Xs/^bne\([ ]\)/jne\1/ Xs/|/!/ XH Xg X/^[_a-zA-Z][_a-zA-Z0-9]*:/{ Xs/:\([ ]*\)[^ ]*.*\n/:\1/ X} X/^:/{ Xs/:\([ ]*\)[^ ]*.*\n/\1/ X}' <$1 / echo x - xenix_to_asld sed '/^X/s///' > xenix_to_asld << '/' X# This shell script converts the kernel assmebly language files from V2 X# (Xenix) format to V1 (asld) format. The call is: X# xenix_to_asld file.x >file.s X XKERDIR=/usr/src/kernel XLIBDIR=/usr/lib.old XCPPFLAGS="-DASLD -P" X Xif test -r $KERDIR; then : ; else echo Cannot read $KERDIR; exit 1; fi Xif test -r $LIBDIR; then : ; else echo Cannot read $LIBDIR; exit 1; fi Xecho DONE X X# Check for args Xcase $# in X1) ;; X*) echo "Usage: $0 file.x >file.s" X exit 1 X ;; Xesac X X# Run cpp first to handle #include and expand macros X$LIBDIR/cpp $CPPFLAGS $1 -I$KERDIR >tmp.1 X Xsed -e ' X:start X/^#/{ Xn Xbstart X} Xs/^[ ][ ]*// Xs/[!].*// Xs/[ ]*$// Xh Xs/^[_a-zA-Z][_a-zA-Z0-9]*:[ ]*// Xs/\.data1/.byte /g Xs/\.data2/.word /g Xs/\.data4/.long /g X# X# Old .globl and old .extern are mapped to new .extern. Thus it is X# not possible to simply map .extern to .globl. X# X#s/^\.extern[ ][ ]*/.globl /g Xs/(b\([xp]\)),(\([sd]\)i)/(b\1_\2i)/g Xs/^\([ecsd]\)seg$/seg \1s/g Xs/^inb\([ ]*\)/in\1/g Xs/^outb\([ ]*\)/out\1/g Xs/^stosb$/stob/g Xs/^stos$/stow/g Xs/^lodsb$/lodb/g Xs/^lods$/lodw/g Xs/^scasb$/scab/g Xs/^scas$/scaw/g Xs/^callf[ ][ ]*/calli /g Xs/^jmpf[ ][ ]*/jmpi /g Xs/^retf$/reti/ X# X# Old bcc uses j for short jumps and does not do jump sizing on jmp. X# Xs/^jmp[ ][ ]*\([_a-zA-Z]\)/j \1/g Xs/^br[ ][ ]*/jmp /g XH Xg X/^[_a-zA-Z][_a-zA-Z0-9]*:/{ Xs/:.*\n/: / Xs/^/\ X/ X} Xs/^.*\n//' <tmp.1 >tmp.2 X X Xsed -e 'y/$/#/' <tmp.2 | grep "." Xrm -f $$.? Xexit 0 X Xrm -rf tmp.? /