Tool/software: TI C/C++ Compiler
It seems the assembler does not allow to compile a valid instruction in thumb mode:
sub sp,#40
It issues "Register Rd cannot be a hi register"
But ARM ARM lists:
SUB SP, #imm * 4 where: SP Indicates the stack pointer. The result of the operation is also stored in the SP. imm is a 7-bit immediate value that is multiplied by 4 and then subtracted from the value of the stack pointer.
I checked 18.12.5-LTS and 16.9.11.