I'm working with an STM32F103 using the latest version of uVision (5.33.0.0 as of this writing), a ULINKpro interface to the microcontroller, and code written in C. I have a variable declared as int16_t (signed short), so when it's in the debug window only two bytes are shown. The result of a particular calculation is stored in this variable, and is (for example), 0xF123. This variable is passed as an argument to a function where comparisons are made. I have reasons to modify this value prior to the function call for debugging purposes. This value is passed, as one might expect, as a register. The 32-bit register displays 0xFFFFF123. I need to modify the value to 0xFF00, but if I do so in the watch window, the corresponding register displays 0x0000FF00. How can I extend the sign when the watch window only offers 16 bits to edit?
int16_t
Sample code:
int16_t f(int16_t x) { if(x>=0xFEFF && x<=0x1F00) { return 1; } else { return 0; } } void main() { int16_t x,y; x=0-1; y=f(x); printf("%x",y); }
If I place a breakpoint on y=f(x), modify x in the watch window to be some (any) negative value other than 0xFFFF, the register (R4 in my case) which did display 0xFFFFFFFF becomes 0x0000FF00. If I try to set x to 0xFFFFFF00, it still doesn't work. I can edit the register directly, but I'm having difficulty convincing myself that changes to the software won't affect which register is assigned to the variable in the future. Is there a setting for sign extensions that I'm missing?