void hexString::setHexValue(){ //Internal function. Convert int to hex using non-recursive method. unsigned long long int tempInt = intValue; hexValue = ""; while (tempInt > 15) { hexValue = intToHex(tempInt%16) + hexValue; tempInt /= 16; } hexValue = intToHex(tempInt) + hexValue; }
static void addValueU8(char *dst, char *str, u8 value) { char v[16]; strcat(dst, str); intToHex(value, v, 2); strcat(dst, v); }
static void addValueU32(char *dst, char *str, u32 value) { char v[16]; strcat(dst, str); intToHex(value, v, 8); strcat(dst, v); }
static void addValueU16(char *dst, char *str, u16 value) { char v[16]; strcat(dst, str); intToHex(value, v, 4); strcat(dst, v); }
/** * Converts a decimal value with the size of a pointer to a hexadecimal string. * example: 26 -> "0xfa" */ static std::string intToHexString(uintptr_t num) { char hexStr[33]; if (intToHex(num, hexStr, 33) < 0) { hexStr[0] = '\0'; } return std::string(hexStr); }
void printInstructsToFile(tableInstruction *table, FILE *output){ int i, j; for (i = 0; i < table->size; i++){ fprintf(output, "%s", intToHex(table->instructions[i][0])); for(j = 1; j <= table->instructions[i][4]; j++){ fprintf(output, " %d", table->instructions[i][j]); } fprintf(output, "\n"); } }
void showRemoteSignalInDisplay(char *data) { if (data == 0) { char empty[4] = {' ', ' ', ' ', ' '}; set_Display(empty); return; } char result[4]; intToHex((uint16_t) data, result); set_Display(result); }
void CreateKey::generatePressed() { QString str = ""; srand( time(0) ); for ( int i=0; i<8; ++i ) { key.X[i] = rand(); key.X[i] <<= 16; key.X[i] |= rand(); str += intToHex( key.X[i] ); if ( i < 7 ) str += "x"; } ui.lineEdit->setText(str); }
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers) { DWORD exceptionCode = pointers->ExceptionRecord->ExceptionCode; ULONG_PTR *exceptionInfo = pointers->ExceptionRecord->ExceptionInformation; string description = codeToStr(exceptionCode); DebugSymbolEngine &symbolEngine = DebugSymbolEngine::instance(); if (exceptionCode == EXCEPTION_ACCESS_VIOLATION) { description += " ("; description += exceptionInfo[0] == 0 ? "Reading" : "Writing"; description += " address: 0x" + intToHex(static_cast<int>(exceptionInfo[1])) + ")"; } std::ostringstream ss; symbolEngine.StackTrace(pointers->ContextRecord, ss); description += "\n\nCall Stack:\n"; description += ss.str(); singleton->log(description.c_str(), pointers->ExceptionRecord->ExceptionAddress, NULL, 0, NULL); singleton->notifyUser(false); return EXCEPTION_EXECUTE_HANDLER; }
void PIC32F42::opcodeFunction() { int opcodeValue, address; string hexStr; opcodeValue = hexToInt('0', '0', memory[PC], memory[PC + 1]); switch (opcodeValue) { //Move Value to W case 80: hasOpcode = true; W[0] = memory[PC + 2]; W[1] = memory[PC + 3]; PC = PC + 4; opcodeFunction(); break; //Move W to memory case 81: hasOpcode = true; address = hexToInt(memory[PC + 2], memory[PC + 3], memory[PC + 4], memory[PC + 5])*2; memory[address] = W[0]; memory[address + 1] = W[1]; PC = PC + 6; opcodeFunction(); break; //Add Value to W case 90: { int value; string hex_value; hasOpcode = true; value = hexToInt('0', '0', memory[PC + 2], memory[PC + 3]); value = value + hexToInt('0', '0', W[0], W[1]); hex_value = intToHex(value); W[0] = hex_value[hex_value.size() - 2]; W[1] = hex_value[hex_value.size() - 1]; PC = PC + 4; opcodeFunction(); } break; //Subtract Value from W case 91: { int value; string hex_value; hasOpcode = true; value = hexToInt('0', '0', memory[PC + 2], memory[PC + 3]); value = hexToInt('0', '0', W[0], W[1]) - value; hex_value = intToHex(value); W[0] = hex_value[hex_value.size() - 2]; W[1] = hex_value[hex_value.size() - 1]; PC = PC + 4; opcodeFunction(); } break; //Goto address case 110: hasOpcode = true; int tmp; address = hexToInt(memory[PC + 2], memory[PC + 3], memory[PC + 4], memory[PC + 5]); PC = address * 2; if (PC > (size - 1)) { cout << "SIGWEED. Program executed past top of memory\n"; PC = tmp; break; } opcodeFunction(); break; //Branch if not equal case 112: hasOpcode = true; int comparision, value; comparision = hexToInt('0', '0', memory[PC + 2], memory[PC + 3]); value = hexToInt('0', '0', W[0], W[1]); if (comparision == value) { PC = PC + 8; } else { PC = hexToInt(memory[PC + 4], memory[PC + 5], memory[PC + 6], memory[PC + 7])*2; } opcodeFunction(); break; //Halt opcode case 255: cout << "Program halted\n"; break; default: if (hasOpcode == true) { hexStr = intToHex(PC / 2); cout << "Program Counter = 0x" << hexStr << "\n"; hasOpcode = false; } else { hexStr = intToHex(PC / 2); cout << "SIGOP. Invalid opcode. Program Counter = 0x" << hexStr << "\n"; } break; } }
void printIntAsHex(int num) { char* converted = intToHex(num); printHex(converted); }
/** * Draw debug text in hex to the screen */ void printHex(u32 hex, u8 length) { char str[length]; intToHex(hex, str, length); VDP_drawText(str, 0, 0); }
void MEM_dump() { char str[40]; char strNum[16]; u16 *b; u16 psize; u16 memused; u16 memfree; KDebug_Alert("Memory dump:"); KDebug_Alert(" Used blocks:"); b = heap; memused = 0; while ((psize = *b)) { if (psize & USED) { strcpy(str, " "); intToHex((u32)b, strNum, 8); strcat(str, strNum); strcat(str, ": "); intToStr(psize & 0xFFFE, strNum, 0); strcat(str, strNum); KDebug_Alert(str); memused += psize & 0xFFFE; } b += psize >> 1; KDebug_Alert(""); } KDebug_Alert(" Free blocks:"); b = heap; memfree = 0; while ((psize = *b)) { if (!(psize & USED)) { strcpy(str, " "); intToHex((u32)b, strNum, 8); strcat(str, strNum); strcat(str, ": "); intToStr(psize & 0xFFFE, strNum, 0); strcat(str, strNum); KDebug_Alert(str); memfree += psize & 0xFFFE; } b += psize >> 1; KDebug_Alert(""); } KDebug_Alert("Total used:"); KDebug_AlertNumber(memused); KDebug_Alert("Total free:"); KDebug_AlertNumber(memfree); }