Some time ago I wrote: > > > I wanted to implement a pseudo-op called 'J' which used the shortest > > possible opcode JR or JP. It turned out that to optimally implement > > this, the assembler would potentially have to make a large number of > > passes, refining its estimate of the value of each label each time. It > > is also conceivable that the assembler could get stuck in an infinite > > loop. > Thanks to all the folks who sent algorithms etc. for solving this problem. Actually, I realised that there was no necessity for an 'infinite loop' to occur with a proper algorithm. Rather, I meant this was a possibility if due care was not exercised. Since this project was done in a great hurry (just a few days!) I didn't have time to consider such luxuries. If I was going to do another assembler, I might consider a PIC assembler which would indeed have this sort of feature so that opcodes could be conditionally inserted without breaking the assembler. Tell you what, though, there's nothing like writing an assembler and simulator to teach one the instruction set in a hurry! Regards, SJH Canberra, Australia