This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
cpu_abi [2021/10/16 17:21] someone2639 add float register section |
cpu_abi [2021/10/16 17:31] (current) someone2639 [Functions With Floating/Decimal Arguments] asm corrections |
||
---|---|---|---|
Line 99: | Line 99: | ||
} | } | ||
void myFunc(void) { | void myFunc(void) { | ||
- | float x = adder(1.0f, 3.0f, 4.0f); | + | float x = three_input_adder(1.0f, 3.0f, 4.0f); |
} | } | ||
</code> | <code> | </code> | <code> | ||
- | glabel adder | + | glabel three_input_adder |
+ | lwc1 f4, 0x10(sp) | ||
+ | add.s f0, f12, f14 | ||
+ | add.s f0, f0, f4 ; return value gets stored in f0 | ||
jr ra | jr ra | ||
- | add.s f0, f12, f14 ; return value gets stored in f0 | + | nop |
glabel myFunc | glabel myFunc | ||
addiu sp, -0x18 | addiu sp, -0x18 | ||
Line 113: | Line 116: | ||
li.s f4, 4.0 | li.s f4, 4.0 | ||
swc1 f4, 0x10(sp) ; subsequent float arguments go on the stack | swc1 f4, 0x10(sp) ; subsequent float arguments go on the stack | ||
- | jal adder | + | jal three_input_adder |
- | nop | + | nop |
| | ||
mfc1 t0, f0 ; f0 has the result | mfc1 t0, f0 ; f0 has the result | ||
Line 120: | Line 123: | ||
lw ra, 0x14(sp) | lw ra, 0x14(sp) | ||
jr ra | jr ra | ||
- | nop | + | addiu sp, 0x18 |
</code> | | </code> | | ||