# ARM assembly - Addition of specific bytes from word-size values

I'm trying to code a way to add specific halfwords from word-sized numbers in the ARM assembly language. For example, lets say I want to add the first 4 digits of r0=0x3B029BA1 and r1=0x0B54A361 or the middle 4 digits of r0=0x3B029BA1 and r1=0x0B54A361. I can't seem to make this work. This is a shortened example of what I have so far.

LDR r0, =0x3B029BA1;
LDR r1, =0x0B54A361;
LDRH r10, [r1];


I'm pretty sure there will need to be an offset for the address in the 3rd line of the code, but I haven't gotten past a halfword just getting into the register 10. Every time I run this code, the correct register values end up in r0 and r1, but nothing at all is appearing in r10. So before I do anything else, I just want to understand why this is happening.

• Is there a reason you would not shift and mask the values? Eg. in C uint32_t r0 = 0x3B029BA1; uint32_t r1 = 0x0B54A361; uint32_t result = ((r0>>8) & 0xFFFF) + ((r1>>8) & 0xFFFF). Also are they signed or unsigned numbers? – gbulmer Sep 20 '16 at 0:55
• Well I'm new to this, and as I side, the offset can come later, right now I just don't understand why nothing at all is appearing in r10. Plus I can only use what we've learned so far. – RoryHector Sep 20 '16 at 0:58
• I rarely write ARM assembler, and am not using my usual computer, so I don't have the ARM manuals to be certain. However, IIRC a LDRx instruction always means load from memory, so LDRH ...,[r1] should mean load from memory using the value in r1 as that memory address. Either you should load the correct two bytes of the value, and not all 4 bytes, or use shift and mask, or look at the MOV instruction for register to register transfers. Please double check as I don't have the ARM manuals, and may be misremembering. I apologise I can't be more help. – gbulmer Sep 20 '16 at 1:29