| 231 | |
| 232 | |
| 233 | void hexToStr_op( uint32_t in, char* out, uint8_t op ) |
| 234 | { |
| 235 | // Position container |
| 236 | uint32_t pos = 0; |
| 237 | |
| 238 | // Evaluate through digits as hex |
| 239 | do |
| 240 | { |
| 241 | uint32_t cur = in % 16; |
| 242 | out[pos++] = cur + (( cur < 10 ) ? '0' : 'A' - 10); |
| 243 | } |
| 244 | while ( (in /= 16) > 0 ); |
| 245 | |
| 246 | // Output formatting options |
| 247 | switch ( op ) |
| 248 | { |
| 249 | case 1: // Add 0x |
| 250 | out[pos++] = 'x'; |
| 251 | out[pos++] = '0'; |
| 252 | break; |
| 253 | case 2: // 8-bit padding |
| 254 | case 4: // 16-bit padding |
| 255 | case 8: // 32-bit padding |
| 256 | while ( pos < op ) |
| 257 | out[pos++] = '0'; |
| 258 | break; |
| 259 | } |
| 260 | |
| 261 | // Append null |
| 262 | out[pos] = '\0'; |
| 263 | |
| 264 | // Reverse the string to the correct order |
| 265 | revsStr( out ); |
| 266 | } |
| 267 | |
| 268 | |
| 269 | void printHex_op( uint32_t in, uint8_t op ) |
no test coverage detected
searching dependent graphs…