The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Finished writing a semester long program by imrambi2005-05-05 16:07:34
  You should have just waited until by run.dll2005-05-05 16:17:24
    I had to write a compiler by imrambi2005-05-05 16:23:06
      Congrats by whoami2005-05-05 16:56:28
        We didn't do all of it by imrambi 2005-05-05 17:10:23
But we did have to write a parser, (after we augmented, and finzlized the grammer). Then once that was saved in an internal data stucture, we then did work on going to an intermediate low level (3 operand format, with basic blocks and such) code format. The prof has written code to take it from the low level to x86. The prof also had written an small optimizer, and a few other things. But here is the final code that he wanted us to run:
int a;

int addThem(int d, int e) {
  int f;
  f = d + e;

  return f;
}

int main (void) {

  int b;
  int c;
  int g;
  int h;
  int i;

  b = 5;

  if (b == 5) {
    a = 3;
  }
  else {
    a = 4;
  }

  g = 0;
  i = 1;
  while (i <= 8) {
    g = g + i;
    i = i+1;
  }
  h = g / 3;
  g = h * 4;

  c = addThem(a, b);
  putchar (c+g);
  putchar (12);
 
  return 0;
}


[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)