// Prozessor: MIPS
// Endianness: irrelevant
// Compiler: GNU-C oder ...
-// Parameter-Übergabe: in Registern $4,$5,$6,$7, und auf dem Stack 16($sp),...
-// Rückgabewert: in Register $2
+// Parameter-Übergabe:
+// o32: in Registern $4,$5,$6,$7, und auf dem Stack 16($sp),...
+// n32: in Registern $4,$5,$6,$7,$8,$9,$10,$11, und auf dem Stack 4($sp),...
+// Rückgabewert: in Register $2
// Einstellungen: intCsize=32, intDsize=32.
-// Besonderheiten: Nach jedem Ladebefehl ein Wartetakt nötig, bevor der
+// Besonderheiten: Nach jedem Ladebefehl ein Wartetakt nötig, bevor der
// geholte Wert benutzt werden darf.
+// Strictly speaking, the MIPS ABI (-32 or -n32) is independent from the CPU
+// identification (-mips[12] or -mips[34]). But -n32 is commonly used together
+// with -mips3, and it's easier to test the CPU identification.
+#if __mips >= 3
+ #define ABI_N32 1
+#else
+ #define ABI_O32 1
+#endif
+
// When this file is compiled into a shared library, ELF linkers need to
// know which symbols are functions.
#if defined(__GNU__) || defined(__NetBSD__)
DECLARE_FUNCTION(mulu32_)
.ent mulu32_ // Input in $4,$5, Output in $2,mulu32_high
mulu32_:
+#if __mips_isa_rev >= 6
+ mulu $2,$5,$4 // arg1 * arg2, lo
+ muhu $6,$5,$4 // arg1 * arg2, hi
+#else
multu $5,$4 // arg1 * arg2
mfhi $6 // hi
mflo $2 // lo
+#endif
sw $6,mulu32_high // hi abspeichern // Adressierung?? Deklaration??
j $31 // return
.end mulu32_
// extern uintD subx_loop_down (uintD* sourceptr1, uintD* sourceptr2, uintD* destptr, uintC count, uintD carry);
.align 2
DECLARE_FUNCTION(subx_loop_down)
- .ent subx_loop_down // Input in $4,$5,$6,$7, Output in $2
+ .ent subx_loop_down // Input in $4,$5,$6,$7,$8 Output in $2
subx_loop_down:
+#if ABI_N32
+ move $12,$8 // carry
+#else
lw $12,16($sp) // carry
+#endif
bnez $12,sxld5 // !(carry==0) ?
b sxld2
sxld1: // kein Carry
// extern uintD subx_loop_up (uintD* sourceptr1, uintD* sourceptr2, uintD* destptr, uintC count, uintD carry);
.align 2
DECLARE_FUNCTION(subx_loop_up)
- .ent subx_loop_up // Input in $4,$5,$6,$7, Output in $2
+ .ent subx_loop_up // Input in $4,$5,$6,$7,$8, Output in $2
subx_loop_up:
+#if ABI_N32
+ move $12,$8 // carry
+#else
lw $12,16($sp) // carry
+#endif
bnez $12,sxlu5 // !(carry==0) ?
b sxlu2
sxlu1: // kein Carry