Search code examples
pythonpythoninterpreter

Hello, I am needing some help to hexdump a .bin file that a python program created


I am following Ben Eaters tutorial on the 6502 computer and I'm completely lost on the python programming stuff. I have a little bit of programming knowledge, but not enough to understand which programs he is swithcing between. Here is the link to the video I'm referring to (around the 9:40 mark): https://www.youtube.com/watch?v=yl8vPW5hydQ&list=PLowKtXNTBypFbtuVMUVXNR0z1mu7dp7eH&index=2

I've created my "makerom.py" program in Visual Studio Code and it appears I was able to run it via the CMD prompt. But when I try to hex dump from there it doesn't work.

Here is my python program:

rom = bytearray([0xea] * 32768)

with open("rom.bin", "wb") as out_file:
    out_file.write(rom);

I've created my "makerom.py" program in Visual Studio Code and it appears I was able to run it via the CMD prompt. But when I try to hex dump from there it doesn't work.


Solution

  • Too many questions to ask to clarify what you are asking. I would use Python for Windows if you're on Windows and then call > python.exe YourScriptName.py from within PowerShell. If you're on Linux just use your bash terminal and call $ python YourScriptName.py.

    Your program above works. To check the file that it creates, navigate to the same directory that you ran the script from, and you should find a rom.bin file. If you don't see that exact file, your program either didn't work or likely didn't run. But if it's there than your script at least created the file. So then, if you want to see what's inside, if you're in Linux you can run $ xxd rom.bin or hexdump. If you're in Windows you can use PowerShell's > Format-Hex .\rom.bin to confirm the data was written to the file.