OLD | NEW |
1 // Derived from Inferno utils/6c/txt.c | 1 // Derived from Inferno utils/6c/txt.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/txt.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/txt.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 plast = pl; | 114 plast = pl; |
115 | 115 |
116 pc = mal(sizeof(*pc)); | 116 pc = mal(sizeof(*pc)); |
117 clearp(pc); | 117 clearp(pc); |
118 pl->firstpc = pc; | 118 pl->firstpc = pc; |
119 | 119 |
120 return pl; | 120 return pl; |
121 } | 121 } |
122 | 122 |
123 void | 123 void |
| 124 clearstk(void) |
| 125 { |
| 126 Plist *pl; |
| 127 Prog *p1, *p2; |
| 128 Node sp, di, cx, con; |
| 129 |
| 130 if((uint32)plast->firstpc->to.offset <= 0) |
| 131 return; |
| 132 |
| 133 // reestablish context for inserting code |
| 134 // at beginning of function. |
| 135 pl = plast; |
| 136 p1 = pl->firstpc; |
| 137 p2 = p1->link; |
| 138 pc = mal(sizeof(*pc)); |
| 139 clearp(pc); |
| 140 p1->link = pc; |
| 141 ········ |
| 142 // zero stack frame |
| 143 nodreg(&sp, types[tptr], D_SP); |
| 144 nodreg(&di, types[tptr], D_DI); |
| 145 nodreg(&cx, types[TUINT64], D_CX); |
| 146 nodconst(&con, types[TUINT64], (uint32)p1->to.offset / widthptr); |
| 147 gins(ACLD, N, N); |
| 148 gins(AMOVQ, &sp, &di); |
| 149 gins(AMOVQ, &con, &cx); |
| 150 gins(AREP, N, N); |
| 151 gins(ASTOSQ, N, N); |
| 152 |
| 153 // continue with original code. |
| 154 gins(ANOP, N, N)->link = p2; |
| 155 pc = P; |
| 156 }······· |
| 157 |
| 158 void |
124 gused(Node *n) | 159 gused(Node *n) |
125 { | 160 { |
126 gins(ANOP, n, N); // used | 161 gins(ANOP, n, N); // used |
127 } | 162 } |
128 | 163 |
129 Prog* | 164 Prog* |
130 gjmp(Prog *to) | 165 gjmp(Prog *to) |
131 { | 166 { |
132 Prog *p; | 167 Prog *p; |
133 | 168 |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 naddr(&n2, a, 1); | 2134 naddr(&n2, a, 1); |
2100 goto yes; | 2135 goto yes; |
2101 | 2136 |
2102 yes: | 2137 yes: |
2103 return 1; | 2138 return 1; |
2104 | 2139 |
2105 no: | 2140 no: |
2106 sudoclean(); | 2141 sudoclean(); |
2107 return 0; | 2142 return 0; |
2108 } | 2143 } |
OLD | NEW |