[Coco] Direct page register question

Salvador Garcia salvadorgarciav at yahoo.com
Tue Oct 30 17:08:33 EDT 2018


 Thanks all!

Now I am officially confused.

I believed that using direct addressing produced opcodes for LDA, for example to be one byte less because the 16 bit address did not have to be specified, yet below it says that the instruction is expanded to include DP's value? Is that correct?

Then there is the SETDP directive defining whether direct or extended addressing is used. So if LDA $4085 assembles as direct addressing, does that mean that the DP doesn't come into play here?

What I understand, I think, is that the interpretation of something like LDA $85 depends on the use of the directive and which assembler is being used.

Hmmm... reading a PDF of WIliam Barden's Color Computer Assembly Language book makes a mention of this:
(page 40)
DP = 0:   LDA $50 - uses direct addressing cause $50 is $0050 and the MSB of that is equal to the DP reg.
DP = $12:    LDA $1250 - uses direct addressing cause DP has $12, so LDA $1250, for this case, is equivalent to LDA $50
The second doesn't seem to make sense because, how would the assembler know whether the DP is equal to the MSB of the address given?
Ah! Clarity! Later on, on page 40, the author explains that indeed, the assembler has no clue as to the value in DP, but for this we can use the SETDP directive so that when LDA $1250 is used, it compares the MSB to what was indicated by the SETDP directive and if they match then it uses Direct Page addressing.
Now I understand. if I use SETDP $40 and then LDA $50 the assembler will compare the MSB of $50 to $40 and use Direct page addressing if they are equal, but if it is different it will use extended, assembling the load using the full 16 bits in $50.
Is that right, or am I whistling Dixie with a mouth full of peanut butter?
Thanks, Salvador




    On Tuesday, October 30, 2018, 3:15:42 PM CDT, Dave Philipsen <dave at davebiz.com> wrote:  

<snip>
> So if you do "SETDP $40", then "LDA $4085" would assemble as direct addressing but "LDA $85" would assemble as extended.
> 
> 
Yeah, I should have been more clear about that.  The LDA  $85 would always be interpreted as a full 16-bit address ($0085)  even though you only specified 8 bits. You can’t do a LDA  $85 and assume that the assembler would expand it to LDA  $xx85 where xx=the DP register.<snip>

  


More information about the Coco mailing list