diff options
| author | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2021-03-02 00:15:03 +0100 |
|---|---|---|
| committer | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2021-03-02 00:34:41 +0100 |
| commit | 278bd60732df558cd43b67166cde8e0410e45428 (patch) | |
| tree | 7fcff1f4467fdef667627753a199d7d16cbb8b19 | |
| parent | 345ac53836bce5eb39a04723b30ac82dd7d5098f (diff) | |
| download | zig-278bd60732df558cd43b67166cde8e0410e45428.tar.gz zig-278bd60732df558cd43b67166cde8e0410e45428.zip | |
stage2 ARM: Add tests for basic integer multiplication
| -rw-r--r-- | test/stage2/arm.zig | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/stage2/arm.zig b/test/stage2/arm.zig index 06e359ccff..1bc3f23058 100644 --- a/test/stage2/arm.zig +++ b/test/stage2/arm.zig @@ -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; + \\} + , + "", + ); + } } |
