Assembly programming problem with CNT
HGPL
Posts: 15
Hi,
I worry about the code below:
The waitcol is working. The waitcol2 not working...
I think make the fixrate wait with a pin verifying capability, and the waitcnt not good here...
Anybody know help for me...?
thanks, Gabor
Post Edited (HGPL) : 11/6/2007 4:18:41 PM GMT
I worry about the code below:
mov wcol,#1 shl wcol,#28 ... call #waitcol or call #waitcol2 ... waitcol2 mov tnextcol,cnt add tnextcol,wcol cmp cnt,tnextcol wc 'c=1; cnt < tnextcol if_c jmp waitcol2 waitcol2_RET ret waitcol mov clk,cnt add clk,wcol waitcnt clk,wcol waitcol_ret ret
The waitcol is working. The waitcol2 not working...
I think make the fixrate wait with a pin verifying capability, and the waitcnt not good here...
Anybody know help for me...?
thanks, Gabor
Post Edited (HGPL) : 11/6/2007 4:18:41 PM GMT
Comments
(1) JMP #waitcol2B
(2) Set the label waitcol2B before the CMP; you have I fine moving target with your original code
Very thanks... [noparse]:)[/noparse] last hour was very poor for me...
HVALA
The # is a very high blame... [noparse]:)[/noparse]
but... [noparse]:)[/noparse]
... and not working yet...
Post Edited (HGPL) : 11/6/2007 4:37:53 PM GMT
It is working, but I don't know why need the T1 temporarily variable...
Is CNT not working with CMP command?
The rule is: Never use a "special register" at the DEST operand unless you exactly know what you are doing..
The reason: You will not read:
- CNT
- INA
- PAR
- PHSA
- PHSB
as expected!
Rather you will read what you last have written to it. This is well know as "The Behaviour Of The Shadow Registers"
You can fix it in your second example by just reversing CNT and TNEXTCOL and jumping IF_NC
Another note: Once every 40 to 50 seconds your program will fail, when the CNT overflows from $FFFF_FFFF to $0
I will read deep the documentation [noparse]:)[/noparse] thanks.
My setup is _CLKMODE = RCFAST
The fail wait about 6 minutes and i will correct the code but this mistake not matter for my app.
thanks
You can avoid using the temp variable 't1' if you use cmpsub instead of cmp
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/7/2007 7:55:08 PM GMT
but this last code is not working...
I read the CMPSUB doc, and I think the code is ok, but the CNT usage is not working with this command...
Post Edited (HGPL) : 11/6/2007 6:06:27 PM GMT
(1) You have to read the "Erratum" www.parallax.com/dl/docs/prod/prop/PMv1.0Supplement-v1.3.pdf
The description of the CMPSUB instruction is not only absolutely confusing in the Manual, it is WRONG!
(2) You don't need CMPSUB! Your program will work fine, when you just reverse the operands of CMP and JUMP if NC, as I described above...
BTW: The Eratum 1.3 now contains detailed hints wrt the "Shadow Registers"
Edited...
Post Edited (deSilva) : 11/6/2007 11:09:41 PM GMT