Assembly routine question
Pliers
Posts: 280
How do I compare the Exit_Pattern to the current Pattern and then exit the loop if they are equal ?
PUB ex01 cognew(@ex01A, 0) DAT ORG 0 ex01A MOV DIRA, My_out ' Output to I/O 16 thru 23 loop MOV OUTA,pattern add pattern, #1 JMP #loop ' repeat loop My_out long $00FF0000 'IO pins set pattern long $0 'Starting value Exit_Pattern long $AA ' Pattern to cause exit from loop FIT 496
Comments
Is this a good way to exit an assembly program?
You would have to use ADD pattern, my_00010000
Not having to declare every value over 511, you could use shl instead with a declared Constant
The extra code space will be offset by not having any longs declared.
If you want up to and including $AA on LED, could switch places for ADD and CMP , or use #$AA+1
stop jmp #stop
If power demands are important, then stop the cog like this: In this case, you'll have to be careful about output pins since they'll all be changed to inputs when the cog is stopped. If turning off the cog is important, but you need to leave the I/O pins as is, consider setting up a loop like this: This essentially waits for an I/O pattern that will never exist, but there's a JMP just in case.
You guys are great.