I\'m just starting to learn ARM and I\'m having trouble understanding what the load and store instructions do exactly.
Load instructions:
ldrsb
ldrb
ldrs
When talking ARM a "word" is 32 bits, a "halfword" is 16 bits, and a "byte" is 8 bits. If you read the instruction set documentation in the ARM Architectural Reference Manual (just get the one for ARMv5 if you dont know which one to get, infocenter.arm.com) you will see that a ldrb loads the byte into the lower 8 bits of the destination register padding the upper 24 bits to zeros. A ldrsb will sign extend instead of pad with zeros. Same goes for halfword.
if you have code like this:
char a,b,c;
...
c = a+b;
if(c<0)
{
}
And either a or b or both were in memory at the time that you needed to do this addition then you would ideally want to do a sign extended (assuming you have told your compiler that char is signed) load to save instructions sign extending the registers so you can perform the math and have the flags set right for the comparison.
From the ARM ARM.
LDRSB (Load Register Signed Byte) loads a byte from memory, sign-extends it to form a 32-bit word, and writes the result to a general-purpose register.
LDRB (Load Register Byte) loads a byte from memory, zero-extends it to form a 32-bit word, and writes the result to a general-purpose register.