{{Multiplication based on the propeller manual page 380 as a subroutine}} CON _clkmode = xtal1 + pll16x '_xinfreq = 6_250_000 'MY BOARD AT 1OOMHZ DIFFERENT CRYSTAL _xinfreq = 5_000_000 'QUICKSTART 80 MHZ NORMAL CRYSTAL var 'VARIABLE IN THE PAR ADDRESS TO BE PASSED long x long y long product obj pst:"parallax serial terminal" pub main x := 2 y := 9 pst.start(115000) waitcnt(clkfreq*5 +cnt)'hold five sec to open the 'serial terminal and enable it cognew(@asm,@x)'start cog at the first variable address waitcnt(clkfreq*2 +cnt) 'give pasm time to do the work pst.str(string("product:")) pst.dec(product) pst.newline dat '' Multiply x[15..0] by y[15..0] (y[31..16] must be 0) ' on exit, product in y[31..0] ' asm org mov temp_var, par 'move par to a temporary variable mov x_var, temp_var 'find the x variable rdlong x_var, temp_var 'read in the value from top object add temp_var, #4 'jump to next long which is the address of the ' next variable mov y_var, temp_var 'repeat assignment and read in value rdlong y_var, temp_var add temp_var, #4 'jump again to assign the product variable address mov product_var, temp_var wrlong y_var, product_var 'test first part prior to subroutine call call #multiply call #writer cogid cogname cogstop cogname multiply shl x_var,#16 'get multiplicand into x[31..16] mov t,#16 'ready for 16 multiplier bits shr y_var,#1 wc 'get initial multiplier bit into c :loop if_c add y_var,x_var wc 'if c set, add multiplicand to product rcr y_var,#1 wc 'put next multiplier in c, shift prod. djnz t,#:loop 'loop until done call #writer '<<<<<