The aim is to allow the user to input a memory address (in Hex) and print out the contents of the address.
The code is running on the Motorola 68HC11.
So far i am able to read memory addresses using hard coded values:
void displayMemory(){
char *p = (char*)0x5000;
printf("Address Ascii: %s\n",p);
}
However i have tried multiple ways of using data input from the user such as:
void displayMemory(char *arr){
char *p = arr;
printf("Address Ascii: %s\n",p);
}
^^ where the *arr is the inputted hex value. Such as: 40a
I have also tried hard coding the hex value as a char array like:
void displayMemory(){
char *p = "0x5000";
printf("Address Ascii: %s\n",p);
}
This also did not work and gave me a different memory address.
Any ideas would be greatly appreciated, i am probably being very stupid!
UPDATED: how the function is called
char *arr;
arr = malloc(size * sizeof(char));
if(arr){
strncat(arr, &userInput[3], size);
displayMemory(arr);
}else{
return 0;
}
userInput is : dm 40a size is: length of the number part of userInput in this case 3