Skip to content

Commit

Permalink
Expand example a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wallbraker committed Apr 9, 2012
1 parent c7b31bc commit e18b5f7
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions tests/dcpu-testing.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
int test(int a, int b, int c, int d, int e);
#define SYS(__sysn) ((((__sysn) + 0x20) << 10) | (2 << 4))

typedef (*funcCall)();
unsigned short sys1_value[] = {0x01a1, SYS(2), 0x61c1};
#define dputs(__str) ((void (*)(const char*))sys1_value)(__str)

struct program {
int state;
int foo;
} program;

int test(struct program *p);
void printResult(int a);

short array = {0x61c1};

int main()
{
((funcCall)array)();
program.state = 3;
program.foo = 4;

int ret = test(&program);

printResult(ret);

int some_var = 3;
ret = foo(6);

int ret = test(1, 2, 3, 4, 5);
printResult(ret);

return some_var + ret;
return foo(ret);
}

int foo(int a)
{
return 9 + a;
return a - 4;
}

int test(int a, int b, int c, int d, int e)
int test(struct program *p)
{
a = foo(a);
return ((a + b + c) * d / a) + (d * e);
return p->state + p->foo;
}

void printResult(int a)
{
static char string[] = "result is 0\n\0";

string[10] = '0' + a;
dputs(string);
}

0 comments on commit e18b5f7

Please sign in to comment.