Assemble ahoy!

I had stumbled upon what seemed like the holy grail!

I had found a tool that could compile source code to VM byte code. It was written in Java, so odds where that it would work on my computer even though all documentation for it only mentioned Windows and Linux. It was light weight, only a JAR and some Logo files.

All I needed to do was to get it to run. That includes two things.

Starting the assembler, and providing it with something to assemble. I had already found how to start it while looking through the make files. There where tons of LMS file to experiment with but they where too complicated for my comfort. Fortunately I had also looked through a file called apps.c, which seems like it would be a C file used by an app somewhere. It was in fact a C file but there is no C code in there, only a bunch of Doxygen style comments. At the very top of that file was an lms example that looked like this:

vmthread  MAIN
  UI_DRAW(FILLWINDOW,0x00,0,0)                  //  Clear screen
  UI_DRAW(TEXT,FG_COLOR,10,50,'hello world')    //  Write "hello world" at 10,50 (X,Y)
  UI_DRAW(UPDATE)                               //  Show the stuff
  UI_BUTTON(WAIT_FOR_PRESS)                     //  Wait for button press

I pasted it into a new file called nosleep.lms. (It was past 1am, I had to go to work the next day and I knew I wouldn’t get much sleep that night)

With my simple Hello World script ready I started the command line

Magnus-starke-dator:lmsasm magnusrunesson$ java -jar assembler.jar ~/Projects/ev3zipper/nosleep

And I got the error message “Can’t open file bytecodes.h in preprocess”

The assembler needed additional files. I looked around and found that fileread.logo needed bytecodes.h and I don’t know exactly how this is supposed to be setup because it just didn’t exist in the right folder. I had seen the bytecodes.c and bytecodes.h previously in a folder so I copied the .h file into the same folder as assembler.jar, tried again and got the error message that bytecodes.c was missing. I did the same procedure for that file and tried again.

Now the output read “57 bytes”

And there it was. nosleep.rbf. I had created my first .rbf file and my excitement was through the roof! Quickly I opened the memory browser in LabVIEW and transferred nosleep.rbf file to the Brick, used the file browser on the Brick and opened the nosleep.rbf, and this is what I saw on the device:

Hello world on the Brick

I was there! I had been able to create some source code that would compile to some sort of EV3 code, transfer it to the Brick and launch it on the Brick.

I had opened the door to my kind of programming for the Brick and I was about to embark on a fantastic journey of EV3 programming!

Leave a Reply