diff options
author | pommicket <pommicket@gmail.com> | 2021-11-19 09:52:27 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2021-11-19 09:52:27 -0500 |
commit | 9760d898b7f3e4b43337bac18c842d95c9f3ea6c (patch) | |
tree | d2ede7ea6fa0ad59395219322c7ba2ca4e126105 /04b/in04 | |
parent | 17cf6b6fa02db452c3b0b88b09b8884f73b0c1eb (diff) |
start 04b compiler
Diffstat (limited to '04b/in04')
-rw-r--r-- | 04b/in04 | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/04b/in04 b/04b/in04 deleted file mode 100644 index 1b362ad..0000000 --- a/04b/in04 +++ /dev/null @@ -1,95 +0,0 @@ -// types: char, uchar, short, ushort, int, uint, long, ulong, *type -// declaration: -// static <type> <name>; -// local <type> <name>; -// :<label> -// statement: -// <declaration> -// if <term> <==/</>/>=/<=/!=> <term> goto <label> -// goto <label> -// <lvalue> = <rvalue> -// <lvalue> += <rvalue> -// <lvalue> -= <rvalue> -// <function>(<term>, <term>, ...) -// syscall(<term>, <term>, ...) -// return <rvalue>; -// term: -// <var> -// <number> -// number: -// 'c -// 12345 -// 0xabc -// lvalue: -// <var> -// *<var> -// <var>[<term>] -// rvalue: -// `<string>` -// <var> -// &<var> -// *<var> -// <var>[<term>] -// ~<var> -// <function>(<term>, <term>, ...) -// syscall(<term>, <term>, ...) -// <term> + <term> -// <term> - <term> -// <term> * <term> -// <term> / <term> -// <term> % <term> -// <term> & <term> -// <term> | <term> -// <term> ^ <term> -// <term> < <term> (left shift) -// <term> > <term> (right shift) -// (<term> ] <term>) - -main(); - -static char x; -static uchar y; -static long z; - -function strlen(*char s) - local ulong len; - local char c; - len = 0; - :strlen.loop - c = s[len]; - if c == 0 goto strlen.loop_end; - len += 1; - goto strlen.loop - :strlen.loop_end - return len; - -function putc(char c) - local char *p; - p = &c; - syscall(1, 1, p, 1, 0, 0, 0, 0); - return; - -function puts(*char s) - local ulong len; - len = strlen(s); - syscall(1, 1, s, len, 0, 0, 0, 0); - return; - -function main() - local *char hello; - hello = `Hello, world! -`; - puts(hello); - syscall(0x3c, 0, 0, 0, 0, 0, 0, 0); - -function f(*long x, **long y) - local long v; - local *long p; - v = *x; - p = *y; - *p = v; - if v == 0 goto something; - p[1] = v + 1; - return p[2]; - :something - return p[1]; |