[Coco] assembly language question.

William Astle lost at l-w.ca
Wed Feb 3 21:35:16 EST 2010


Gene Heskett wrote:
> Greets all;
> 
> I've read through the moto programmers manual for the 6809 for the cmp 
> functions, and am still confused.  The cmp function is a subtract function 
> where the answer is thrown away, only affecting the CC flags so that a 
> following beq or blo will take the correct jump.  But somehow, it isn't clear 
> which is subtracted from what.
> 
> Given that regs.x contains $02FA, and that the integer memory location 
> referenced by LblName contains $000A, will the blo take, or be ignored here?
> 
> 	cmpx  <LblName memory address in DP that holds the $000A above
> 	blo	somewhere else

The subtraction in CMP is exactly equivalent to SUB. That is, the 
operand is subtracted from the register. In this case, the subtraction 
is $02FA-$000A giving $02F0 with C=0, N=0, V=0, Z=0.

In this case, the condition will be false so no branch will be taken. 
(BLO is the same as BCS or branch if C=1).

Thus, in the above, if X is less than the value at LblName (unsigned), 
the branch is taken; otherwise it's not.

-- 
William Astle
lost at l-w.ca



More information about the Coco mailing list