grep 'extrn ' StarCraft.asm | awk '{print $2}' | awk -F: '{print $1}' > implist
-echo -n "" > tramp.s
+echo ".data" > tramp.s
+echo ".align 4" >> tramp.s
cat implist | while read i; do
rm -f tmpsym
;;
esac
- grep "\<_$si\>" /usr/i586-mingw32msvc/lib/lib* | awk '{print $3}' | \
+ grep "\<_$si\>" /usr/i586-mingw32msvc/lib/lib* *.lib | awk '{print $3}' | \
while read f; do
sym=`i586-mingw32msvc-nm $f | grep "\<_$si\>" | grep ' T ' | awk '{print $3}'`
if test -n "$sym"; then
echo ".globl $i" >> tramp.s
echo "$i:" >> tramp.s
- echo " jmp $sym" >> tramp.s
+ echo " .long $sym" >> tramp.s
echo >> tramp.s
done
s/dd[[:blank:]]rva/dd/;\
s/\<fldcw\>\t\[esp+4+var_4\]/fldcw\tword ptr \[esp\]/;\
s/\<large \(.*fs:\)/\1/;\
+s/lea\t\(e.[px]\), \[\1+0\]/align 10h/;\
+s/\[\(e..\)+\(e.p\)\]/\[\2+\1\]/;\
+s/\(\<word_.*\), 0FFFFh/\1, word ptr 0FFFFh/;\
+s/\(\<j[mn]\?[abceglopszp]e\?\>\)\tloc_/\1\tnear ptr loc_/;\
' StarCraft.asm" >> $f
. $f
+# manual fixup:
+# = 'end start' -> 'end'
+# - 'lea ecx, [ecx+0]' -> align
+# - add 'near ptr' to some jumps
+# - 'cmp [ebp+edx+0], cl' -> 'cmp [edx+ebp+0], cl'
+# - 0FFFFh constant - masm treats a byte, sometimes prefix with 'word ptr'