6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 9:25 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: java_grinder
PostPosted: Mon Mar 03, 2014 11:48 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
A buddy of mine has been working on java for microcontrollers etc:
https://github.com/mikeakohn/java_grinder

For fun/learning I am doing the 6502 part. The idea is basically to compile the java byte code into assembly. There are limitations:

-integers are 16-bit, shorts are treated like integers
-stack is always aligned to 16-bit
-division/modulus is unsigned only
-you can have 8/16 bit arrays (byte/int)
-no floating point etc

He made it so you can extend a processor to a particular platform, and make corresponding java classes. Pretty cool. So I extended 6502 to the C64, and am working on an API for that. Not everything in java is supported, but basically you make one class file, and include static methods within that to do what you want.

There is a Mandelbrot demo for the C64. The latest naken_asm from github (see above) is required for this to work:
https://github.com/mikeakohn/naken_asm

Code:
cd java
make
cd ..

That builds the API..
Code:
cp testing/CommodoreDemo.java .
javac -cp build CommodoreDemo.java
./java_grinder CommodoreDemo.class test.asm c64


Then use naken_asm to compile:
Code:
naken_asm test.asm -b -o test.prg


Now test.prg will run in a c64 emulator such as VICE:
Image

Mike's pages for java_grinder and naken_asm with more information:
http://www.mikekohn.net/micro/java_grinder.php
http://www.mikekohn.net/micro/naken_asm.php


Top
 Profile  
Reply with quote  
 Post subject: Re: java_grinder
PostPosted: Tue Mar 04, 2014 3:24 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 411
Location: Minnesota
You might also be interested in taking a look at VM02, a similar Java-for-the-6502 project David Schmenk put up a few years ago:

http://sourceforge.net/projects/vm02/


Top
 Profile  
Reply with quote  
 Post subject: Re: java_grinder
PostPosted: Fri Mar 07, 2014 4:39 am 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
Sweet, I never would have imagined an actual interpreter.

Re-wrote some of this today, changed the game plan a bit. Now using the processor stack solely for jsr/rts etc, and made a parallel stack of 256 lo/256 hi bytes for variables. This frees up the 6502 stack and allows 256 16-bit variables to be on the java stack.

Also now either inlines code if there is a constant involved (shifts can be unrolled etc) or will only include a subroutine if it's actually needed. (The code inlining saves a few cycles but not too much, so I'm not sure it's really worth the bloat.)

Haven't updated the code yet but will after I debug a bit more.
:mrgreen:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: