aboutsummaryrefslogblamecommitdiffstats
path: root/system/doc/tutorial/port.c
blob: 3a9a4e442c2c24d41b1d7292738dc694fff300b5 (plain) (tree)





















                             
/* port.c */

typedef unsigned char byte;

int main() {
  int fn, arg, res;
  byte buf[100];

  while (read_cmd(buf) > 0) {
    fn = buf[0];
    arg = buf[1];
    
    if (fn == 1) {
      res = foo(arg);
    } else if (fn == 2) {
      res = bar(arg);
    }

    buf[0] = res;
    write_cmd(buf, 1);
  }
}