6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 01, 2024 3:34 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: 6502 Assembler question
PostPosted: Sat Jan 09, 2021 9:52 pm 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
Hello there,

The joined parts are extract from a compilation listing... I have to rewrite the asm source file from there.

Anybody can explain me the signification of the character <'> which follow the instruction LDXIM in the first attachment ?
This kind of instruction appear several time in the listing also with CMPIM instruction.

In the second attachment how describe the table values in the source file ?
And again have the <'> a special signification in this table ?

Thanks for the attention.
Regards.

Philippe


Attachments:
Capture d’écran_2021-01-09_22-26-11.png
Capture d’écran_2021-01-09_22-26-11.png [ 13.85 KiB | Viewed 995 times ]
Capture d’écran_2021-01-09_22-26-51.png
Capture d’écran_2021-01-09_22-26-51.png [ 24.06 KiB | Viewed 995 times ]
Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 09, 2021 9:59 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10971
Location: England
Welcome Philippe!

It looks like the ' character introduces a character constant. So 'A would be $65, 'B would be $66, '7 would be $37, and so on. Where you see a ' with no following character, in this case it's a space - you can see in the left columns that it was value $20.

>In the second attachment how describe the table values in the source file ?

I'm not sure what you're asking there. In this particular assembler it looks like '=' introduces a single byte constant. Other assemblers might use .DBYTE or EQU or some other syntax. (I just made those up - could be mistaken! There will always be some syntax for a single byte constant.)


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 09, 2021 10:04 pm 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
I fully agree with you explanation for the first question. Thanks.

I expect to use A65 for compiling the source.
The question is more or less how to describe a fixed value at an address in the source file.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 09, 2021 10:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10971
Location: England
Do you have a link for A65? There's a chance that there's more than one 6502 assembler with that name!


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 7:42 am 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
Till now I have used this in a dosbox :

http://retro.hansotten.nl/uploads/junio ... re/a65.zip

Thanks for the help.
Philippe


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 7:45 am 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
.BYTE (8bits) or .DBYTE (16 bits) seems to be the answer...

But if <'> give $20 what will give a <.BYTE '1> instruction ? Or may be <.DBYTE '1> ?

On my listing $31 ($20 + $11 ?) will be stored at this address.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 8:03 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8534
Location: Southern California
wawavoun wrote:
But if <'> give $20 what will give a <.BYTE '1> instruction ? Or may be <.DBYTE '1> ?

I think the idea was that there was a space after the ' and $20 is the ASCII value of a space; so the ' does not stand alone.

_________________
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: Sun Jan 10, 2021 9:21 am 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
In the listing I think there is no space after <'>. See here after....

When the <'> follow LDXIM or CMPIM it is unsure....

At least TASM dont like <.BYTE '1>....


Attachments:
extrait.png
extrait.png [ 49.69 KiB | Viewed 958 times ]
Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 9:46 am 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
but <.BYTE '1'> produce the expected result in the listing...
It is more clear now !

Probably you are right the others instructions should be <LDXIM ' '> with a space between...


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 11:28 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10971
Location: England
Sounds like you are getting closer: indeed a more conventional assembly syntax would put the single ASCII character in between two apostrophes: 'X'. But the assembler behind the listing you have evidently requires only the first apostrophe: 'X


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 4:16 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
wawavoun wrote:
In the listing I think there is no space after <'>.


The early Motorola assemblers used the convention of a prefix designating the type of a value.

Most well known is '$' to indicate a hexadecimal number.

Less well known is an apostrophe to indicate an ASCII character.

Unfortunately, they did not choose to implement the clearer convention of surrounding the character between two apostrophes, but that the character following is the literal value. This decision has unnecessarily made the specification of a space character into a fringe case.

To make matters worse, some assemblers refused to accept

Code:
 ldaa #'A'


While the text editors at the time did not automatically delete training spaces on a line, reliance on the presence an "invisible" character is inviting disaster. If that trailing space is deleted, the literal value is a carriage return or line feed character depending on the conventions of the operating system for a text file.

Some people coded defensibly by

Code:
 ldaa #$20


I used the following technique in my code:

Code:
 ldaa #' space


The comment made the intent clear and protected the space character from accidental deletion.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 5:07 pm 
Offline

Joined: Sat Jan 09, 2021 9:33 pm
Posts: 24
Thanks for the help. By chance TASM accept fe <CMP #' '> so solved now...

After work on the source file come the first compiling tries...

I have a lot of unrecognized instructions... Quick check in A65 and TASM documentation show they are not opcodes of 6502.

They are :
CMPIM
JMI
LDAX
LDAY
LDAIM
SBCIM
ANDIM
ADCIM
LDYIM
LDXIM
STAIY
CPXIM
ORAIM
CPYIM

It seems there are addressing mode variants... This is show by the resulting byte on the compilation listing but then I have to translate in a way TASM understand...

I think <CPYIM $00> should become <CPY #$00> and so on for each instruction with IM at mnemonic end. Right ?

More ubiquitous for me is LDAX, LDAY, STAIY and JMI...
Should <LDAX TABLE> become <LDA TABLE,X> and <STAIY RAMPTR> become <STA (RAMPTR),I> ???
And <JMI JMPVEC> become <JMP (JMPVEC)> ?

Thanks for your help !
Philippe


Last edited by wawavoun on Sun Jan 10, 2021 5:12 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 5:09 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10971
Location: England
I think your suppositions are correct: LDXIM and similar were quite commonly seen, I think, but are these days outside the mainstream. I think I could quite like them, although they are not what I'm used to.

As your listing gives you the hex values of the opcodes that the assembler produced, you can easily check your thinking.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2021 6:14 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 704
Location: North Tejas
wawavoun wrote:
It seems there are addressing mode variants... This is show by the resulting byte on the compilation listing but then I have to translate in a way TASM understand...

I think <CPYIM $00> should become <CPY #$00> and so on for each instruction with IM at mnemonic end. Right ?

More ubiquitous for me is LDAX, LDAY, STAIY and JMI...
Should <LDAX TABLE> become <LDA TABLE,X> and <STAIY RAMPTR> become <STA (RAMPTR),I> ???
And <JMI JMPVEC> become <JMP (JMPVEC)> ?


Correct.

Parsing the operand and determining the addressing mode is not trivial.

Instead of trying to distinguish between

cpy #<value>
cpy abs
cpy zpg

unique mnemonics were defined for each form.

The same thing was done in the 8008, 8080, Z80 world as assemblers became more "advanced."

lab on the 8008 became
mov A,B on the 8080

while

lai <value> on the 8008 became
mvi A,<value> on the 8080 to
ld A,<value> on the Z80


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 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: