Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > illegal opcodes that f
2003-02-05 09:02
Dwangi

Registered: Dec 2001
Posts: 129
illegal opcodes that f

2003-02-05 09:04
Dwangi

Registered: Dec 2001
Posts: 129
hmm sorry something went wrong here the topic should be "illegal opcodes that fuxx up or something" :)

Anyway.. can anyone tell me any illegal opcodes that works fine on a c64 but that dont work on c128?



2003-02-05 09:20
Ninja

Registered: Jan 2002
Posts: 404
Try looking here:

http://mars.wiwi.uni-halle.de/ec64/technical/aay64/c64/ibmain.h..

The instable opcodes are marked, dunno if they fail on C128 only...
2003-02-05 10:42
Graham
Account closed

Registered: Dec 2002
Posts: 990
http://oxyron.net/graham/opcodes.html
2003-02-05 10:46
Graham
Account closed

Registered: Dec 2002
Posts: 990
forgot to say: the blue marked opcodes are unstable but still usuable (like SHX/SHY which is used quite often), the red marked ones are completely unusable atleast on some machines.
2003-02-05 16:38
Ninja

Registered: Jan 2002
Posts: 404
graham: could you please give me a hint what SHX/SHY could be used for when from time to time the "&H" is dropped?
2003-02-07 18:52
Graham
Account closed

Registered: Dec 2002
Posts: 990
Quote: graham: could you please give me a hint what SHX/SHY could be used for when from time to time the "&H" is dropped?

the "&H" is only an unwanted side-effect which originally wasn't supposed to be.

SHX and SHY should have been STX (adr),Y and STY (adr),X.
due to some internal trouble in the 6502 core the value which is going to be stored to ram is on the internal cpu bus at the same time as the incremented high-byte of the adress. this results in a logical AND in most cases.

These two opcodes exist in legal form for zeropage adresses, but sometimes you could use them for other memory aswell, so if you really badly need them, you use SHX or SHY and choose an adress which doesn't harm the values you want to store (usually that would be $3E00, $7E00 or $FE00). for example, oneder uses these illegal opcodes to make some calculations a lot faster. if the demo is run on a cpu which doesn't have these illegal opcodes, an alternative code is executed which is slower, but i think this doesn't matter because that usually would mean that the demo is run on supercpu or something similar.
2003-02-07 19:52
Ninja

Registered: Jan 2002
Posts: 404
Graham: Thanx! That is a fucking cool trick :)

So, it looks like the 6502-designers at least tried to implement STX xxxx,Y but simply failed?
2003-02-07 21:16
Stryyker

Registered: Dec 2001
Posts: 465
Failed? I have no idea how they make an opcode legal or illegal but if you search the online Transactor achives there is some writing on how the 6502 possible decodes the opcode (bitwise) which helps further explain all the patterns. Maybe they thought at a later date we will debug it, much like how one of the shift or roll instructions wasn't added until June 1976 or so.
2003-02-08 13:03
Graham
Account closed

Registered: Dec 2002
Posts: 990
anyway, they never really fixed these opcodes, but they were "replaced" by STZ which usually means: store zero to ram (hardly any 6502-based cpus actually have a Z-register). this way they didn't need to fix anything, just pull everything to zero. that's also the reason why the 65816 does indeed have STX and STY indexed adressing modes, but on other opcodes. they wanted to keep the STZ's on $9C and $9E to remain compatible with previous designs.
2003-02-11 10:02
chatGPZ

Registered: Dec 2001
Posts: 11116
btw for some weirdo opcodes in the 65xx line, checkout the HuC6280 (which is a 65c02 derivate used in NECs PCEngine) ... some neat things there. (i like the way bankswitching is done in zeropage vs i/o... kindof smart :))
2004-09-10 09:56
Kabuto
Account closed

Registered: Sep 2004
Posts: 58
To explain what's going on take a look at LDA ABX and STA ABX first.

