News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
MurgaLua Compiler
Author Message
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
RE: MurgaLua Compiler

JohnMurga Wrote:
They are slow because they are currently coded in Lua, I'll change that at a future date, however the functionality is useful :-)


I guessed something like that already from the "stellar" performance ;-)

But I don't get it, why to bother to implement something like that in Lua when the C implementation is trivial and much simpler then the Lua implementation. BTW aren't Lua strings immutabe? Then this could bring noMMU system instantly down.

Juergen

P.S.: An example for a C implementation:

bin2hex:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv){
unsigned char byte;
char lookup[]="0123456789ABCDEF";

while (fread((char *) &byte,1,1,stdin)==1) {
printf("%c%c",lookup[(byte>>4)%16],lookup[byte%16]);
}
return 0;
}


hex2bin:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv){
unsigned char byte,i,j,obyte=0;
unsigned char lookup[]="0123456789ABCDEF";

j=0;
while (fread((char *) &byte,1,1,stdin)==1) {
  for(i=0;i<16;i++) {
    if (byte==lookup[i]) {
       obyte+=(j==0)?i<<4:i;
       if (j==1) {printf("%c",obyte); obyte=0;}
       j^=1;
       break;
     }
  }
}
return 0;
}

02-01-2008 09:08 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
MurgaLua Compiler - iGame3D - 01-31-2008, 09:54 PM
RE: MurgaLua Compiler - mikshaw - 02-01-2008, 12:00 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 02:45 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 02:50 AM
RE: MurgaLua Compiler - iGame3D - 02-01-2008, 08:05 AM
RE: MurgaLua Compiler - Juergen - 02-01-2008, 09:08 AM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 09:38 AM
RE: MurgaLua Compiler - iGame3D - 02-01-2008, 03:26 PM
RE: MurgaLua Compiler - Juergen - 02-01-2008 09:08 PM
RE: MurgaLua Compiler - JohnMurga - 02-01-2008, 11:47 PM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 04:33 AM
RE: MurgaLua Compiler - JohnMurga - 02-06-2008, 08:21 AM
MurgaLua Compiler Platforms - iGame3D - 02-06-2008, 09:24 AM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 09:29 AM
RE: MurgaLua Compiler - Juergen - 02-06-2008, 08:14 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: