1 # Ben Myers <0003571400@mcimail.com>
3 # Sum up sizes of Windows OBJ files in current directory
4 # requires DOS 5.0 and Borland TDUMP
5 # A clumsy script to count Windows OBJs and sum up the CODE sizes
7 # awk -fwinobj.awk work1
8 # where work1 is a work file
9 # You must have at least one filename as an arg, else awk will want to read
10 # from con:, hence the requirement for work1
12 # redirection done by shelled command
13 ocount = 0 # obj module counter
14 otsize = 0 # text size accumulator
15 odsize = 0 # data size accumulator
16 system("del workfile.$%$") # Will probably cause a File Not Found message
17 # Generate a list of OBJs
18 system("dir *.obj /b >" ARGV[1])
19 while (getline < ARGV[1] > 0) {
20 # TDUMP selects only the SEGDEFs to speed things up a lot
21 # and keeps on piping to the workfile
22 system("tdump " $1 " -oiSEGDEF >>workfile.$%$")
25 # Now read workfile back, processing lines that are module ids and SEGDEF info
26 # Print one line for each SEGDEF processed
28 while (getline < "workfile.$%$" > 0) {
30 if($1 == "Display" && $2 == "of" && $3 == "File") { module_name = $4 }
32 if($2 == "SEGDEF" && $9 =="'CODE'") {
35 printf ("%12s CODE %4s %7i\n", module_name, $11, decval)
38 if($2 == "SEGDEF" && $9 =="'DATA'") {
41 printf ("%12s DATA %4s %7i\n", module_name, $11, decval)
44 } # end of BEGIN section
45 # no main loop at all!
47 # print summary and delete work files
48 printf ("%i OBJ files\n", ocount)
49 printf ("Total CODE size %04x %7li bytes\n", otsize, otsize)
50 printf ("Total DATA size %04x %7li bytes\n", odsize, odsize)
52 system("del workfile.$%$")
53 } # end of END section
55 # No scanf in awk, so convert hex string x to decimal the hard way
58 for (i=1; i<=length(x); i++) {
59 thechar = substr(x,i,1)
60 # digits 0-9 and lower case hex produced by TDUMP
62 if (thechar == "0") {result = result*16}
63 if (thechar == "1") {result = result*16 + 1}
64 if (thechar == "2") {result = result*16 + 2}
65 if (thechar == "3") {result = result*16 + 3}
66 if (thechar == "4") {result = result*16 + 4}
67 if (thechar == "5") {result = result*16 + 5}
68 if (thechar == "6") {result = result*16 + 6}
69 if (thechar == "7") {result = result*16 + 7}
70 if (thechar == "8") {result = result*16 + 8}
71 if (thechar == "9") {result = result*16 + 9}
72 if (thechar == "a") {result = result*16 + 10}
73 if (thechar == "b") {result = result*16 + 11}
74 if (thechar == "c") {result = result*16 + 12}
75 if (thechar == "d") {result = result*16 + 13}
76 if (thechar == "e") {result = result*16 + 14}
77 if (thechar == "f") {result = result*16 + 15}
78 } # for (i=1;i<length(x);i++)
80 } # function hexdec (x)