6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 9:54 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: 6502 Illegal Opcodes
PostPosted: Sun Feb 09, 2014 8:58 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Hi guys

I've been writing a BBC Basic like 6502 assembler for windows and am a good way into that.
I'm now trying to implement optional instruction files something like this::

6502 instruction file [loaded by default]
6502 illegal instruction file
65C12 instruction file

Does anyone have a comprehensive and accurate list of 6502 illegal opcodes? I used to have a list myself, but for some reason I can't seem to locate it and google is coming up blank.

Many thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Sun Feb 09, 2014 9:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Have a look at http://visual6502.org/wiki/index.php?ti ... 56_Opcodes and the links at http://visual6502.org/wiki/index.php?ti ... ed_Opcodes
cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Sun Feb 09, 2014 9:05 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I have some links to pages on them in one of the sections on my links page, at http://wilsonminesco.com/links.html#65fam .

_________________
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  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Sun Feb 09, 2014 10:27 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Fantastic - thanks very much guys :)
I'll be posting an alpha video demo of my assembler soon. let me kn ow what you think? :)


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Sun Feb 09, 2014 10:28 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
I like Neil Parker's take on things ... very colorful and informative.

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 11:30 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
banedon wrote:
65C12 instruction file

Might be worth noting that the 65C12 is like a 65C02 but without the TRB and TSB instructions (which are also[*] missing on the 65816) - it's a CPU found in Acorn's BBC Master computer. (Their external Second Processor used a 65C02, whereas the internal Coprocessor for the Master used a 65C102)

Edit: [*] as Mike points out below, this is not so!


Last edited by BigEd on Mon Feb 10, 2014 4:22 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 4:18 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
BigEd wrote:
... without the TRB and TSB instructions (which are also missing on the 65816) ...

I believe that TRB and TSB are there on the 816 (BBD will no doubt confirm). It's the BBR, BBS, RMB and SMB instructions that aren't there, probably because they suck up too much opcode space.

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 4:21 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Silly me - you're quite right. So, the 65C12 lacks both sets.
Thanks for the correction
Ed


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 5:55 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8505
Location: Midwestern USA
barrym95838 wrote:
It's the BBR, BBS, RMB and SMB instructions that aren't there, probably because they suck up too much opcode space.

I don't miss them. Even when I did 65C02 development I never found a use for them. :lol: Their space was taken up by more useful instructions in the '816.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 8:20 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I have never used them either. It would be nice if they were there with an absolute (instead of ZP) addressing mode, to make them useful for I/O. I guess they were in ZP because a few microcontrollers had I/O there and they had so little ROM that it was important to save one byte each time one of these instructions was encountered; but that's not normal for our applications. The '816 of course has so many additional instructions and addressing modes that are more important, that keeping BBS & friends would have required using the WDM op code extension and making them 5-byte instructions taking probably 8 clocks. I probably should be always bank 0 (regardless of the data bank register) as that's where I/O would normally be.

_________________
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  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 8:55 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8505
Location: Midwestern USA
GARTHWILSON wrote:
I have never used them either. It would be nice if they were there with an absolute (instead of ZP) addressing mode, to make them useful for I/O. I guess they were in ZP because a few microcontrollers had I/O there and they had so little ROM that it was important to save one byte each time one of these instructions was encountered; but that's not normal for our applications. The '816 of course has so many additional instructions and addressing modes that are more important, that keeping BBS & friends would have required using the WDM op code extension and making them 5-byte instructions taking probably 8 clocks. I probably should be always bank 0 (regardless of the data bank register) as that's where I/O would normally be.

TRB and TSB are very useful in I/O work,as they may be used on hardware registers to turn off or turn on features (but not on the NXP 2691, 2692 or 2698!). In the 65C816, TRB and TSB can process 16 bit values, making them extra useful in filesystem structure manipulations. For example, in UNIX-like filesystems, file characteristics are encoded into a 16 bit value, of which nine bits specify read, write and execute permissions for owner, group and others. Real easy to diddle with the '816 in 16 bit accumulator and memory mode and a 16 bit mask in the accumulator.

One of my reasons for ignoring BBR and BBS, other than their limitation to ZP addressing, is that the bit being tested is hard-coded into the instruction, making it a hassle to write a routine that can change which bit it's testing on the fly. Also, I mostly use bits 6 and 7 (or 14 and 15 if the m bit in the 65C816's status register is cleared) for flag purposes, which are easily tested with a BIT instruction. Or BIT immediate can be used...plus TRB and TSB can readily clear or set those bits. There's lots of bit-twiddling flexibility without the BBR and BBS instructions being present.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 9:51 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
Yes, and I do use TSB, TRB, and BIT (with bits 6 & 7 having a privileged place), plus putting bit-bang clocks on ports' bit 0 to produce a full pulse on them with just two instructions INC DEC; but it would still be nice to be able to set or clear any arbitrary bit in a sigle instruction without affecting processor registers, or to be able to test and conditionally branch on any arbitrary bit (regardless of position in the port), all in one instruction.

PIC16 microcontrollers may appear to have an advantage there, but that advantage kind of disappears when you consider a couple of serious drawbacks. Without resorting to an inefficient mickey-mouse bank-switching scheme, they can only address 128 combined RAM and I/O and other special-function register addresses; and with bank-switching, you only get 512 total, in four banks. To make it worse, BTFSC (bit test file skip if clear) and BTFSS (bit test file skip if set) really only let you conditionally branch forward and around a single instruction; so if you need to branch around more, or branch backward, you have to use the opposite test and follow it with a GOTO to conditionally branch. It takes 8 to 12 clocks.

_________________
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  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Mon Feb 10, 2014 11:01 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8505
Location: Midwestern USA
GARTHWILSON wrote:
Yes, and I do use TSB, TRB, and BIT (with bits 6 & 7 having a privileged place), plus putting bit-bang clocks on ports' bit 0 to produce a full pulse on them with just two instructions INC DEC...

DEC and INC would blow up on my POC unit if applied to some of the 26C92's registers, as the R-M-W sequence would violate timing on the device with the MPU running any faster than a cheap pocket calculator. Ditto with TRB and TSB.

Aside from potential timing issues, I have fastidiously avoided using DEC and INC on hardware due to the non-obvious effects that such instructions can have. Way back when when I was first learning this stuff (c. 1970), we were schooled to never use R-M-W instructions on hardware, it being deemed bad programming practice that would bite you in the...er...gluteal region. I still think that way, which proves that I really am a big, dumb dinosaur. :lol:

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Illegal Opcodes
PostPosted: Tue Feb 11, 2014 12:22 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
GARTHWILSON wrote:
It would be nice if they were there with an absolute (instead of ZP) addressing mode, to make them useful for I/O.
I do use BBR/BBS and RMB/SMB instructions for I/O, and Garth is certainly correct about their aptness in that regard. My experiences have been 100% positive. To give the subject the attention it deserves, I've started a new thread: huge speedup with 65C02 I/O mapped into zero-page

cheers
Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


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 13 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: