[Coco] Mod10 Suggestions

Glen Hewlett glen.hewlett at sympatico.ca
Thu Feb 16 22:57:28 EST 2017


Hi William,

It’s cool that you are getting into assembly now, you can push the limits of any PC if you do it with assembly.  The 6809 is an awesome chip to learn assembly on too.  Mark has some good points.  I thought I’d share some too. 

You can change the init code:
;        CLRB   * Clear the Byte directly leaving B to be used for other things
;        STB	#RESULT	;Clear the result field.  I don’t think you can do this explained below. You would normally just STB   RESULT
        CLR     RESULT

Another thing if you need to make a byte a $FF and not touch your accumulators you could:
	CLR		STAUTS
	DEC	STATUS
Or to make a byte a 1
	CLR		STATUS
	INC		STATUS

Anytime you need to make A or B zero use CLRA or CLRB, it’s uses 1 byte instead of two

Brett beat me to the loop method…. That is a good one

Maybe I will learn something here but I don’t think you can use the Store ST command with the # that I see in your code such as
STA		#RESULT
STA		#STATUS

I think you would simply use:  Maybe some assemblers will accept it as the same...
STA		RESULT
STA		STATUS

Good for you for getting into assembly, it’s good for the brain as you have to account for everything.  But in the end when your code is working perfect it’s a really nice feeling…

I don’t know what is worse when you're programming, if your code isn’t working right in the first place or you think your code is working properly then you notice a mistake in your code and think how could the program have worked like this?  :)

Also a great book to learn 6809 assembly programming on the CoCo is William Barden Jr.’s book Color Computer Assembly Language Programming, I’m sure if you Google it you can find a pdf around.

Cheers,
Glen

> On Feb 16, 2017, at 10:06 PM, William Mikrut <wmikrut72 at gmail.com> wrote:
> 
> The only reason I am using lda a,x is I am actually reading the number
> backwards (from right to left)... not that I have to.
> 
> For that MUL I should have used an ASLB -- 2x1 is still 2!
> 
> Why not sub 9... right!  I get too caught up in the technique instead of
> the practical.
> 
> I was using A for a loop counter because I didn't want to keep loading a
> var with a value.
> however, I'll give it a try.
> 
> Thank you for the suggestions!!
> 
> 
> 
> 
> On Feb 16, 2017 8:20 PM, "Mark McDougall" <msmcdoug at iinet.net.au> wrote:
> 
> On 17/02/2017 12:26 PM, William Mikrut wrote:
> 
> Following is a MOD10 program I have used for years in IBM programs.
>> I have translated it the best I can...I am sure it is not the most
>> efficient... and I have much to learn.
>> 
> 
> I can't go through it now but a couple of things jump out at me
> immediately...
> 
> * Rather than using LDB A,X to get the next digit, simply increment X each
> time through the loop, using auto-increment.
> 
> * Multiply by 2 is a left shift. Because your digits are 0-9, you'll never
> get overflow.
> 
> * Why sub 10, then add 1? Why not sub 9?
> 
> * I'd probably store the loop counter on the direct page myself.
> 
> * Count from 15 to 0 (-1) to eliminate CMPA #0 (which can be replaced with
> TSTA in this case)
> 
> * Should be STB RESULT (no hash)
> 
> I'm sure Simon can get this down to 4 lines (with music)! ;)
> 
> Regards,
> 
> -- 
> Mark McDougall
> <http://retroports.blogspot.com.au>
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list