Open KlausScheffler opened 3 years ago
Hi Klaus,
you can't run it so simply. The compiler itself needs to compiled and run as a Java application. You need jlex and java_cup jars to compile .lex and .cup files - you can find the files and tutorial here: http://www.cs.cornell.edu/courses/cs412/2002sp/resources/skeleton.html
I used a tomcat server to tie it all together and run the app, but you can use whatever you want (e.g. Spring, or any other server that can run jars).
Hi Darijan
thanks, I also realized that all needs to be compiled. Works all fine now, thanks a lot.
Hi Darijan
sorry, another issue: all stack and memory addresses increase/decrease by 4. Do you assume that each memory location can only hold 8 bits? I am not sure, but if I have a memory that can hold 32 bits then the factor 1 should also work. Similarly, all offsets to base/stackpointer are multiples of 4. Can this be changed to 1? I found a hard-coded "4" in "Codegen" that seems to multiply addresses with 4, can this be set to 1?
Thanks so much for your help Klaus
@KlausScheffler The underlying assumption is that memory addresses always refer to a single byte, but this is supposed to be a 32-bit system, so 4 bytes = 32 bits, hence the factor of 4.
Hi Darijan
thanks for that very nice and educative compiler. I would like to use your compiler for a home-built cpu (where I can define the machine code on my own via micro code), and the very simple x86-like machine code seems perfect for that. However, I need to modify some constants such as size of stack etc, so I need to toach your code and need to run it locally on my PC. I am not an expert in html and Java, but if I download your code and start ccode.html, it just does not start to compile. Not sure if some files are missing. Actually I dont need the html environment, maybe I just can input a text file (with c code) to your Java compiler.
I would be happy for any help, thanks a lot Klaus