Help understanding LEGO bytecode for Arduino project

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
frazras
Posts: 5
Joined: 11 Apr 2012, 14:43

Help understanding LEGO bytecode for Arduino project

Post by frazras »

I am not sure if this is the right forum for this level of lego convo because my search has not turned up much results but here goes.
As I had mentioned in April I am working on a LEGO minstorms interpreter for Arduino, I have "open sourced" it on github
https://github.com/frazras/x10abot
So far I have been trying to interpret the example bytecode provided. I am at the point of reading out the variables and assigning them to the SRAM.
However I am having problems with the offsets.
There are 3 varibables, two 32-bit longs and an 8-bit byte type. The info in the docs say they take up 12 bytes of memory when they really should take up 9 bytes.
There is some info also about the byte alignment of the Dope Vector Arrays being on 4 byte intervals which could explain it by placing padding bytes but I am not sure.
This is because I see other arrays being aligned on address offsets not divisible by 4.
Please let me know if there is anybody here who could help, or where to go to get more help, thank you.

Also feel free to contribute to the development on github if you want to get lego bytecode running on an arduino :-)
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: Help understanding LEGO bytecode for Arduino project

Post by tcwan »

Have you tried studying the LEGO Firmware VM source code?
http://mindboards.svn.sourceforge.net/v ... ms_nbcnxc/
That would probably be the most complete documentation you'll find.

Otherwise you'd probably have to disassemble NBC http://bricxcc.sourceforge.net/nbc/ compiled binaries.
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: Help understanding LEGO bytecode for Arduino project

Post by spillerrec »

tcwan wrote:Otherwise you'd probably have to disassemble NBC http://bricxcc.sourceforge.net/nbc/ compiled binaries.
Disassembling might be a bit overkill when the source code is available ; )

However I'm afraid to say that the only one here on Mindboards which has a fair grip on the bytecode encoding is John Hansen and even he has asked for help (which as far I as know didn't result in anything and it was a bug which affected me :\ ).
I have read a good amount of the specification, but I haven't spend the time to fully understand it yet. I have been planning to learn it, but I usually does these kind of things on and off, so when that will be I don't know. But I will keep this in mind and inform you if I notice anything.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: Help understanding LEGO bytecode for Arduino project

Post by tcwan »

spillerrec wrote:
tcwan wrote:Otherwise you'd probably have to disassemble NBC http://bricxcc.sourceforge.net/nbc/ compiled binaries.
Disassembling might be a bit overkill when the source code is available ; )
Sorry, I think I didn't explain myself well.
What I meant was, take a NBC source file, run it through the NBC Compiler, and look at the generated binary output (rxe?) file.
If NBC provides a listing file, then that could be used as the reference. Otherwise, compare the disassembled rxe output byte stream against the NBC source statements, this would provide the mapping from NBC source statements to the corresponding hexadecimal bytecode values.
Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests