L'Hexapod: Integrating the multi-move command

Previously published

This article was previously published on lhexapod.com as part of my journey of discovery into robotics and embedded assembly programming. A full index of these articles can be found here.

I’m in the process of integrating the stand alone code that implements my ‘multi-servo move’ command and the rest of the controller. It’s harder than it should be, probably because I’m not experienced enough yet with assembly language not to have made some school boy errors. Once again I’ve run out of registers, mainly because I’m trying not to have to push stuff on the stack that often. I’ve been juggling with the limited number of registers and up until now it’s worked but…

The first problem is that I need two pointers to be able to do the data sorting for the multi-move command. Up until now all of the serial code has only ever had to use one pointer. I’ve been using X in the serial code and Y and Z in the PWM code. My usage of both Y and Z precludes me sharing them with the non interrupt code, which is a shame. The reason I can’t share Z is because I’m using it to switch between modes in the timer interrupt; I use ijmp which is an indirect jump using Z to select which interrupt handler I need to call next time around. This is cute but hardly necessary… Removing this use of Z means that I can use it in the serial code as well, now that it’s just a normal register pair I can simply push it onto the stack during the PWM setup code that also needs to use it for sorting…

My second problem is that I should always have simply been pushing registers onto the stack when I entered the PWM setup routine. Instead I tried very hard to simply not share registers between the PWM code and the serial code. Unfortunately I’ve no pretty much run out and so have to go back into the code and adjust the register usage which is a pain and error prone…

Anyway, that’s almost done now and, hopefully, the rest of the integration will be straight forward.