Waze for WP7 – Java to CSharp

OK, so I have Waze and Cibyl source code and all I need to do is make Cibyl yield C# code instead of Java. Simple, right? Well, not exactly.

Cibyl dictates you to work in two layers: the Java bytecode level and Java code level. The C code that comes in Cibyl is being translated to Java bytecode while every external call from the C code (printf, DrawLine, fopen etc.) is being translated to a call from the Java bytecode to Java code for implementing the required functionality. Example:

#include <stdio.h>
#include <cibyl.h>

int main(int argc, char **argv)
  return 0;

Will be translated into 10K Java bytecode lines (I shit you not) that will call Java for printing the characters to the screen:

; 0x01001c84: 0x1001c84: cibyl_sysc_arg 0x7
; 0x01001c88: 0x1001c88: cibyl_sysc_arg 0x8
	iload 7
; 0x01001c8c: 0x1001c8c: cibyl_sysc 0x120
	invokestatic Syscalls/NOPH_OutputStream_write(II)V
; 0x01001c90: 0x1001c90: addu  a3, v0, zero
	iload 4

What’s that?

Apparently, Simon, the creator of Cibyl, did amazing work of translation all LIBC to be compliant with Cibyl. Essentially he implemented all the I/O functions (fopen, printf etc.) as C code that calls Java predefined funtcions to do the real IO (print char to the screen, open file etc.). The C code is being compiled into Java byte code and, along with your code, being printed into J files (Java assembly files).


Now, for making it really useful, some performance work has to be done. Read about it here

This entry was posted in Waze, WP7 and tagged . Bookmark the permalink.

1 Response to Waze for WP7 – Java to CSharp

  1. Pingback: Waze for WP7 – Deep dive into Cibyl | Meir Tsvi's blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s