Ben Eater 6502 Kit — Day 08 – Create a ROM with only NOP operations.
It seems that the broken power supply has also destroyed the CPU itself. That’s very bad and I have to order new one. Getting hold of a WDC60C02 (WDC = Western Design Center) is not that easy. It’s much easier to buy a R65C02 (R = Rockwell) but the R65C02 CPU doesn’t feature a fully static design which you can hardware single step. The R65C02 is also missing the WAI (Wait-for-Interrupt) and STP (Stop) instruction why rely on said fully static design of the WDC60C02.
So I’m going thought the pain of ordering a WDC60C02 from Jameco. The CPU itself is not that expensive. Sadly postage to Europe is twice the cost of the CPU. I ordered a few extras to make it worth while.
So the projects is stalled for a few weeks and I’ll use the time I wait for a new CPU for some software development.
In the next step a ROM with all NOP operations will be needed. Ben Eater does this in Python but I choose to program this on my favourite language Ada. The, again over engineered, result looks like this:
with Ada.Sequential_IO;
with Ada.IO_Exceptions;
with Ada.Command_Line;
with Ada.Text_IO;
with Interfaces;
procedure Create_NOP is
package Byte_IO is new Ada.Sequential_IO (Interfaces.Unsigned_8);
Byte_Output : Byte_IO.File_Type;
NOP : constant Interfaces.Unsigned_8 := 16#EA#;
Rom_Size : constant := 32 * 2**10;
begin
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line ("Syntax: create_nop <output file>");
else
declare
File_Name : constant String := Ada.Command_Line.Argument (1);
begin
Byte_IO.Create (Byte_Output, Byte_IO.Out_File, File_Name);
exception
when Ada.IO_Exceptions.Name_Error =>
Ada.Text_IO.Put_Line ("File “" & File_Name & "” couldn't be created.");
Ada.Text_IO.Put_Line ("See stack trace below for more details.");
raise;
end;
for I range 1 .. Rom_Size loop
Byte_IO.Write (Byte_Output, NOP);
end loop;
Byte_IO.Close (Byte_Output);
end if;
end Create_NOP;
Yes, a little longer the Python but it has an error handler, a simple command line interpreter and outputs some help if needed.
The program uses Sequential_IO
to write the same type of element sequentially — as the name suggest. In this case it’s
not just the same type of element but the very same element called NOP
which contains an unsigned integer with the
value if hex EA
. This is done 32768 times (32×2¹⁰).
EA
of course is the 6502 instruction for NOP (No Operation). Not a very complicated program. Here you see the ROM
being written.
You find the full source code with makefiles, project files and everything on GitLab: 6502Tutorial — Tools/Create_NOP