cleans up hello.c
This commit is contained in:
parent
de4cf8f35a
commit
87539a8433
@ -3,35 +3,19 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "encoding.h"
|
||||
#include "platform.h"
|
||||
#include <string.h>
|
||||
|
||||
int factorial(int i) {
|
||||
|
||||
volatile int result = 1;
|
||||
for (int ii = 1; ii <= i; ii++) {
|
||||
result = result * ii;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
extern volatile uintptr_t tohost;
|
||||
|
||||
void write_tohost(char *string) {
|
||||
volatile uint64_t payload[4] = {64, 0, (uintptr_t)string,
|
||||
(strlen(string) + 1)};
|
||||
tohost = (uintptr_t)payload;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char string[] = "hello world with write in hello";
|
||||
|
||||
write_tohost(string);
|
||||
|
||||
write(STDOUT_FILENO, string, sizeof(string));
|
||||
|
||||
int result = factorial(10);
|
||||
printf("Factorial is %d", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user