mirror of
https://github.com/ziglang/zig.git
synced 2025-12-26 08:03:08 +00:00
stage2 ARM: Add tests for basic integer multiplication
This commit is contained in:
parent
345ac53836
commit
278bd60732
@ -344,4 +344,38 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
var case = ctx.exe("integer multiplication", linux_arm);
|
||||
// Simple u32 integer multiplication
|
||||
case.addCompareOutput(
|
||||
\\export fn _start() noreturn {
|
||||
\\ assert(mul(1, 1) == 1);
|
||||
\\ assert(mul(42, 1) == 42);
|
||||
\\ assert(mul(1, 42) == 42);
|
||||
\\ assert(mul(123, 42) == 5166);
|
||||
\\ exit();
|
||||
\\}
|
||||
\\
|
||||
\\fn mul(x: u32, y: u32) u32 {
|
||||
\\ return x * y;
|
||||
\\}
|
||||
\\
|
||||
\\fn assert(ok: bool) void {
|
||||
\\ if (!ok) unreachable;
|
||||
\\}
|
||||
\\
|
||||
\\fn exit() noreturn {
|
||||
\\ asm volatile ("svc #0"
|
||||
\\ :
|
||||
\\ : [number] "{r7}" (1),
|
||||
\\ [arg1] "{r0}" (0)
|
||||
\\ : "memory"
|
||||
\\ );
|
||||
\\ unreachable;
|
||||
\\}
|
||||
,
|
||||
"",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user