LDA ABX takes 4 cycles unless a page wrap occured (address+X lies in another page than address) in which case the value read during the 4th cycle (which was read with the original high byte) is discarded and in the 5th cycle a read is made again, this time from the correct address. During the 4th cycle the high address byte is incremented in order to have a correct high byte if the 5th cycle is neccessary. The byte read from memory is buffered and copied to A during the read of the next command's opcode.

But there's a problem with storage commands: they need to put the value to write on the internal bus which is used for address computations as well. To avoid collisions STA ABX contains a fixup which makes it always take 5 cycles (the value is always written in the 5th cycle as the high byte is computed in the 4th cycle).

This fixup requires some transistors on the CPU; the guys at MOS forgot (or were unable?) to make them detect STX ABY (which becomes SHX) and a few others, they are missing that fixup so this results in a collision between the value and high address byte computation.
2005-10-31 09:50
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: http://oxyron.net/graham/opcodes.html


@Graham:

This link seems to be dead... Did you store it anywhere else?
2005-10-31 10:26
Steppe

Registered: Jan 2002
Posts: 1510
Try this:
http://www.oxyron.de/html/opcodes.html
2005-10-31 10:35
MRT
Account closed

Registered: Sep 2005
Posts: 149
@Steppe:
Thanx... Too bad it doesn't state the workings of the illegal opcodes.

For example: What does AHX do? Which flags are altered? And so on...
2005-10-31 10:36
MRT
Account closed

Registered: Sep 2005
Posts: 149
Blueehhh...

Sorry I was too quick... IT DOES STATE IT ALL!!!

Thanx again
2005-10-31 14:52
Monte Carlos

Registered: Jun 2004
Posts: 351
What does &H mean?

Monti Carlotti
2005-10-31 15:27
MRT
Account closed

Registered: Sep 2005
Posts: 149
Ehr... I believe the H stands for the instruction pointer (program counter). This points to the instruction in mem which is beeing executed.
2005-10-31 15:37
MRT
Account closed

Registered: Sep 2005
Posts: 149
To extend this...
The H is short for PCH (according to some other docs on the net), where PC is program counter and the H is the Highbyte of the address...

So, if the PC would be $1234, PCH = $12 and PCL = $34.
2005-11-01 11:24
Monte Carlos

Registered: Jun 2004
Posts: 351
so a

ldx #$05
ldy #$cc
shy $fe00

means

ldx #$05
lda #$cc
and #$ff ;h+1
sta $fe00,x

????

2005-11-01 12:17
MRT
Account closed

Registered: Sep 2005
Posts: 149
ehr... No...

The program counter points to the current opcode in memory which is beeing executed by the processor...

So...

*=$1000
PC:$1000 : lda #$01
PC:$1002 : ldy #$02
PC:$1004 : shy $2000

; then shy is:
; #$02 & #$20 and stores it in $2000
2005-11-01 12:18
MRT
Account closed

Registered: Sep 2005
Posts: 149
NO NO... TYPO!!!

*=$1000
PC:$1000 : lda #$01
PC:$1002 : ldy #$02
PC:$1004 : shy $2000

then shy is:
#$02 & #$10 and stores it in $2000

So #$10 and not #$20
2005-11-01 12:32
Nafcom

Registered: Apr 2002
Posts: 588
Quote: NO NO... TYPO!!!

*=$1000
PC:$1000 : lda #$01
PC:$1002 : ldy #$02
PC:$1004 : shy $2000

then shy is:
#$02 & #$10 and stores it in $2000

So #$10 and not #$20


HINT: CSDb has an edit function for posts if you are the last replyer in a thread! ;)
2005-11-01 12:37
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: HINT: CSDb has an edit function for posts if you are the last replyer in a thread! ;)

Ha cool...
I see...
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
krissz
chesser/Nigaz
AMB/Level 64
Sentinel/Excess/TREX
Guests online: 131
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Vincenzo  (9.8)
2 Rob Hubbard  (9.7)
3 Stinsen  (9.7)
4 Jeroen Tel  (9.6)
5 Linus  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.07 sec.