1/* 2 * Some or all of this work - Copyright (c) 2006 - 2016, Intel Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * Neither the name of Intel Corporation nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * Data type conversion and manipulation 31 * 32 * Convert Data to Decimal String 33 */ 34 35// Integer 36 37// 32-bit 38Name(p338, Package() 39{ 40 0, 41 1, 42 12, 43 345, 44 6789, 45 12345, 46 678901, 47 2345678, 48 90123456, 49 789012345, 50 4294967295, 51 123456789, 52 0xff, 53 0xffff, 54 0xffffffff, 55}) 56 57Name(p339, Package() 58{ 59 "0", 60 "1", 61 "12", 62 "345", 63 "6789", 64 "12345", 65 "678901", 66 "2345678", 67 "90123456", 68 "789012345", 69 "4294967295", // == "0xffffffff" 70 "123456789", 71 "255", 72 "65535", 73 "4294967295", // == "0xffffffff" 74}) 75 76// 64-bit 77Name(p340, Package() 78{ 79 30123456790, 80 123456789012, 81 3456789012345, 82 26789012346789, 83 123456789012345, 84 3789012345678901, 85 23456789012345678, 86 301234567890123456, 87 1890123456789012345, 88 18446744073709551615, 89 0xffffffffffffffff, 90}) 91 92Name(p341, Package() 93{ 94 "30123456790", 95 "123456789012", 96 "3456789012345", 97 "26789012346789", 98 "123456789012345", 99 "3789012345678901", 100 "23456789012345678", 101 "301234567890123456", 102 "1890123456789012345", 103 "18446744073709551615", 104 "18446744073709551615", // == "0xffffffffffffffff" 105}) 106 107// String 108Name(p344, Package() 109{ 110 "", 111 "0123456789", 112 "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 113 "abcdefghijklmnopqrstuvwxyz", 114 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 115 "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !\"#$%&'()*", 116}) 117 118// Buffer 119Name(p342, Package() 120{ 121 Buffer(9) {}, 122 Buffer() {9, 7, 5, 3}, 123 Buffer(1) {1}, 124 Buffer(4) {1, 2, 3, 4}, 125 Buffer(8) {1, 2, 3, 4, 5, 6, 7, 8}, 126 127 // Results into 197 characters 128 Buffer(69) { 129 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 130 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 131 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 132 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 133 65, 66, 67, 68, 69}, 134 Buffer(57) { 135 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 136 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 137 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112, 138 113,114,115,116,117,118,119,120,121,122,123,124,125,126}, 139 140 // Results into 199 characters 141 Buffer(50) { 142 127,128, 143 129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144, 144 145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160, 145 161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176}, 146 Buffer(50) { 147 177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192, 148 193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208, 149 209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224, 150 225,226}, 151 152 Buffer(30) { 153 227,228,229,230,231,232,233,234,235,236,237,238,239,240, 154 241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, 0}, 155 156 // Results into 200 characters 157 Buffer(100) { 158 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 159 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 160 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 161 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 162 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 163 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 164 1, 1, 1, 11}, 165 Buffer(51) { 166 111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111, 167 111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111, 168 111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111, 169 111, 11, 1}, 170}) 171 172Name(p343, Package() 173{ 174 "0,0,0,0,0,0,0,0,0", 175 "9,7,5,3", 176 "1", 177 "1,2,3,4", 178 "1,2,3,4,5,6,7,8", 179 "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69", 180 "70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126", 181 "127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176", 182 "177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226", 183 "227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,0", 184 "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11", 185 "111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11,1", 186}) 187 188// Run-method 189Method(TOD0,, Serialized) 190{ 191 Name(ts, "TOD0") 192 193 Store("TEST: TOD0, Convert Data to Decimal String", Debug) 194 195 // From integer 196 if (LEqual(F64, 1)) { 197 m302(ts, 15, "p338", p338, p339, 3) 198 m302(ts, 11, "p340", p340, p341, 3) 199 } else { 200 m302(ts, 15, "p338", p338, p339, 3) 201 } 202 203 // From buffer 204 m302(ts, 12, "p342", p342, p343, 3) 205 206 // From string 207 m302(ts, 6, "p344", p344, p344, 3) 208} 209