/ / mult.pal / / Started by Jeff Ondich on 9/17/96 / Last modified 9/18/96 / / This PDP8 program illustrates some simple features of / the PAL assembly language. It consists of a call to a / simple-minded multiplication subroutine, and leaves / the product in the AC when the program terminates. / *0200 MAIN, CLA OSR DCA FACTOR1 HLT CLA OSR DCA FACTOR2 JMS MULT HLT FACTOR1, 0 FACTOR2, 0 / MULT multiplies two non-negative integers, leaving / the product in the AC upon return. If the product / overflows 12 bits, the answer will be wrong. / / When MULT is called, the factors should be stored / in the locations FACTOR1 and FACTOR2. / MULT, 0000 TAD FACTOR1 CMA DCA COUNTER DCA PRODUCT / Initialize the product to 0 LOOP, ISZ COUNTER / Add FACTOR to PRODUCT SKP / and increment COUNTER JMP END / until COUNTER = 0. TAD FACTOR2 / This is A*B by way of TAD PRODUCT / adding up B copies of A. DCA PRODUCT JMP LOOP END, TAD PRODUCT / AC is clear before now, so / this loads product into AC JMP I MULT / Return to caller COUNTER, 0 PRODUCT, 0