LEFT | RIGHT |
1 // Derived from Inferno utils/8c/txt.c | 1 // Derived from Inferno utils/8c/txt.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/8c/txt.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/8c/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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 else | 129 else |
130 plast->link = pl; | 130 plast->link = pl; |
131 plast = pl; | 131 plast = pl; |
132 | 132 |
133 pc = mal(sizeof(*pc)); | 133 pc = mal(sizeof(*pc)); |
134 clearp(pc); | 134 clearp(pc); |
135 pl->firstpc = pc; | 135 pl->firstpc = pc; |
136 | 136 |
137 return pl; | 137 return pl; |
138 } | 138 } |
| 139 |
| 140 void |
| 141 clearstk(void) |
| 142 { |
| 143 Plist *pl; |
| 144 Prog *p1, *p2; |
| 145 Node sp, di, cx, con, ax; |
| 146 |
| 147 if(plast->firstpc->to.offset <= 0) |
| 148 return; |
| 149 |
| 150 // reestablish context for inserting code |
| 151 // at beginning of function. |
| 152 pl = plast; |
| 153 p1 = pl->firstpc; |
| 154 p2 = p1->link; |
| 155 pc = mal(sizeof(*pc)); |
| 156 clearp(pc); |
| 157 p1->link = pc; |
| 158 ········ |
| 159 // zero stack frame |
| 160 nodreg(&sp, types[tptr], D_SP); |
| 161 nodreg(&di, types[tptr], D_DI); |
| 162 nodreg(&cx, types[TUINT32], D_CX); |
| 163 nodconst(&con, types[TUINT32], p1->to.offset / widthptr); |
| 164 gins(ACLD, N, N); |
| 165 gins(AMOVL, &sp, &di); |
| 166 gins(AMOVL, &con, &cx); |
| 167 nodconst(&con, types[TUINT32], 0); |
| 168 nodreg(&ax, types[TUINT32], D_AX); |
| 169 gins(AMOVL, &con, &ax); |
| 170 gins(AREP, N, N); |
| 171 gins(ASTOSL, N, N); |
| 172 |
| 173 // continue with original code. |
| 174 gins(ANOP, N, N)->link = p2; |
| 175 pc = P; |
| 176 }······· |
139 | 177 |
140 void | 178 void |
141 gused(Node *n) | 179 gused(Node *n) |
142 { | 180 { |
143 gins(ANOP, n, N); // used | 181 gins(ANOP, n, N); // used |
144 } | 182 } |
145 | 183 |
146 Prog* | 184 Prog* |
147 gjmp(Prog *to) | 185 gjmp(Prog *to) |
148 { | 186 { |
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 void | 1952 void |
1915 sudoclean(void) | 1953 sudoclean(void) |
1916 { | 1954 { |
1917 } | 1955 } |
1918 | 1956 |
1919 int | 1957 int |
1920 sudoaddable(int as, Node *n, Addr *a) | 1958 sudoaddable(int as, Node *n, Addr *a) |
1921 { | 1959 { |
1922 return 0; | 1960 return 0; |
1923 } | 1961 } |
LEFT | RIGHT |