Robert Seczkowski wrote:
Below is C code and asm representation for msp430F147.
Question:
1. Can anyone see reason why is push r2, and pop SR. Is it for fun?
and a DINT follows. push saves the state of the GIE interrupt enbale bit
pop restores that state.
2. has anyone found in early math lessons, that 144 = -112 !!!?
i do ;-)
I fully understand, that 112+144 = 256. I also understand, that 2+2=4
But these are not what states in C.
Funny is that if constant is below 126 everything is OK.
your describing "twos complement" the usual way to store signed integers
/ negative numbers in todays computers.
casting to int doesn't help
well, casing a signed char to a signed int will extend the bits so that
the results stays the same...
I am used to write HW mul myself but after 1 year and many updates I thought
somebody has fixed it up.
i dont think that it's broken ;-)
t= usart0_rx_buffer[usart0_rx_extract_idx]*144;
and usart0_rx_buffer is defined as "char"? that would mean it using
signed 8 bit math. maybe try:
t= (unsigned int)usart0_rx_buffer[usart0_rx_extract_idx]*144;
chris