Closed bergfried closed 3 weeks ago
Wow! I almost forgot the existence of this; haven't done C64 stuff for ages, but I'll try to incorporate the information that you listed into the cheat sheet :)
Thank you for the very quick reply! Looking at the current cheat sheet version, I just noticed a few more things, so I have some ideas but I am not sure whether they will help or are good at all:
BRK
to the upper-right corner of the section it is in], you might be able to put the "Branches" section to the right of the then-smaller "Jumps and Calls" section. Also, in order to save space in "Branches", turn "Branch on" into a two-liner.NOP
($EA
) instruction. (You might still want to keep the NOP
for the key.) However, this might occupy some more space so not sure.BIT
instruction from "Flag Manipulation" to "Logical and Arithmetic" between CPY
and DEC
. [EDIT: I just noticed that it should not be controversial but mandatory! Why? Because the opcodes aggree! The BIT
opcodes ($24
, $2C
) resemble two CPY
opcodes (namely $C4
, $CC
) better than any of the unconditional flag operations.] This would make the "Flag Manipulation" section just as small as the "Branches" section but it would also make "Logical and Arithmetic" a bit bigger.EDIT:
Again, just ideas I have never really tested, but maybe they inspire you.
Few more things:
Adding a "Touch" column to NOP
s (as suggested earlier) might be unnecessary because the locations they will touch can be derived from the addressing mode column header, as they will touch the target locations accordingly, as if using a load instruction and then discarding the result.
(By the way, all opcodes, including the official ones, tend to touch more memory then just the current instruction's location and target locations. So, one might just as well point this out in general. Or maybe not because it was never pointed out before and the cheat sheet works well so far.)
Given all that, I just sketched out how a new NOP
section might look like:
Illegal `NOP` instructions
1 byte 2 bytes 3 bytes
(implied) #00 $00 $00,X $0000 $0000,X
-----------------------------------------------
1A 14 1C
3A 80 34 3C
5A 82 54 5C
7A 89 04 74 7C
DA C2 44 D4 DC
FA E2 64 F4 0C FC
2 2 3 4 4 4*
* add one cycle if page boundary crossed
NOP behaves like LDA but discards the result.
Opcodes 0C and 1C sometimes also known as TOP.
Opcodes 80, 04 and 14 sometimes also known as DOP.
Pros:
Cons:
Now for the JAM
opcodes:
Illegal JAM instruction opcodes
02 12 22 32 42 52
62 72 92 B2 D2 F2
JAM freezes the CPU.
Note: According to page 104 of 118, JAM
is not known by any other mnemonic to any of the assemblers listed. Therefore, it should be okay to leave out alternatives like HLT
or KIL
.
Ideally, the cheat sheet will cover all 256 opcodes.
EDIT: I changed the sketch a bit. Also, I think I have found a suitable "Function" for NOP
s: $
because it is like $ ⇒ A
for LDA
but discards the result (like SBC
versus CMP
). No flags. However, it might not make much sense for the "(implied)" addressing mode which the official NOP
also belongs to, other than for symmetry reasons.
Regarding the NOPs: does any assembler actually recognize the instruction mnemonics?
I started making the changes in another branch, have a look at the draft here
- The normal
SBC
($E9
) has an unintended twin ($EB
). Given the current layout, it should probably appear in a new line betweenAXS
andAXA
.
This is now in the normal table, with a mark that its actually unintended
- If the then-smaller "Jumps and Calls" section has still enough space, you might want to add an explicit line for the normal
NOP
($EA
) instruction. (You might still want to keep theNOP
for the key.) However, this might occupy some more space so not sure.
Did not as I don't find it quite appropriate to call a NOP a jump or a call. I just kept it where it is, but now it is near the other illegal NOPs so people looking for a NOP should find it.
- Maybe you can move the key to the upper-right corner of the page. Maybe the flags in the P-register can be explained in a single (albeit long) line somewhere at the bottom of the page.
I'm sure I'd be able to squeeze the P-register description, but since it seems to fit like it was, didn't change it.
- A bit controversial, but maybe you can move the
BIT
instruction from "Flag Manipulation" to "Logical and Arithmetic" betweenCPY
andDEC
. [EDIT: I just noticed that it should not be controversial but mandatory! Why? Because the opcodes aggree! TheBIT
opcodes ($24
,$2C
) resemble twoCPY
opcodes (namely$C4
,$CC
) better than any of the unconditional flag operations.] This would make the "Flag Manipulation" section just as small as the "Branches" section but it would also make "Logical and Arithmetic" a bit bigger.
I agree with this in principle, but now it messes the space so I'd rather not if possible :)
- Then, maybe you can move "Flag Manipulation" to the lower-left corner where "Branches" then used to be. The area where the key currently is can probably be used to store the "Illegal NOP Instructions" section, and just above it, maybe where "Flag Manipulation" currently is, you can put the "Illegal JAM instruction opcodes" section. If you are lucky, this leaves a tiny area at the top of the current "Flag Manipulation" section where you can still put the key.
"Illegal JAMs" and "Illegal NOPs" tables are there.
- In order to distinguish the sections for illegal opcodes mentioned above, the current "Illegal Instruction" section should be renamed to something like "Illegal Logic and Arithmetic Instructions".
Done.
Regarding the NOPs: does any assembler actually recognize the instruction mnemonics?
I just tested it, and ACME, for example, translates all NOP
s and DOP
s and TOP
s just fine:
nop ; EA (the official NOP)
nop #$ee ; 80 EE
nop $ee ; 04 EE
nop $ee,x ; 14 EE
nop $eeee ; 0C EE EE
nop $eeee,x ; 1C EE EE
dop #$ee ; 80 EE
dop $ee ; 04 EE
dop $ee,x ; 14 EE
top $eeee ; 0C EE EE
top $eeee,x ; 1C EE EE
Of course, ACME prefers using certain opcodes when creating its output. This is no different from other instructions like SBC #imm
which has as an unintended twin (as mentioned earlier), or ANC #imm
where ACME prefers $0B
over $2B
while the cheat sheet lists both (as it should). And just like the cheat sheet lists all ANC
opcodes, it should also list all unintended NOP
opcodes, I think.
(Just now, I am imagining someone creating self-modyfing code that produces various different NOP
s as a by-product of some computations. Of course, for something like that, you want to know all the different opcodes for NOP
s!)
Of course, ACME prefers using certain opcodes when creating its output. This is no different from other instructions like
SBC #imm
which has as an unintended twin (as mentioned earlier), orANC #imm
where ACME prefers$0B
over$2B
while the cheat sheet lists both (as it should). And just like the cheat sheet lists allANC
opcodes, it should also list all unintendedNOP
opcodes, I think.
I went through the cheat sheet and painfully checked with Inkscape's find functionality that every hex opcode 00 - FF is now mentioned somewhere, so I think all opcodes (including all NOPs/TOPs/DOPs/JAMs) are there. Please report back any errors you find from the draft
I have to admit that I do not like the idea of mixing intended opcodes with unintended ones. The fact that the unintended one works just the same as the official one is really just pure luck. On the other hand, it's a cheat sheet, not a super official document, and I do understand the idea behind that, so I guess it's just fine. :)
Please report back any errors you find from the draft
I'm trying, but first, I need to try and install the font you use. But even without having installed the font yet, I think I`m going to like the new layout.
6510_assembly_instructions.pdf
This PDF version should have fonts embedded.
I have to admit that I do not like the idea of mixing intended opcodes with unintended ones. The fact that the unintended one works just the same as the official one is really just pure luck. On the other hand, it's a cheat sheet, not a super official document, and I do understand the idea behind that, so I guess it's just fine. :)
How about just putting a dagger and something like "† illegal opcode EB works identical to E9", so no EB in the table?
6510_assembly_instructions.pdf
Here's a version with the latest minor tweaks; this time the EB is removed from the table and just mentioned in the dagger.
Thank you for the drafts. I would like to comment on them later, but I am too busy right now.
I am sorry for the late reply.
I went through the cheat sheet and painfully checked with Inkscape's find functionality that every hex opcode 00 - FF is now mentioned somewhere, so I think all opcodes (including all NOPs/TOPs/DOPs/JAMs) are there.
Thank you very much. I also just checked by throwing some shell magic at it:
$ diff <(printf '%.2X\n' {0..255}) <(sed -r -n -e 's#.*>([0-9A-F]{2})</tspan.*#\1#p' 6510_assembly_instructions.svg | sort)
12d11
< 0B
44d42
< 2B
236d233
< EB
So only 0B
, 2B
and EB
could not be found automatically, and these are exactly the opcodes that are present but formatted in a different way (which is why they could not be found automatically). So all good. :)
I have to admit that I do not like the idea of mixing intended opcodes with unintended ones. The fact that the unintended one works just the same as the official one is really just pure luck. On the other hand, it's a cheat sheet, not a super official document, and I do understand the idea behind that, so I guess it's just fine. :)
Well, on second thought, I still prefer not mixing intended opcodes and illegal ones very much, and the additional reason that now came to mind is that, for consistency reasons, you would also need to mention that $1A
, $3A
, $5A
, $7A
, $DA
and $FA
all work the same as $EA
aka NOP
. Also, I have tried it out (see the attached draft), and I think the illegal SBC
fits just perfectly, space-wise, opcode-wise and all.
Anyway, as mentioned above, I took the liberty and time to create a draft (PDF, SVG in ZIP) based on your most recent draft.
It comes with the following changes:
DOP
and TOP
are mixed up. Change "Also known as DOP:" to "also known as TOP" and "Also known as TOP:" to "also known as DOP".ANC
.CLC
.SBC
($EB
) from the official opcodes to the illegals between AXS
and AXA
. Add mnemonic SBC2
to it (mainly to indicate once more to the reader that this is the illegal SBC
).NOP
($EA
) to the "Jumps and Calls" section.Regarding NOP
: The first time I tried to use the cheat sheet, I failed to locate NOP
on it because I did not expect it to be mentioned only in the key! I remember the key used to explain the details of a periodic table on the wall at school. The element that was used for the key certainly appeared in the full table again. I have seen this pattern everywhere else, so I do not see why the cheat sheet should deviate from it.
Regarding the font change, please have a look at #2 where I explain it in detail.
I just noticed that there is a superfluous whitespace character right after the comma in AND $, N ⇒ C
, the function description of ANC
, and it should be removed, I think.
Just so you know that all these have been mostly addressed in my latest version, but the font change (#2) made everything misaligned, so I'll return to this issue when the font change is sorted out.
I will close this issue also, as all opcodes & illegal NOPs/DOPs/TOPs, JAMs and SBC2 are now documented in the cheat sheet. Also I believe the alignment issues mentioned here or in the other issue have been resolved (or, at least attempted to be resolved), but if there's still remaining issues (e.g. alignments), let's open further specific issues to discuss those, so it's easier to find them later.
Sorry for the late reply. The new version 0.2.0 looks very good. Thank you very much!
First of all, thank you very much for this very handy cheat sheet!
You might want to have a look at https://csdb.dk/release/?id=226987 (or any newer version) which seems to be very detailed when it comes to unintended opcodes. Given the information presented in that document, I would like to see the following information added to the cheat sheet:
SBC
($E9
) has an unintended twin ($EB
). Given the current layout, it should probably appear in a new line betweenAXS
andAXA
.NOP
instructions (often calledDOP
orTOP
depending on the number of bytes they take, see page 52 of 118). While such aNOP
does not have a function per se, it has the side effect of touching certain memory locations. Thus, a column header like "Touch" (similar to "Branch on") might be appropriate for the cheat sheet. You can read about all the different memory locations being touched by instructions (includingNOP
s) in the section "Unintended memory accesses". In general, unintendedNOP
s have several use cases, which is why I think they should be included:JAM
(KIL
,HLT
) instructions which could be listed for completeness (see page 56 of 118). Also,JAM
s do come in handy when using emulators to stop execution altogether so one can easily inspect memory.It would be great if you could incorporate the changes proposed above in some way or the other as I really like the compact way you present the instructions.