What’s the easiest way in C to assemble two bytes received from a UART to make a (signed) int? (an ARM int is 32 bits).
In assembler, it’s a complete doddle:
with the two bytes from the UART in R1 (LSB) and R2 (MSB)
ORRS R0, R1, R2, LSL #8
SXTH R0,R0
I can only think of long-winded ways of doing it in C.
Or is it best just to write the above as a function and call it from C?
In assembler, it’s a complete doddle:
with the two bytes from the UART in R1 (LSB) and R2 (MSB)
ORRS R0, R1, R2, LSL #8
SXTH R0,R0
I can only think of long-winded ways of doing it in C.
Or is it best just to write the above as a function and call it from C?