Move string printing to runtime

This commit is contained in:
Ayke van Laethem
2018-04-11 20:41:09 +02:00
parent 7ffb73b407
commit d08ff64d1d
4 changed files with 105 additions and 33 deletions
+30
View File
@@ -0,0 +1,30 @@
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "runtime.h"
void __go_printstring(char *str) {
write(STDOUT_FILENO, str, strlen(str));
}
void __go_printspace() {
write(STDOUT_FILENO, " ", 1);
}
void __go_printnl() {
write(STDOUT_FILENO, "\n", 1);
}
void go_main() __asm__("main.main");
void __go_runtime_main() {
go_main();
}
__attribute__((weak))
int main() {
__go_runtime_main();
return 0;
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
typedef struct {
uint32_t length; // TODO: size_t
uint8_t *data;
} string_t;
void __go_printstring(char *str);
void __go_printnl();