PASM code question
10gigbill
Posts: 79
New at PASM. Need some help. I would like to pass 4 ascii characters (numbers) to a pasm obj and have them converted to binary and added together . So I thought I would start simple and just try to add some numbers and have the pasm obj return a value. See attached code.
Something is not quite right .
adder_test.spinadder.spin
Something is not quite right .
adder_test.spinadder.spin
spin
984B
Comments
I think it's not so much a problem of the PASM but of the SPIN-part
The first method of SPIN-program starts after booting the propeller.
If this first method is executed the cog is shutdown
this means
PUB summit is executed with zeros and thats all
method "start" and method "what" never execute
So I would add Debug-output to PST.EXE with using FullDUplexSerial
to see what the program flow does
keep the questions coming
best regards
Stefan
If you just swap the submit() and start() method calls, then add a wait between the start and the what() call, it should work.
Could I change PUB summit(no1,no2,no3,no4) to PUB summit(no1,no2,no3,no4):cow
So then I would only make one call?
Billadder4.spinadder_test.spin
I have spent many long hours to get this far. If it weren't for you guys helping out I don't think
I could have found all the answers in the two propeller books I have. I will attach my latest.
Thank you for your support
Billadder5_test.spinadder5.spin
As you are working with PASM do you know PASD?
keep the questions coming
best regards
Stefan
1) The :loop label can be moved down a line to remove an unneeded instruction.
2) You don't need both the init_asm and gohere label, they are both the same address.
3) As your submit method executes, your PASM cog it already adding the existing values. A more appropriate way to do this might be to have the PASM code wait for a "submit" variable to be set, or the fourth variable to be a non-zero or non-negative-one.
4) In the same idea as the previous tip, returning a "done" flag would be worthwhile because, all you do it grab the total, as soon as you have set the values to add. I am surprised the timing works correctly. It seems the first run through of the submit method might actually return an incorrect result. This will be absolutely a necesity when you create longer PASM algorithms.
Something like this:
you are right. I have added more code, as my original goal was to have a PASM object to convert
4 octal digits to binary. and it does return a wrong answer the first time. I will try to make your
recommended changes and will post it here a little later... thanks again... this is all a great educational
adventure.
Bill
I'm think the octal to binary convert code is OK it was returning the right answer (on second call) before.
something not quite in the right place...?
Billadder8_test.spinadder8.spin edit... 10minutes later... I think I got it, have to add 4 to par since we stuck in "done"
and add 4 to the first number fetch.. now is working...