CON oscmode = $010007f8 freq = 160_000_000 baud = 230_400 OBJ ser: "spin/SmartSerial" VAR long cog long data long data2 long answer PUB main clkset(oscmode, freq) ser.start(63, 62, 0, BAUD) pausems(500) ' wait for baud change on host ser.str(" PASM demo addition: ") ser.nl ' ADD THESE TWO VALUES data := 200 data2 :=36500 cog := cognew(@startasm, @data) ser.str(" cog: ") ser.dec(cog) ser.nl '' wait until the COG has finished '' it indicates this by clearing "data" repeat while data <> 0 '' now print results ser.str(" answer = ") ser.dec(answer) ser.nl DAT startasm '' assembly program to add numbers '' we start with ptra pointing at the number '' the answer must immediately follow the input data '' in the VAR section rdlong value, ptra 'get first value add ptra, #4 ' move over to pickup next value 'in the next long rdlong value2, ptra 'get second value add value2, value mov value3,value2 'move to answer var in next long add ptra,#4 wrlong value3,ptra 'write it to the pointer '*****HERE IS THE QUESTION********* sub ptra, #8 ' point back to original data???? wrlong #0, ptra ' tell original COG we are done '' now shut down cogid value cogstop value value long 0 'data value2 long 0 'data2 value3 long 0 'answer