This commit is contained in:
Jonathan Turner 2023-11-29 08:49:02 -05:00
parent 6d47e897c5
commit 319c0d2772

View File

@ -39,6 +39,8 @@
if (sstrlen(input, 15) > 4) { if (sstrlen(input, 15) > 4) {
char *number = input + 4; char *number = input + 4;
kprint(number); kprint(number);
int result = digit_conver(number);
kprint(result);
} }
umem_head = add_node( umem_head, 0x10000, 0x100, true, global_id++); umem_head = add_node( umem_head, 0x10000, 0x100, true, global_id++);
} else if (strcmp(input, "LIST") == 0) { } else if (strcmp(input, "LIST") == 0) {
@ -107,17 +109,17 @@
int digconver(const char *str) { int digconver(const char *str) {
int result = 0; u32 result = 0;
int i = 0; while (*hexString != '\0') {
char hexChar = *hexString;
while (str[i] != '\0') { if ((hexChar >= '0' && hexChar <= '9') || (hexChar >= 'A' && hexChar <= 'F')) {
if (str[i] >= '0' && str[i] <= '9') { int digit = (hexChar >= '0' && hexChar <= '9') ? (hexChar - '0') : (10 + (hexChar - 'A'));
result = result * 10 + (str[i] - '0'); result = result * 16 + digit;
} else { } else {
kprint("Error - Provided input is not a valid number.\n"); kprint("Invalid hex input\n");
return 0; return -1;
} }
i++; hexString++;
} }
return result; return result;
} }