6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 11:56 pm

All times are UTC




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Fri Jan 25, 2008 9:37 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
debounce wrote:
kc5tja wrote:
debounce wrote:
FWIW I prefer the old syntax, and not just for inertia's sake. Addressing modes are an 'intellectual convenience' I'd like to keep, as they are a mnemonic in themselves.


That is their syntactic point -- the idea is to make assembly language a bit more like a high-level language.
Not sure what you're saying here. You mean "the idea [of bracket-and-comma] is..." or "The idea [of all-alphabetic] is..."? If the latter, then reducing mnemonics to a simple label for an opcode byte (and a width specifier for the following operand) pushes the assembly language closer to machine code. As evidenced by the Forth examples quoted earlier.


Therefore, I must be talking about the former.

Quote:
INC abs,Y is an illegal instruction (the only one that's bitten me.) It's just as easy to assume INCAY abs exists.


But this particular problem is not what is being discussed. Look at the subject of the message: LDA 5 versus LDA #5. We're specifically addressing the issue where you have ambiguity.

Quote:
And the mnemonics aren't such great mnemonics any more. Some people work better with brackets and commas.


This is a "what I learned first stays with me" issue. You only think this because you learned the current syntax first.

Compare: Folks who program the 68000 series of CPUs find Intel's native syntax to be retarded. Also, folks who grew up coding on Zilog or Intel machines first find Motorola syntax to be gobsmackingly stupid. You find religious wars over whether Unix assemblers should continue to use such "AT&T-syntax" (which is basically Motorola syntax) to this day.

Quote:
The @ prefixes an otherwise bare operand of an instruction to indicate it is intended as an absolute address. Any addressing mode notation # () [] , A: Z: is enough to show the intention (or non-intention) and @ is forbidden. Where @ is allowed and the assembler does not generate a warning (depending on the sophistication of its heuristics), @ is optional. @ has nothing to do with ADDR notation, but there's no reason why the two couldn't be used in conjunction (though I'd rather there was a shorter and less shouty symbol than "ADDR+".)


Wait, what? I'm thoroughly confused by your proposition. Why bother with @ at all, if you already have A: and Z:?

Code:
        LDY     const   ; give warning
        LDY     @const  ; opcode AC or A4

You mean I have to actually work to decipher these opcodes? Uugh. I've offered a correction to the table, with published interpretations of various prefixes (published by WDC, I might add): :)
Code:
LDY const   ; give warning
LDY @const  ; LDY abs or LDY dp??
LDA <addr   ; ditto here; LDA abs or LDA dp??
LDA @<addr  ; LDA abs ; <N is NOT (N & 0xFF) on 65816.  See LDA # below.
LDA A:addr  ; LDA abs (for ca65 only)
LDA #<addr  ; LDA #nn(nn) -- note that LDA #>01020304 will load $0203 into A!!
STA const   ; AMBIGUOUS; STA A:$000F and STA Z:$0F are *NOT* the same thing on 65816!!
STA @const  ; STA abs


Even this table is pretty doggone confusing to me. What's needed is a distinguishing between types of access, and mathematical operators:

Code:
; new operators
HIBYTE x = (x & 0xFF00) >> 8
LOBYTE x = (x & 0x00FF)
HIWORD x = (x & 0xFFFF0000) >> 16
LOWORD x = (x & 0x0000FFFF)

; for WDC compatibility:
^ x = HIWORD x
> x = LOWORD (x >> 8)
< x = LOWORD x

; typecasts:
@ x = (make x an absolute address)
# x = (make x an immediate value)
& x = (make x a long-absolute address)
* x = (make x a direct-page address)


So, with this, we can be far more precise:

Code:
LDY const   ; give warning
LDY *const   ; LDA dp
LDY @const  ; LDY abs
LDA <addr   ; warning: LDA abs or LDA dp??
LDA @<addr  ; LDA abs
LDA *<addr   ; LDA dp
LDA #<addr  ; LDA #nn(nn) -- note that LDA #>01020304 will load $0203 into A!!
STA const   ; for sake of typing consistency, this would be a warning.
STA *const   ; STA dp
STA @const  ; STA abs


Quote:
@ notation is appropriate when the problem is framed as "# being left off instructions." ADDR notation is an appropriate response to "constants being used as addresses" (in which case STA const should give a warning.) I prefer @ notation as ADDR doesn't cover the case of an address being used as an address when it should have been used as a constant.


I have to giggle at this, because if we assume future assembler syntax takes this route, and to eliminate further ambiguities between (long-)absolute and direct page modes, then you end up with a system of prefixes that fundamentally aren't any different than one opcode, one mnemonic.

Quote:
We'll see, I suppose, which syntax wins out.


Nothing will change of course; WDC's syntax has defined the assembler syntax for decades. :)

So, with that in mind, this will be my final post on the topic. I think my opinion on this matter is already very well known, and we're flogging a dead horse. :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jan 26, 2008 4:42 pm 
Offline

Joined: Tue Dec 30, 2003 10:35 am
Posts: 42
My only aim was to catch the error with minimal changes to source, and preferably in a way that doesn't yield one's source incompatible with the standard ca65. I've succeeded in all these respects and have a simple, practical approach, so doubt I'll do much more work on it. Out of curiosity, has anyone actually tried my implementation? Using it would dispel a lot of the misunderstandings about how much work it requires to use.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jan 26, 2008 5:13 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I have to admit that I regularly use constants as both addresses and immediate values freely in my code, so I likely won't profit in using it until it becomes a problem for me (which is unlikely). However, that's no reason not to make it available to others. Have you considered submitting a patch to the ca65 maintainers?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 06, 2008 1:05 am 
Offline

Joined: Tue Sep 24, 2002 4:56 pm
Posts: 50
Location: Essex, UK
Just as a not - I'm sure that this is how 6502 assmbler was *originally* written, "way back when"; for example, have a look at the code towards the end of this article:

http://users.telenet.be/kim1-6502/micro ... chess.html

I'm not quite sure why the switch was made to the current way of writing code, but I *think* it may have been to generate "neater, tidier" code with "simple" 3-character opcodes...

Just my £0.02's-worth...

--Martin

_________________
Martin Penny

.sig in beta - full release to follow.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 16, 2008 7:28 pm 
Offline

Joined: Tue Nov 23, 2004 2:11 pm
Posts: 25
Location: London, UK
Sorry everyone, I take it all back. Strange as I'm usually more flexible. Perhaps I had believed it was The One True Syntax.

--G


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 9 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: