aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoam Preil <pleasantatk@gmail.com>2020-07-07 21:35:00 -0400
committerNoam Preil <pleasantatk@gmail.com>2020-07-07 21:35:42 -0400
commit64bf1301822866904f52a70213dd71eefce4b99a (patch)
tree1a8d540dab89453096386c0a61d13a676492c045 /test
parentcf09b335d8b7ad5b43ceefd169b4c2e6be8ed249 (diff)
downloadzig-64bf1301822866904f52a70213dd71eefce4b99a.tar.gz
zig-64bf1301822866904f52a70213dd71eefce4b99a.zip
CBE: working asm Inputs and Outputs; std{int,def}.h auto-inclusion
Diffstat (limited to 'test')
-rw-r--r--test/stage2/cbe.zig51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig
index 88eb6c5953..9a28c25e27 100644
--- a/test/stage2/cbe.zig
+++ b/test/stage2/cbe.zig
@@ -31,4 +31,55 @@ pub fn addCases(ctx: *TestContext) !void {
\\_Noreturn void main(void) {}
\\
);
+ // TODO: implement return values
+ ctx.c11("inline asm", linux_x64,
+ \\fn exitGood() void {
+ \\ asm volatile ("syscall"
+ \\ :
+ \\ : [number] "{rax}" (231),
+ \\ [arg1] "{rdi}" (0)
+ \\ );
+ \\}
+ \\
+ \\export fn _start() noreturn {
+ \\ exitGood();
+ \\}
+ ,
+ \\#include <stddef.h>
+ \\
+ \\void exitGood(void);
+ \\
+ \\_Noreturn void _start(void) {
+ \\ exitGood();
+ \\}
+ \\
+ \\void exitGood(void) {
+ \\ register size_t rax_constant __asm__("rax") = 231;
+ \\ register size_t rdi_constant __asm__("rdi") = 0;
+ \\ __asm volatile ("syscall" :: ""(rax_constant), ""(rdi_constant));
+ \\}
+ \\
+ );
+ //ctx.c11("basic return", linux_x64,
+ // \\fn main() u8 {
+ // \\ return 103;
+ // \\}
+ // \\
+ // \\export fn _start() noreturn {
+ // \\ _ = main();
+ // \\}
+ //,
+ // \\#include <stdint.h>
+ // \\
+ // \\uint8_t main(void);
+ // \\
+ // \\_Noreturn void _start(void) {
+ // \\ (void)main();
+ // \\}
+ // \\
+ // \\uint8_t main(void) {
+ // \\ return 103;
+ // \\}
+ // \\
+ //);
}