-
Notifications
You must be signed in to change notification settings - Fork 27
Compiler Patterns and Gotchas
mattbruv edited this page Oct 23, 2020
·
4 revisions
This pattern denotes a modulo operation: r3 % r4
:
divwu r0, r3, r4
mullw r0, r0, r4
subf r0, r0, r3
This pattern: clrlwi r3, r5, 0x18
is the result of casting a boolean value to an integer.
In this example, there is a function that returns an unsigned int in r3, and the r5 register either has 0 or 1.
In many places throughout the code, Heavy Iron uses 4 byte integers as return values for functions which return a boolean type, whereas in C++, the bool
keyword is equivalent to a single byte.