Most examples have IT commands such as the following,
ITTE NE ; IT can be omitted
ANDNE r0,r0,r1 ; 16-bit AND, not ANDS
ADDSNE r2,r2,#1 ; 32-bit ADDS (16-bit ADDS does not set flags in IT block)
MOVEQ r2,r3 ; 16-bit MOV
ITT AL ; emit 2 non-flag setting 16-bit instructions
ADDAL r0,r0,r1 ; 16-bit ADD, not ADDS
SUBAL r2,r2,#1 ; 16-bit SUB, not SUB
ADD r0,r0,r1 ; expands into 32-bit ADD, and is not in IT block
ITT EQ
MOVEQ r0,r1
BEQ dloop ; branch at end of IT block is permitted
ITT EQ
MOVEQ r0,r1
BKPT #1 ; BKPT always executes
ADDEQ r0,r0,#1
I want to look at for example the last IT block in the examples. Im really confused what is happening. For MOVEQ, I thought it was checking if r0 = r1, and moving r1 into r0 if they were equal. But that doesn't make sense if they are equal. What is really going on?
I wrote a thumb code that checks which number is greater:
cmp r0, r1
ITE HS
movhs r0, r0
movlo r0, r1
Here I needed to compare registers before the IT block... But why do all the examples not include a comparison atleast before hand? Would there been another way to write an IT block for my example that doesn't include a comparison? What's really going on in these examples?