mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
plan9 codegen, add tests
They generate an object file, but do not execute yet, since we don't have something to execute them with.
This commit is contained in:
parent
7b8a968f14
commit
7b5d139fd3
2 changed files with 41 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||
try @import("stage2/wasm.zig").addCases(ctx);
|
||||
try @import("stage2/darwin.zig").addCases(ctx);
|
||||
try @import("stage2/riscv64.zig").addCases(ctx);
|
||||
try @import("stage2/plan9.zig").addCases(ctx);
|
||||
|
||||
{
|
||||
var case = ctx.exe("hello world with updates", linux_x64);
|
||||
|
|
|
|||
40
test/stage2/plan9.zig
Normal file
40
test/stage2/plan9.zig
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const std = @import("std");
|
||||
const TestContext = @import("../../src/test.zig").TestContext;
|
||||
|
||||
pub fn addCases(ctx: *TestContext) !void {
|
||||
const target: std.zig.CrossTarget = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .plan9,
|
||||
};
|
||||
{
|
||||
var case = ctx.exe("plan9: exiting correctly", target);
|
||||
case.addCompareOutput("pub fn main() void {}", "");
|
||||
}
|
||||
{
|
||||
var case = ctx.exe("plan9: hello world", target);
|
||||
case.addCompareOutput(
|
||||
\\pub fn main() void {
|
||||
\\ const str = "Hello World!\n";
|
||||
\\ asm volatile (
|
||||
\\ \\push $0
|
||||
\\ \\push %%r10
|
||||
\\ \\push %%r11
|
||||
\\ \\push $1
|
||||
\\ \\push $0
|
||||
\\ \\syscall
|
||||
\\ \\pop %%r11
|
||||
\\ \\pop %%r11
|
||||
\\ \\pop %%r11
|
||||
\\ \\pop %%r11
|
||||
\\ \\pop %%r11
|
||||
\\ :
|
||||
\\ // pwrite
|
||||
\\ : [syscall_number] "{rbp}" (51),
|
||||
\\ [hey] "{r11}" (@ptrToInt(str)),
|
||||
\\ [strlen] "{r10}" (str.len)
|
||||
\\ : "rcx", "rbp", "r11", "memory"
|
||||
\\ );
|
||||
\\}
|
||||
, "");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue