1 | #
|
---|
2 | # Strip stuff lines and spaces we don't care about.
|
---|
3 | #
|
---|
4 | / %line /d
|
---|
5 | /\[section /d
|
---|
6 | /\[bits /d
|
---|
7 | /\[absolute /d
|
---|
8 | / times /d
|
---|
9 | s/ *[0-9]* //
|
---|
10 | /^ *$/d
|
---|
11 | s/ *$//g
|
---|
12 | s/^ *//g
|
---|
13 | /^\.text$/d
|
---|
14 | /^\.data$/d
|
---|
15 | /^\.bss$/d
|
---|
16 |
|
---|
17 | #
|
---|
18 | # Figure which type of line this is and process it accordingly.
|
---|
19 | #
|
---|
20 | /^[A-Za-z][A-Za-z0-9_]*:/b struct
|
---|
21 | /<gap>/b member
|
---|
22 | /^\.[A-Za-z][A-Za-z0-9_.:]* res.*$/b member_two
|
---|
23 | b error
|
---|
24 | b member_two
|
---|
25 |
|
---|
26 |
|
---|
27 | #
|
---|
28 | # Struct start / end.
|
---|
29 | #
|
---|
30 | :struct
|
---|
31 | s/:$//
|
---|
32 | h
|
---|
33 | s/^/global /
|
---|
34 | s/$/ ; struct/
|
---|
35 | b end
|
---|
36 |
|
---|
37 |
|
---|
38 | #
|
---|
39 | # Struct member
|
---|
40 | # Note: the 't' command doesn't seem to be working right with 's'.
|
---|
41 | #
|
---|
42 | :member
|
---|
43 | s/[0-9a-fA-Z]* *//
|
---|
44 | s/<gap> *//
|
---|
45 | /^\.[a-zA-Z0-9_.]*[:]* .*$/!t error
|
---|
46 | s/\(\.[a-zA-Z0-9_]*\)[:]* .*$/\1 /
|
---|
47 | G
|
---|
48 | s/^\([^ ]*\) \(.*\)$/global \2\1 ; member/
|
---|
49 | s/\n//m
|
---|
50 |
|
---|
51 | b end
|
---|
52 |
|
---|
53 |
|
---|
54 | #
|
---|
55 | # Struct member, no address. yasm r1842 and later.
|
---|
56 | #
|
---|
57 | :member_two
|
---|
58 | s/[:]* *res[bwdtq] .*$//
|
---|
59 | s/$/ /
|
---|
60 | /^\.[a-zA-Z0-9_.]* *$/!t error
|
---|
61 | G
|
---|
62 | s/^\([^ ]*\) \(.*\)$/global \2\1 ; member2/
|
---|
63 | s/\n//m
|
---|
64 |
|
---|
65 | b end
|
---|
66 |
|
---|
67 |
|
---|
68 | :error
|
---|
69 | s/^/\nSed script logic error!\nBuffer: /
|
---|
70 | s/$/\nHold: /
|
---|
71 | G
|
---|
72 | q 1
|
---|
73 | b end
|
---|
74 |
|
---|
75 |
|
---|
76 | :end
|
---|
77 |
|
---|