code_6502: GraphViz block diagram (.dot) source

This spec can be used to disassemble raw stream of 6502 CPU machine code into individual operations. Each operation includes an opcode and, optionally, an argument. Register arguments are part of the opcode enum.

KS implementation details

License: CC0-1.0

References

This page hosts a formal specification of code_6502 using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

code_6502.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__code_6502 {
		label="Code6502";
		graph[style=dotted];

		code_6502__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="operations_pos">0</TD><TD PORT="operations_size">...</TD><TD>Operation</TD><TD PORT="operations_type">operations</TD></TR>
			<TR><TD COLSPAN="4" PORT="operations__repeat">repeat to end of stream</TD></TR>
		</TABLE>>];
		subgraph cluster__operation {
			label="Code6502::Operation";
			graph[style=dotted];

			operation__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="code_pos">0</TD><TD PORT="code_size">1</TD><TD>u1→Opcode</TD><TD PORT="code_type">code</TD></TR>
				<TR><TD PORT="args_pos">1</TD><TD PORT="args_size">...</TD><TD>switch (code)</TD><TD PORT="args_type">args</TD></TR>
			</TABLE>>];
operation__seq_args_switch [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
	<TR><TD BGCOLOR="#F0F2E4">case</TD><TD BGCOLOR="#F0F2E4">type</TD></TR>
</TABLE>>];
		}
	}
	code_6502__seq:operations_type -> operation__seq [style=bold];
	operation__seq:args_type -> operation__seq_args_switch [style=bold];
	operation__seq:code_type -> operation__seq:args_type [color="#404040"];
}