| AGC assembler uses unusual mnemonics, so it can be difficult to understand for someone who doesn't know the architecture. The CPU has onle accumulator which instructions act on. The argument is normally an address. The relevant instructions for this code snippet is: AD - Add the value pointed to by the argument to the accumulator TS - Transfer to storage. Write the accumulator to the argument TCF - Transfer control to fixed memory. Jumps to an instruction in fixed storage DOUBLE - Assembler macro compiling to AD A. I.e. double the accumulator. XCH - This exchanges the value in the accumulator with the argument INDEX - Adjust the address used in the next instruction by the argument COM - Complements the accumulator. Note that the AGC uses one's complement arithmetic, so this negates the value. EXTEND - Indicate that the next instruction is an extended instruction MP - Multiply the accumulator with the argument The final instruction is TS Q which jumps to the location stored in the Q register. This is the return address which is updated by the TS instruction. In other words, TS can be used both as a regular jump as well as being used as a function call, depending on what the destination does with the Q register. I hope this helps you analyse the code further. I haven't spent much time looking at the code itself, so I am not going to attempt an analysis right now. |