Compare commits
No commits in common. "d5f3944b1a5f1dea9d33f12e1ba82167d263c7b4" and "ec59936d429338dfd6deae55a7d09b2da94a781d" have entirely different histories.
d5f3944b1a
...
ec59936d42
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,6 +0,0 @@
|
|||||||
**/*.o
|
|
||||||
**/*.a
|
|
||||||
**/*.lds
|
|
||||||
**/*.h
|
|
||||||
zig-out/
|
|
||||||
zig-cache/
|
|
0
.gitmodules
vendored
0
.gitmodules
vendored
@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
zig build-obj ./src/main.zig -fno-PIE -fno-PIC -fno-stack-check
|
|
||||||
ld.bfd main.o -o zig-out/bin/nmvm.com.dbg -T extern/cosmopolitan/ape.lds extern/cosmopolitan/crt.o extern/cosmopolitan/ape-copy-self.o \
|
|
||||||
extern/cosmopolitan/cosmopolitan.a -z common-page-size=0x1000 -z max-page-size=0x1000 --gc-sections
|
|
4
extern/cosmopolitan/get.sh
vendored
4
extern/cosmopolitan/get.sh
vendored
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
wget wget https://justine.lol/cosmopolitan/cosmopolitan.tar.gz
|
|
||||||
unzip cosmopolitan.tar.gz
|
|
4
extern/get.sh
vendored
4
extern/get.sh
vendored
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cd ./cosmopolitan
|
|
||||||
./get.sh
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cd ./extern
|
|
||||||
./get.sh
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/cosmopolitan/cosmopolitan.zig
|
|
@ -208,28 +208,14 @@ fn addInt6(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32) callconv(.SysV) void {
|
|||||||
@panic("addInt6");
|
@panic("addInt6");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addInt7(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32, sa: u32) callconv(.SysV) void {
|
|
||||||
@setAlignStack(16);
|
|
||||||
if ((a + b + c + d + e + @as(u64, @intCast(f)) + sa) != 30)
|
|
||||||
@panic("addInt7");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn addInt8(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32, sa: u32, sb: u8) callconv(.SysV) void {
|
|
||||||
@setAlignStack(16);
|
|
||||||
if ((a + b + c + d + e + @as(u64, @intCast(f)) + sa + sb) != 40)
|
|
||||||
@panic("addInt8");
|
|
||||||
}
|
|
||||||
|
|
||||||
const opZov1Int = generateOpZovSysvFromPrototype(addInt1) catch unreachable;
|
const opZov1Int = generateOpZovSysvFromPrototype(addInt1) catch unreachable;
|
||||||
const opZov2Ints = generateOpZovSysvFromPrototype(addInt2) catch unreachable;
|
const opZov2Ints = generateOpZovSysvFromPrototype(addInt2) catch unreachable;
|
||||||
const opZov3Ints = generateOpZovSysvFromPrototype(addInt3) catch unreachable;
|
const opZov3Ints = generateOpZovSysvFromPrototype(addInt3) catch unreachable;
|
||||||
const opZov4Ints = generateOpZovSysvFromPrototype(addInt4) catch unreachable;
|
const opZov4Ints = generateOpZovSysvFromPrototype(addInt4) catch unreachable;
|
||||||
const opZov5Ints = generateOpZovSysvFromPrototype(addInt5) catch unreachable;
|
const opZov5Ints = generateOpZovSysvFromPrototype(addInt5) catch unreachable;
|
||||||
const opZov6Ints = generateOpZovSysvFromPrototype(addInt6) catch unreachable;
|
const opZov6Ints = generateOpZovSysvFromPrototype(addInt6) catch unreachable;
|
||||||
const opZov7Ints = generateOpZovSysvFromPrototype(addInt7) catch unreachable;
|
|
||||||
const opZov8Ints = generateOpZovSysvFromPrototype(addInt8) catch unreachable;
|
|
||||||
|
|
||||||
test "integer parameter passing" {
|
test "integer register passing" {
|
||||||
const code = [_]tolmac.Word{
|
const code = [_]tolmac.Word{
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)),
|
||||||
1,
|
1,
|
||||||
@ -255,16 +241,6 @@ test "integer parameter passing" {
|
|||||||
4,
|
4,
|
||||||
@as(tolmac.Word, @intFromPtr(opZov6Ints)),
|
@as(tolmac.Word, @intFromPtr(opZov6Ints)),
|
||||||
@as(tolmac.Word, @intFromPtr(&addInt6)),
|
@as(tolmac.Word, @intFromPtr(&addInt6)),
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)),
|
|
||||||
15,
|
|
||||||
@as(tolmac.Word, @intFromPtr(opZov7Ints)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&addInt7)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)),
|
|
||||||
10,
|
|
||||||
@as(tolmac.Word, @intFromPtr(opZov8Ints)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&addInt8)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),
|
||||||
|
19
src/main.zig
19
src/main.zig
@ -1,29 +1,20 @@
|
|||||||
|
const std = @import("std");
|
||||||
const tolmac = @import("tolmac.zig");
|
const tolmac = @import("tolmac.zig");
|
||||||
const cosmo = @import("cosmopolitan/cosmopolitan.zig");
|
|
||||||
|
|
||||||
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
|
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
|
||||||
@setAlignStack(16);
|
@setAlignStack(16);
|
||||||
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other + another)));
|
std.debug.print("test: {}, {}, {}\n", .{ int, other, another });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn printInt2(int: u64, other: u8) callconv(.SysV) void {
|
fn printInt2(int: u64, other: u8) callconv(.SysV) void {
|
||||||
@setAlignStack(16);
|
@setAlignStack(16);
|
||||||
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other)));
|
std.debug.print("test: {}, {}\n", .{ int, other });
|
||||||
}
|
}
|
||||||
|
|
||||||
const opPrintInt3Zov = tolmac.generateOpZovSysvFromPrototype(printInt3) catch unreachable;
|
const opPrintInt3Zov = tolmac.generateOpZovSysvFromPrototype(printInt3) catch unreachable;
|
||||||
const opPrintInt2Zov = tolmac.generateOpZovSysvFromPrototype(printInt2) catch unreachable;
|
const opPrintInt2Zov = tolmac.generateOpZovSysvFromPrototype(printInt2) catch unreachable;
|
||||||
|
|
||||||
comptime {
|
pub fn main() !void {
|
||||||
@export(cosmopolitanMain, .{ .name = "main" });
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: No cosmopolitan main.
|
|
||||||
|
|
||||||
export fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) c_int {
|
|
||||||
_ = argc;
|
|
||||||
_ = argv;
|
|
||||||
|
|
||||||
const add = [_]tolmac.Word{
|
const add = [_]tolmac.Word{
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opSumWordsWithOverflow)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opSumWordsWithOverflow)),
|
||||||
@as(tolmac.Word, @intFromPtr(&tolmac.opReturn)),
|
@as(tolmac.Word, @intFromPtr(&tolmac.opReturn)),
|
||||||
@ -52,8 +43,6 @@ export fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) c_int {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tolmac.execute(&entry, 0);
|
tolmac.execute(&entry, 0);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
Loading…
Reference in New Issue
Block a user