Last active
July 31, 2017 22:59
-
-
Save hollobon/89f9c84ef32c29ce232ec662e15b056a to your computer and use it in GitHub Desktop.
8-Bit CPU Opcode matrices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
mnemonics = """ | |
ADC AND ASL BCC BCS BEQ BIT BMI BNE BPL BRK BVC BVS CLC | |
CLD CLI CLV CMP CPX CPY DEC DEX DEY EOR INC INX INY JMP | |
JSR LDA LDX LDY LSR NOP ORA PHA PHP PLA PLP ROL ROR RTI | |
RTS SBC SEC SED SEI STA STX STY TAX TAY TSX TXA TXS TYA | |
""".split() | |
for m in mnemonics: | |
print "mnemonic({}, {}, {}).".format(*map(str.lower, m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% -*- mode: prolog -*- | |
%% Prolog to generate all 3x3 squares containing 6 valid 6502 mnemonics, without | |
%% repetition. Inspired by the front cover of "The Advanced User Guide for the BBC Micro" [1], I | |
%% wanted to see if any other combinations existed. Only a minor variation (with CPX/LDX instead | |
%% of CPY/LDY) and tranpositions do. | |
%% | |
%% [1] https://duckduckgo.com/?q=advanced+user+guide+for+bbc+micro&t=hu&iax=1&ia=images | |
mnemonic(a, d, c). | |
mnemonic(a, n, d). | |
mnemonic(a, s, l). | |
mnemonic(b, c, c). | |
mnemonic(b, c, s). | |
mnemonic(b, e, q). | |
mnemonic(b, i, t). | |
mnemonic(b, m, i). | |
mnemonic(b, n, e). | |
mnemonic(b, p, l). | |
mnemonic(b, r, k). | |
mnemonic(b, v, c). | |
mnemonic(b, v, s). | |
mnemonic(c, l, c). | |
mnemonic(c, l, d). | |
mnemonic(c, l, i). | |
mnemonic(c, l, v). | |
mnemonic(c, m, p). | |
mnemonic(c, p, x). | |
mnemonic(c, p, y). | |
mnemonic(d, e, c). | |
mnemonic(d, e, x). | |
mnemonic(d, e, y). | |
mnemonic(e, o, r). | |
mnemonic(i, n, c). | |
mnemonic(i, n, x). | |
mnemonic(i, n, y). | |
mnemonic(j, m, p). | |
mnemonic(j, s, r). | |
mnemonic(l, d, a). | |
mnemonic(l, d, x). | |
mnemonic(l, d, y). | |
mnemonic(l, s, r). | |
mnemonic(n, o, p). | |
mnemonic(o, r, a). | |
mnemonic(p, h, a). | |
mnemonic(p, h, p). | |
mnemonic(p, l, a). | |
mnemonic(p, l, p). | |
mnemonic(r, o, l). | |
mnemonic(r, o, r). | |
mnemonic(r, t, i). | |
mnemonic(r, t, s). | |
mnemonic(s, b, c). | |
mnemonic(s, e, c). | |
mnemonic(s, e, d). | |
mnemonic(s, e, i). | |
mnemonic(s, t, a). | |
mnemonic(s, t, x). | |
mnemonic(s, t, y). | |
mnemonic(t, a, x). | |
mnemonic(t, a, y). | |
mnemonic(t, s, x). | |
mnemonic(t, x, a). | |
mnemonic(t, x, s). | |
mnemonic(t, y, a). | |
square([A,B,C], [D,E,F], [G,H,I]) :- | |
mnemonic(A, B, C), | |
mnemonic(D, E, F), | |
mnemonic(G, H, I), | |
mnemonic(A, D, G), | |
mnemonic(B, E, H), | |
mnemonic(C, F, I), | |
[A,B,C] \= [D,E,F], | |
[A,B,C] \= [G,H,I], | |
[D,E,F] \= [G,H,I], | |
[A,D,G] \= [B,E,H], | |
[A,D,G] \= [C,F,I], | |
[B,E,H] \= [C,F,I], | |
[B,C] \= [D,G], | |
[A,B] \= [F,I], | |
[A,D] \= [H,I], | |
[G,H] \= [C,F], | |
[A,B,C] \= [B,E,H], | |
[G,H,I] \= [B,E,H], | |
[A,D,B] \= [D,E,F], | |
[C,F,I] \= [D,E,F], | |
[D,E,F] \= [B,E,H]. | |
%% ?- square(A,B,C). | |
%% A = [b, c, c], | |
%% B = [p, l, p], | |
%% C = [l, d, x] ; | |
%% | |
%% A = [b, c, c], | |
%% B = [p, l, p], | |
%% C = [l, d, y] ; | |
%% | |
%% A = [b, p, l], | |
%% B = [c, l, d], | |
%% C = [c, p, x] ; | |
%% | |
%% A = [b, p, l], | |
%% B = [c, l, d], | |
%% C = [c, p, y] ; | |
%% | |
%% false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% -*- mode: prolog -*- | |
%% Prolog to generate all 3x3 squares containing 6 valid Z80 mnemonics, without | |
%% repetition. Inspired by the front cover of "The Advanced User Guide for the BBC Micro", I | |
%% wanted to see if something similar could be made with 3-character Z80 opcodes. Sadly, | |
%% it cannot. | |
mnemonic(c, p). | |
mnemonic(d, i). | |
mnemonic(e, i). | |
mnemonic(e, x). | |
mnemonic(i, m). | |
mnemonic(i, n). | |
mnemonic(j, p). | |
mnemonic(j, r). | |
mnemonic(l, d). | |
mnemonic(o, r). | |
mnemonic(r, l). | |
mnemonic(r, r). | |
mnemonic(a, d, c). | |
mnemonic(a, d, d). | |
mnemonic(a, n, d). | |
mnemonic(b, i, t). | |
mnemonic(c, c, f). | |
mnemonic(c, p, d). | |
mnemonic(c, p, i). | |
mnemonic(c, p, l). | |
mnemonic(d, a, a). | |
mnemonic(d, e, c). | |
mnemonic(e, x, x). | |
mnemonic(i, n, c). | |
mnemonic(i, n, d). | |
mnemonic(i, n, i). | |
mnemonic(l, d, d). | |
mnemonic(l, d, i). | |
mnemonic(n, e, g). | |
mnemonic(n, o, p). | |
mnemonic(o, u, t). | |
mnemonic(p, o, p). | |
mnemonic(r, e, s). | |
mnemonic(r, e, t). | |
mnemonic(r, l, a). | |
mnemonic(r, l, c). | |
mnemonic(r, l, d). | |
mnemonic(r, r, a). | |
mnemonic(r, r, c). | |
mnemonic(r, r, d). | |
mnemonic(r, s, t). | |
mnemonic(s, b, c). | |
mnemonic(s, c, f). | |
mnemonic(s, e, t). | |
mnemonic(s, l, a). | |
mnemonic(s, l, l). | |
mnemonic(s, r, a). | |
mnemonic(s, r, l). | |
mnemonic(s, u, b). | |
mnemonic(x, o, r). | |
mnemonic(c, a, l, l). | |
mnemonic(c, p, d, r). | |
mnemonic(c, p, i, r). | |
mnemonic(d, j, n, z). | |
mnemonic(h, a, l, t). | |
mnemonic(i, n, d, r). | |
mnemonic(i, n, i, r). | |
mnemonic(l, d, d, r). | |
mnemonic(l, d, i, r). | |
mnemonic(o, t, d, r). | |
mnemonic(o, t, i, r). | |
mnemonic(o, u, t, d). | |
mnemonic(o, u, t, i). | |
mnemonic(p, u, s, h). | |
mnemonic(r, e, t, i). | |
mnemonic(r, e, t, n). | |
mnemonic(r, l, c, a). | |
mnemonic(r, r, c, a). | |
square([A,B,C], [D,E,F], [G,H,I]) :- | |
mnemonic(A, B, C), | |
mnemonic(D, E, F), | |
mnemonic(G, H, I), | |
mnemonic(A, D, G), | |
mnemonic(B, E, H), | |
mnemonic(C, F, I), | |
[A,B,C] \= [D,E,F], | |
[A,B,C] \= [G,H,I], | |
[D,E,F] \= [G,H,I], | |
[A,D,G] \= [B,E,H], | |
[A,D,G] \= [C,F,I], | |
[B,E,H] \= [C,F,I], | |
[B,C] \= [D,G], | |
[A,B] \= [F,I], | |
[A,D] \= [H,I], | |
[G,H] \= [C,F], | |
[A,B,C] \= [B,E,H], | |
[G,H,I] \= [B,E,H], | |
[A,D,B] \= [D,E,F], | |
[C,F,I] \= [D,E,F], | |
[D,E,F] \= [B,E,H]. | |
%% ?- square(A,B,C). | |
%% false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
mnemonics = """ ADC ADD AND BIT CALL CCF CP CPD CPDR CPI CPIR CPL DAA DEC DI DJNZ EI EX EXX HALT IM IN INC IND INDR INI INIR JP JR LD LDD LDDR LDI LDIR NEG NOP OR OTDR OTIR OUT OUTD OUTI POP PUSH RES RET RETI RETN RL RLA RLC \ | |
RLCA RLD RR RRA RRC RRCA RRD RST SBC SCF SET SLA SLL SRA SRL SUB XOR """.split() | |
for m in sorted(mnemonics, key=len): | |
print "mnemonic({}).".format(", ".join(map(str.lower, m))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment