| Electronic Components Datasheet Search |
|
ST20-C1 Datasheet(PDF) 180 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
ST20-C1 Datasheet(HTML) 180 Page - STMicroelectronics |
|
180 / 205 page ![]() 180/205 ® C.2 Compiling switch statements The switch statement is a special form of conditional transfer where the transfer is determined by comparing an expression to a number of constants. When compiling the process switch x ... the expression x is evaluated and stored in a local variable by x; stl selector Then each branch of the switch statement c1, ..., cn P can be compiled by ldl selector; ldc c1; sub; cj L; ldl selector; ldc c2; sub; cj L; ... ldl selector; eqc cn;cj M; L: P; j END; M: where the label END: is placed at the end of the switch statement. C.2.3 Optimal compilation of switch The compilation method given above will produce inefficient code for large switch statements. To produce more efficient code the following rules can be used. First build up a set of pairs of selector values and processes, consisting of every selector value in the switch statement along with its associated process — the process part of each pair can be represented by the offset to the start of the compiled code for that process. Then the following rules can be used. 1 If there are 3 entries or less then use the method as described above. 2 If there are 12 entries or less then use a binary search to limit the number of comparisons required. 3 For more than 12 entries attempt to use a jump table. The offset of the start of each selected process is placed in the table against each selector value. Entries that do not match a selector in the switch statement must contain the offset of an error handler process. This jump table should be the largest table such that about one third of the entries are filled. This compilation strategy is then recursively called to handle the two ends. The jab (section 4.10) and ldpi (section 4.5) instructions, can be used to jump to the selected piece of code. The choice of 3 or less entries, 12 or less entries and one third filled tab le are the values used in current ST20 compilers. |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |