void os::printc(char c) {
write_serial(c);
}
-void os::print(const char* str) {
- for (std::size_t i = 0; str[i] != '\0'; i++) {
- os::printc(str[i]);
+void os::print(const char* format, const char* val) {
+ os::assert(format[0] == '\0', "Format string unsupported. TODO.");
+ for (std::size_t i = 0; val[i] != '\0'; i++) {
+ os::printc(val[i]);
}
}
-void os::print(std::uint64_t v) {
+void os::print(const char* format, std::uint64_t val) {
+ os::assert(format[0] == '\0', "Format string unsupported. TODO.");
for (int i = 60; i >= 0; i -= 4) {
- const int c = (v >> i) & 0xF;
- os::printc(c < 10 ? c + '0' : c + 'A' - 10);
+ const int v = (val >> i) & 0xF;
+ os::printc(v < 10 ? v + '0' : v - 10 + 'a');
}
}
-void os::print(std::int64_t v) {
- if (v < 0) {
+void os::print(const char* format, std::int64_t val) {
+ os::assert(format[0] == '\0', "Format string unsupported. TODO.");
+ if (val < 0) {
os::printc('-');
- os::print(std::uint64_t(-v));
+ os::print(format, std::uint64_t(-val));
} else {
os::printc(' ');
- os::print(std::uint64_t(v));
+ os::print(format, std::uint64_t(val));
}
}
-void os::print(std::uint32_t v) { os::print(std::uint64_t(v)); }
-void os::print(std::uint16_t v) { os::print(std::uint64_t(v)); }
-void os::print(std::uint8_t v) { os::print(std::uint64_t(v)); }
-void os::print(std::int32_t v) { os::print(std::int64_t(v)); }
-void os::print(std::int16_t v) { os::print(std::int64_t(v)); }
-void os::print(std::int8_t v) { os::print(std::int64_t(v)); }
+void os::print(const char* format, std::uint32_t val) { os::print(format, std::uint64_t(val)); }
+void os::print(const char* format, std::uint16_t val) { os::print(format, std::uint64_t(val)); }
+void os::print(const char* format, std::uint8_t val) { os::print(format, std::uint64_t(val)); }
+void os::print(const char* format, std::int32_t val) { os::print(format, std::int64_t(val)); }
+void os::print(const char* format, std::int16_t val) { os::print(format, std::int64_t(val)); }
+void os::print(const char* format, std::int8_t val) { os::print(format, std::int64_t(val)); }
void os::assert(bool cond, const char* diagnostic) {
if (!cond) {
os::print("Error: ");
void write_serial(std::uint8_t v);
void printc(char c);
-void print(const char* str);
-void print(std::uint64_t v);
-void print(std::uint32_t v);
-void print(std::uint16_t v);
-void print(std::uint8_t v);
-void print(std::int64_t v);
-void print(std::int32_t v);
-void print(std::int16_t v);
-void print(std::int8_t v);
+void print(const char* format, const char* val);
+void print(const char* format, std::uint64_t val);
+void print(const char* format, std::int64_t val);
+void print(const char* format, std::uint32_t val);
+void print(const char* format, std::int32_t val);
+void print(const char* format, std::uint16_t val);
+void print(const char* format, std::int16_t val);
+void print(const char* format, std::uint8_t val);
+void print(const char* format, std::int8_t val);
+template <typename T> void print(const T& val) {
+ print("", val);
+}
void assert(bool cond, const char* diagnostic);
}