2 * Test R5900-specific DIVU1.
9 struct quotient_remainder
{ uint32_t quotient
, remainder
; };
11 static struct quotient_remainder
divu1(uint32_t rs
, uint32_t rt
)
15 __asm__
__volatile__ (
19 : "=r" (lo
), "=r" (hi
)
20 : "r" (rs
), "r" (rt
));
22 assert(rs
/ rt
== lo
);
23 assert(rs
% rt
== hi
);
25 return (struct quotient_remainder
) { .quotient
= lo
, .remainder
= hi
};
28 static void verify_divu1(uint32_t rs
, uint32_t rt
,
29 uint32_t expected_quotient
,
30 uint32_t expected_remainder
)
32 struct quotient_remainder qr
= divu1(rs
, rt
);
34 assert(qr
.quotient
== expected_quotient
);
35 assert(qr
.remainder
== expected_remainder
);
40 verify_divu1(0, 1, 0, 0);
41 verify_divu1(1, 1, 1, 0);
42 verify_divu1(1, 2, 0, 1);
43 verify_divu1(17, 19, 0, 17);
44 verify_divu1(19, 17, 1, 2);
45 verify_divu1(77773, 101, 770, 3);