Continue to Site

# Reconfigure user input variable

Status
Not open for further replies.

#### shaswat

Hi,

I want to try to find out that is it possible to reconfigure this value into two of others variables.
e.g.
This is the user input value
Code:
0002DECE - 0002E03D
and I want to try to reconfigure it in two variables like
Code:
0002DECE
&
Code:
0002E03D
.

Does C language provide us some sort of function to do it ??

Thanks...

#### Easyrider83

0002DECE is 32-bit variable already. Doesn't matter what user enter. It will 32-bit as far, as electricity will supply the circuit. I thinks you do not understand some basic things or I didn't understood what do you mean.

#### shaswat

What about if it's only 16 bit variable?

#### Easyrider83

It will be not 0002DECE, only DECE. 0xFFFF is a bit mask for 16-bit variables.

#### shaswat

Actually what I am trying to do, this is the code memory allocated size by the module/function written in my project. Now what I have to do, I have to check out that how much amount of memory is been using by EACH function. So as its a lengthy and hectic work, I am thinking to just write a simple program so that I just entered the code size value like (0002DECE - 0002E03D) and it will tell me the exact memory usage of modules (e.g. in this case 16F).

#### betwixt

##### Super Moderator
Staff member
It's unclear what you are asking. Do you mean you want the text entered literally as "0002DECE - 0002E03D" to be converted into the calculation 0002DECE minus 0002E03D so you get the difference between them? The result of the calculation is negative so how do you want to handle that?

If you are simply looking for the address range occupied by a function, give it labels in it's start and end in your source code and subtract the labels.

Brian.

#### shaswat

Yes, this is exactly what I want but here with a slight difference. I know that the result will have some negative values, so I want to subtract from the last value to the first one. Means 0002E03D - 0002DECE. With this, I am able to find out exactly the value which I want.

I already found out the address range and yes this is the one of the example of one of my function address range. Instead of checking manually and hence time-consuming, I want to create an exe file in which I just enter the address range (as a user) and it will tell the exact segmentation usage bytes (367 in dec in this case).

#### betwixt

##### Super Moderator
Staff member
I can't help with the GUI but the principle will be:

1. input the two numbers as A and B
2. if (A > B) {C = B; B = A; A = C;} // swap so the bigger is B
3. result is B - A

make all the variables 'unsigned long' types.

If you use the Windows calculator, set it to scientific, hex mode. Do the subtraction, if the result starts with FF, press the +/- button. Select Decimal if needed.

Brian.

Status
Not open for further replies.