1 | # $Id: tstAsmStructsAsm-lst.sed 91287 2021-09-16 21:30:45Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # For testing assembly struct when using yasm.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | #
|
---|
19 | # Strip stuff lines and spaces we don't care about.
|
---|
20 | #
|
---|
21 | / %line /d
|
---|
22 | /\[section /d
|
---|
23 | /\[bits /d
|
---|
24 | /\[absolute /d
|
---|
25 | / times /d
|
---|
26 | s/ *[[:digit:]]* //
|
---|
27 | /^ *$/d
|
---|
28 | s/ *$//g
|
---|
29 | s/^ *//g
|
---|
30 | /^\.text$/d
|
---|
31 | /^\.data$/d
|
---|
32 | /^\.bss$/d
|
---|
33 | / *\.unnamed_padding\./d
|
---|
34 | s/[[:space:]][[:space:]]*/ /g
|
---|
35 |
|
---|
36 | #
|
---|
37 | # Figure which type of line this is and process it accordingly.
|
---|
38 | #
|
---|
39 | /^[[:alpha:]_][[:alnum:]_]*:/b struct
|
---|
40 | /^[[:alpha:]_][[:alnum:]_]*_size EQU \$ - .*$/b struct_equ
|
---|
41 | /<gap>/b member
|
---|
42 | /^\.[[:alpha:]_][[:alnum:]_.:]* res.*$/b member_two
|
---|
43 | /^\.[[:alpha:]_][[:alnum:]_.:]* EQU .*$/b member_two
|
---|
44 | /^\.[[:alpha:]_][[:alnum:]_.:]*:$/b member_alias
|
---|
45 | b error
|
---|
46 | b member_two
|
---|
47 |
|
---|
48 |
|
---|
49 | #
|
---|
50 | # Struct start / end.
|
---|
51 | #
|
---|
52 | :struct_equ
|
---|
53 | s/_size EQU.*$/_size/
|
---|
54 | :struct
|
---|
55 | s/:$//
|
---|
56 | h
|
---|
57 | s/^/global /
|
---|
58 | s/$/ ; struct/
|
---|
59 | b end
|
---|
60 |
|
---|
61 |
|
---|
62 | #
|
---|
63 | # Struct member
|
---|
64 | # Note: the 't' command doesn't seem to be working right with 's'.
|
---|
65 | #
|
---|
66 | :member
|
---|
67 | s/[[:xdigit:]]* *//
|
---|
68 | s/<gap> *//
|
---|
69 | /^\.[[:alnum:]_.]*[:]* .*$/!t error
|
---|
70 | s/\(\.[[:alnum:]_]*\)[:]* .*$/\1 /
|
---|
71 | G
|
---|
72 | s/^\([^ ]*\) \(.*\)$/global \2\1 ; member/
|
---|
73 | s/\n//m
|
---|
74 |
|
---|
75 | b end
|
---|
76 |
|
---|
77 |
|
---|
78 | #
|
---|
79 | # Struct member, no address. yasm r1842 and later.
|
---|
80 | #
|
---|
81 | :member_two
|
---|
82 | s/[:]* *res[bwdtq] .*$//
|
---|
83 | s/[:]* *EQU .*$//
|
---|
84 | s/$/ /
|
---|
85 | /^\.[[:alnum:]_.]* *$/!t error
|
---|
86 | G
|
---|
87 | s/^\([^ ]*\) \(.*\)$/global \2\1 ; member2/
|
---|
88 | s/\n//m
|
---|
89 |
|
---|
90 | b end
|
---|
91 |
|
---|
92 | #
|
---|
93 | # Alias member like Host.cr0Fpu in 64-bit. Drop it.
|
---|
94 | #
|
---|
95 | :member_alias
|
---|
96 | d
|
---|
97 | b end
|
---|
98 |
|
---|
99 | :error
|
---|
100 | s/^/\nSed script logic error!\nBuffer: /
|
---|
101 | s/$/\nHold: /
|
---|
102 | G
|
---|
103 | q 1
|
---|
104 | b end
|
---|
105 |
|
---|
106 |
|
---|
107 | :end
|
---|
108 |
|
---|