I am trying to load a 64-bit number on a 32-bit ARM7TDMI-S microprocessor however, I am not understanding how to do so. I know that MOV and LDR all store only 32bit numbers so is there any way I can use 2 32bit registers as one 64-bit register?
Asked
Active
Viewed 1,917 times
1
-
3I mean, you load one half into one register and the other half into another. You can't "use" two 32-bit registers as a single 64-bit register, but whatever it is you actually want to do with the number, there will be a way to do it. What is it that you want to do? – Nate Eldredge Jan 31 '21 at 06:22
-
LDM can load two registers at once, but there are no ALU instructions that do an add across a pair of integer registers so you'd normally have to `add`/`adc`. Look at compiler output for simple `int64_t` functions (https://godbolt.org/) If you have NEON, you can of course do a 64-bit load into a register such as `d0`. I don't know if NEON has much support for 64-bit elements for shift / add / whatever, but you could at least AND or other bitwise boolean ops that don't care about element width. – Peter Cordes Jan 31 '21 at 06:38
-
@NateEldredge I just want to load 2 64bit numbers and add them. So as you are saying I should write my assembly code such that when I add 2 numbers it is reflected on both 32-bit registers or is there any instruction that can do it. – Kruti Deepan Panda Jan 31 '21 at 07:18
-
@PeterCordes the issue is I have instructed to use MOV to load registers – Kruti Deepan Panda Jan 31 '21 at 07:20
2 Answers
4
Just ask the compiler it will tell you. Obviously you cannot fit 64 bits into 32, it takes two registers.
unsigned long long fun ( unsigned long long a, unsigned long long b )
{
return(a+b);
}
00000000 <fun>:
0: e0900002 adds r0, r0, r2
4: e0a11003 adc r1, r1, r3
8: e12fff1e bx lr

old_timer
- 69,149
- 8
- 89
- 168
0
Okay, I got the answer to my own question. I have to load the lower half of the number in one register and the upper half in another. If we want to add the two numbers then we add the lower half by using ADDS
and the upper half using ADC
.

Kruti Deepan Panda
- 324
- 1
- 4
- 16
-
If you can't do it with one register, do it with two. If you can't do it with two use more, or, use memory. – Erik Eidt Jan 31 '21 at 16:07