[Coco] Assembler Question???

William Astle lost at l-w.ca
Wed Sep 2 13:49:43 EDT 2009

jdaggett at gate.net wrote:
> That is what I would expect. To better qualify what my question better is what is the 
> binary code generated from a SUBA #1. My suspicion is;
> When SUBA #1 ( immedate mode)  is assembled and it is stored in binary form as
> $80 $FF instead of $80 $01. 
> Why I think this is because of the two things. One from what I remember  from teh 
> MC6800 schematic, there was an internal adder but no subtractor. Subtraction was done 
> by 2's compliment. Also by the branch relative instruction offset byte(s) are stored as 2's 
> compliment so that a simple add is performed and the adition is unsigned addition.
> Also the Motorola Freeware Assembler mentions that arithmetic is done is 2's 
> complement.  Thus this implies that subtraction is done with 2's complement. 
> I can be wrong about this and to do addition internally, one port to the ALU has a 2's 
> complement generator at its input to do subtraction by addition
> Any way I can implement a 2's complementor and then do add and either invoke it or 
> not. 

The assembler does not do anything special with SUB instructions. SUBA 
#1 is encoded as $80 $01. After all, if it did expect something special, 
SUB instructions would not work with data accessed via indexing and so on!

Note that both SUB and ADD take the same number of clock cycles so 
whatever the CPU does internally fits in a clock cycle.

William Astle
lost at l-w.ca

More information about the Coco mailing list