6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 8:51 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Aug 22, 2015 5:31 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
I recently added a 65816 assembler module for naken_asm (and rewrote the 65xx assembler from scratch). Besides $, older syntax still doesn't work, but I plan to support as much as I can. Where might I learn what the de-facto assembler standards are for both chips?


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 22, 2015 8:58 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
I can't pass up the opportunity to recommend the excellent programming manual available for free download, "Programming the 65816 including the 6502, 65C02, and 65802" by David Eyes and Ron Liechty. It has the standard syntaxes. This is a .pdf file of a rather large book that is well laid out and is much better than the description there lets on. Note: There were many problems with the earlier .pdf version that were not in the original paper manual; but in late March 2015, WDC scanned and OCR'ed the paper manual and posted the new, repaired .pdf.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 9:49 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
The book recommendation helped a lot, thank you. So far '<', '>', and '!' works. '$' already worked, but we still have to add '%' and '&', as well as directives for accumulator/index sizes on the 65816 (longa on/off, etc).

I've noticed that some listings have "LDA A" or "ROL A" etc, so I may add that also, although it seems redundant. Anything else I'm missing?


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 10:08 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
In the C32 assembler I use, #< can be used to force 8-bit immediate addressing; so for example if you want an LDY #4 but the index registers are to be in 8-bit mode, you'd do LDY #<4. Then you don't have to use extra lines to tell the assembler whether to assemble 8-bit or 16-bit operands. It works very well, and I have come to prefer it.

As for things like ROL A, I like it to accept it without the A to make the source code a little cleaner. If there's no operand specified on these, then it's automatically A.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 11:46 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
This seems a lot clearer to me, and already works. I realized that its possible to use 'A' for a label name so I don't think I can support it anyway. Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 25, 2015 5:54 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
joe7 wrote:
The book recommendation helped a lot, thank you. So far '<', '>', and '!' works. '$' already worked, but we still have to add '%' and '&', as well as directives for accumulator/index sizes on the 65816 (longa on/off, etc).

I've noticed that some listings have "LDA A" or "ROL A" etc, so I may add that also, although it seems redundant. Anything else I'm missing?

The MOS Technology standard assembler syntax required that all accumulator instructions other than implied have an operand. I no longer recall the exact reason why, but ROL A in that standard means left-rotate the accumulator, with A symbolically representing the accumulator. An instruction such as LDX #A would cause a syntax error, as A is a reserved symbol. I also recall that something like A = 10 would cause an error, again because A was reserved.

The supported radices in that standard are % for binary, @ for octal, none for decimal and $ for hexadecimal. I believe those were "borrowed" from the Motorola 6800 assembly language for both political and practical reasons. The official MC68000 assembly language uses them as well.

The assembly language syntax described in the 65C816 data sheet largely continues the MOS Technology standard, with additional operators to accommodate 24 bit addressing and cases where one or two bytes of a 24 bit operand are needed. It's generally good practice to stick to publish standards and avoid the temptation to devise alternatives.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 28, 2015 4:13 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
I think I can actually support everything mentioned, so hopefully this time around the full syntax will work for 65xx/65816.

Since this is part of a larger assembler suite, the default modern syntax is also available:

https://github.com/mikeakohn/naken_asm/ ... ter/README

I added .b, .w, and .l suffixes which force certain addressing modes (direct-page, absolute, and absolute-long, respectively). With these additions, it's possible to use the default syntax entirely if desired.

(The choice exists but discretion should be used when using a non-standard syntax: mention it in the code, etc.)


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 03, 2015 9:49 am 
Offline

Joined: Mon Jan 26, 2015 6:19 am
Posts: 85
GARTHWILSON wrote:
As for things like ROL A, I like it to accept it without the A to make the source code a little cleaner. If there's no operand specified on these, then it's automatically A.

When coding an assembler for my forth, I found that I couldn't use A as an argument since it would prevent using A as a constant or variable. I reluctantly concluded that instructions like ROLA, LSRA were the least complicated methods of coding these accumulator mode instructions.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: