Skip to content

Commit 3481924

Browse files
19tracksAntonioND
authored andcommitted
math: correct semantics of asm in normalizef32()
Kuratius in the gbadev Discord noticed that this asm statement was missing a memory input constraint, since it reads from the memory pointed to by a. I took a look at it, too, and noticed a couple more things. volatile isn't necessary because the statement could be eliminated if its outputs were never used, and the & modifiers aren't necessary because the inputs aren't read from after the outputs are written to. I also changed the input's name to match the name of the variable instead of the name of the register it will be kept in. None of this affects the generated code with the current toolchain, but it is a little more correct.
1 parent 5cf45a3 commit 3481924

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/arm9/math.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ ARM_CODE void normalizef32(int32_t *a)
111111
register uint32_t Lo;
112112
register uint32_t Hi;
113113

114-
asm volatile (
114+
asm (
115115
".syntax unified \n\t"
116-
"ldm %[r0], {r1,r2,r3} \n\t"
116+
"ldm %[a], {r1,r2,r3} \n\t"
117117
"smull %[Lo],%[Hi], r1, r1 \n\t"
118118
"smlal %[Lo],%[Hi], r2, r2 \n\t"
119119
"smlal %[Lo],%[Hi], r3, r3 \n\t" :
120-
[Lo]"=r&"(Lo), [Hi]"=r&"(Hi) :
121-
[r0]"r"(a) :
120+
[Lo]"=r"(Lo), [Hi]"=r"(Hi) :
121+
[a]"r"(a), "m"(*(int32_t (*)[3]) a) :
122122
"r1", "r2", "r3"
123123
);
124124

0 commit comments

Comments
 (0)