authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2021-03-02 00:15:03+01:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2021-03-02 00:34:41+01:00
log278bd60732df558cd43b67166cde8e0410e45428
tree7fcff1f4467fdef667627753a199d7d16cbb8b19
parent345ac53836bce5eb39a04723b30ac82dd7d5098f
signature Commit is signed but in an unrecognized format.

stage2 ARM: Add tests for basic integer multiplication


1 files changed, 34 insertions(+), 0 deletions(-)

test/stage2/arm.zig+34
......@@ -344,4 +344,38 @@ pub fn addCases(ctx: *TestContext) !void {
344344 "",
345345 );
346346 }
347
348 {
349 var case = ctx.exe("integer multiplication", linux_arm);
350 // Simple u32 integer multiplication
351 case.addCompareOutput(
352 \\export fn _start() noreturn {
353 \\ assert(mul(1, 1) == 1);
354 \\ assert(mul(42, 1) == 42);
355 \\ assert(mul(1, 42) == 42);
356 \\ assert(mul(123, 42) == 5166);
357 \\ exit();
358 \\}
359 \\
360 \\fn mul(x: u32, y: u32) u32 {
361 \\ return x * y;
362 \\}
363 \\
364 \\fn assert(ok: bool) void {
365 \\ if (!ok) unreachable;
366 \\}
367 \\
368 \\fn exit() noreturn {
369 \\ asm volatile ("svc #0"
370 \\ :
371 \\ : [number] "{r7}" (1),
372 \\ [arg1] "{r0}" (0)
373 \\ : "memory"
374 \\ );
375 \\ unreachable;
376 \\}
377 ,
378 "",
379 );
380 }
347381}