I still haven't been able to catch my friend on a free day to make the kickstarter video, so in the meantime I've been working on anything I can make progress on. I don't NEED the funding to do some things, but I do need it to help with prototyping. Unlike a lot of my solo funded projects, this one is not just for my own amusement, and I'm trying to create something that will open robotics up to the widest possible audience.
The bootloader code is coming along nicely. The microprocessor portion is done, it's simply responsible for checking if the PC is connected and if so reading data from the PC. The PC is responsible for much more, it's responsible for making sure that the users code won't poke around where it isn't supposed too. To do that we basically disassemble the code and check to make sure that particular opcode doesn't do anything that would touch the bootloader code.
Disassembly is very interesting, take the following opcodes, they usually appear in hexadecimal format
Each opcode is 2 bytes long, which means that the first opcode is 15 and 8A and the second is 2F and 9B. The first byte is called the high byte, and the second the low byte. We actually need to split these in half again, ending with:
1, 5, 8, and A
2, F, 9, and B
By looking at the datasheet for the microcontroller, we can see that the commands are divided into 4 categories:
0 - General Commands (22) - these commands include addwf, subwf, return and nop; and ones that affect the F register
1 - Bitset and Bittest commands (4) - these commands set and test individual bits
2 - Call and Goto
3 - W Commands - These commands affect the W register
From each of the first half bits, we can see the first command is a Bcf, Bsf, Btfsc, or Btfss; and the second is a Call or Goto! Awesome! What next?
Checking the datasheet again, you'll notice that for each of the commands, the second half-byte is specific, this is how we identify which of the commands is the one we want
The first one is 5, well the half bytes only come out to 0, 4, 8, and C so which one is the right one? The answer is to round down to the closest number, in this case 4. That means we have a BSF command, which is exactly right. The next command, the half bytes come out to 0 and 8, applying the round-down rule we can see that this is a GOTO command, which is also correct!
The complete dissassembly is:
BSF 0x10, 0x03
GOTO 0x79B
And I'll leave you to figure out how to derive the other components, it's all in the datasheet :).