Beginner's Guide to Disassembling 6502 Binaries

  Рет қаралды 5,063

Commodore History

Commodore History

Күн бұрын

Пікірлер: 53
@MrToast64
@MrToast64 Жыл бұрын
What a fantastic way of explaining this, Dave. Absolutely loved how you paced and connected everythign together in a very digestible format.
@commodorehistory
@commodorehistory Жыл бұрын
Awe man, this was a great comment to read. Thank you so much for watching and for taking the time to share positive feedback!
@stupossibleify
@stupossibleify Жыл бұрын
Timely video from my perspective! Back into 6502 after decades and loving it. Great video editing skills, btw, very polished episode.
@commodorehistory
@commodorehistory Жыл бұрын
Thank you for regularly watching my stuff and always leaving kind comments. I really appreciate it!
@JohnMDiLiberto
@JohnMDiLiberto Жыл бұрын
Now, that is impressive. Well done!
@commodorehistory
@commodorehistory Жыл бұрын
Thanks! I hope you enjoyed watching.
@neleabels
@neleabels Жыл бұрын
22:52 Why should you need to recalculate the BNE address? It's only absolute in the assembly code, in machine code it's a relative jump which remains valid in relocated code (unless there is new code inserted between the branch and the target.) But anyway, thanks for this very interesting video!
@commodorehistory
@commodorehistory Жыл бұрын
Totally right - I even mentioned that they’re relative earlier in the video. Good catch!
@commodorehistory
@commodorehistory Жыл бұрын
…except I guess since it was disassembled to an absolute address, when you reassemble the assembler would calculate the relative branch based on an incorrect absolute address.
@neleabels
@neleabels Жыл бұрын
@@commodorehistory That’s true.
@8bittimes
@8bittimes Жыл бұрын
IIRC you can load label files into VICE so that the disassembler shows the actual labels
@commodorehistory
@commodorehistory Жыл бұрын
good to know. Thanks Andre!
@seansretroverse9082
@seansretroverse9082 8 ай бұрын
Awesome video, I really enjoyed it! I have had the mental thought process of disassembling before, and I am glad to see I was not terribly far off. I really am enjoying your channel, so you have my sub now!
@commodorehistory
@commodorehistory 8 ай бұрын
Thanks for watching, and thanks for the sub! Let me know if there’s anything else you’d like to see.
@carolinemathieson
@carolinemathieson Жыл бұрын
I did something like this many years ago after graduating but before I started work to disassemble the Sinclair QL ROM. I used QLMON to do the dissasembly along with a lot of books to know what the system calls were. It was an interesting exercise but gave up eventually as I started a new job. I am curious what all those NOPs were at the beginning though, Scratch space, self modifying code or what?
@commodorehistory
@commodorehistory Жыл бұрын
Sounds like a fun project you were working on! I’m guessing the reason for the NOPs at the beginning was he wrote the machine language before the basic loader and didn’t know exactly how many bytes the basic loader would consume, so he started his assembly at $040F and padded from $0401-$040E with NOP. Then he added the BASIC loader at $0401 and left the intervening NOPs.
@uhertlein
@uhertlein Жыл бұрын
Fantastic explanation of the whole process. One thing I was wondering about were the 9 NOP instructions at the beginning of the program. Do you know why they're there? I was wondering whether that might be space for some self-modifying code?
@commodorehistory
@commodorehistory Жыл бұрын
Thanks for the kind words!! My best guess as to why the leading NOPs are there was just padding to allow the BASIC loader to be plugged in after the assembly code was done.
@andrewdunbar828
@andrewdunbar828 3 ай бұрын
Hi there. I'm not a PET guy or a 6502 guy but I am an 8-bit guy and a disassembler guy and a retrocomputing guy (-: Are there any ways to tell if a .PRG file is for PET, VIC-20, or C64, or probably also C16 & Plus4? Do .PRG files always contain BASIC like this one or do they sometimes contain just machine code?
@commodorehistory
@commodorehistory 2 ай бұрын
Commodore's prg file format really is as simple as "two bytes for the load address, then the binary data that gets loaded to that address". There's no metadata that would explicitly tell you which computer a prg file is for, but there are some clues. If the prg file contains BASIC tokens, you'd be able to tell which computer it's for by the load address, since the start of BASIC is known for the PET, VIC-20 and C64. The prg could certainly contain only machine language and no BASIC tokens. The tokenized BASIC you see in the Space Invaders code was there as a convenience to users so they wouldn't have to type a SYS command to launch the program.
@trs80model14
@trs80model14 Жыл бұрын
I’ve disassembled 6502 for Gottleib System 80a pinball machines. I’ve disassembled (and written) tons of Z80 code but 6502, not much.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
At #08:50 - Instead of LDX #$00 you could just write LDX #0. Same with the zero byte for the text string. A simple 0 would do.
@commodorehistory
@commodorehistory Жыл бұрын
You just typed 127 characters to tell me that I should have typed 1 fewer character.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
@@commodorehistory - that, and to clarify to the viewers that there is no need to complicate things by indicating that "the next number is hexadecimal 0 so we write $00" when decimal 0 is the same and that a simple 0 would do.
@piggypiggypig1746
@piggypiggypig1746 Жыл бұрын
Great video. Sub'd of course. Whenever I see 6502-related stuff on YT I have to immediately jmp straight to it like a nerd. Started my journey into assembly a few years ago but still have much to learn. Look forward to catching up with the rest of your videos. By the way, I wonder why they used so many NOP's at the beginning of their code?
@commodorehistory
@commodorehistory Жыл бұрын
Hey there piggy! Thanks for the kind feedback. I am guessing they just padded the beginning with NOPs because they didn't know exactly how big the basic loader would be, then they never went back and took them out, but that's a guess.
@CostumeJewelryHome
@CostumeJewelryHome Жыл бұрын
Does anyone know if KERNAL source code for the original Commodore PET is available? Original , not disassembly.
@commodorehistory
@commodorehistory Жыл бұрын
I've not run across it thus far.
@NotaWizard
@NotaWizard Жыл бұрын
Very cool Dave. Nice work! And thanks for showing the process.
@commodorehistory
@commodorehistory Жыл бұрын
Thanks NotaWizard! I appreciate you watching and taking the time to comment!
@NotaWizard
@NotaWizard Жыл бұрын
@@commodorehistory all good. btw I think that one of my comments was marked as spam as it had a github link in it. I wanted to edit it to change the word opcode to mnemonic in one place but it wouldn't let me. :)
@Nichetronix
@Nichetronix Жыл бұрын
Love that you use vi :-)
@commodorehistory
@commodorehistory Жыл бұрын
vi is a hard habit to break :) Great that it does search and replace via regular expressions for this video though.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
At #31:00 - I think it is a mistake at this point to add a new instruction to initialize the Y register. The safe method is to keep the code identical to the original, and compare the newly assembled binary code with original and make sure they are identical.
@commodorehistory
@commodorehistory Жыл бұрын
That is certainly *not* the safe method. For the code to be relocatable, you cannot assume the low byte of the address will be zero. If you don’t explicitly set the Y register to 0 you’re risking the code not working. The only reason not to set it would be if your goal was not relocation but to be able to assemble an exact copy of the original binary. That’s explicitly not my goal.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
@@commodorehistory - it is the safe method AT THIS POINT. At this point your goal is to prove that you assemble the symbolic code into a binary that exactly matches the original. Only then is it safe to make changes to the code to ensure that it is safe to relocate. By the way, instead of messing with the setup code, I would look at the documentation for the assembler and see if there was a directive to force a data segment to start at a page boundary.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
Guess what? I just had a look at the tass64 manual. The .alignind directive will do the trick.
@commodorehistory
@commodorehistory Жыл бұрын
Ah, got it. I thought you meant not to fix it at all. Fair point then.
@theenglishman1312
@theenglishman1312 Жыл бұрын
I’ve been trying for years to find assembly to load and save areas of memory from disk , do you know any examples of this in assembler?
@commodorehistory
@commodorehistory 11 ай бұрын
Depending what you're looking for, any of the Commodore machine language monitors should be able to do what you have in mind. They all can save areas of memory to disk. Give it a try! If you have questions, ask.
@daveduke8783
@daveduke8783 10 ай бұрын
@@commodorehistoryin a running assembler program not interactively, yes quite easy in a monitor just s name dev mem
@balorprice
@balorprice Жыл бұрын
Wow! New subscriber here, this is really usesful, thank you
@commodorehistory
@commodorehistory Жыл бұрын
Hey, thanks for subscribing! Hope you enjoy my content.
@skeleton_craftGaming
@skeleton_craftGaming Жыл бұрын
I also would not be surprised if microdigital and the other companies still making 6502s [and yes you can buy a new 6502 today (well maybe not literally today today , but you know what I mean)] I have an instruction set appendix in them as well. I think Intel has their instruction reference on their website for free.
@Mr_ToR
@Mr_ToR Жыл бұрын
dude, i'm more impressed with your vi skills. my adhd brain wont allow me learn stuff like this unfortunately. i just cant help to quickly edit with whatever is most convenient. insert, delete and quit-save thats all i can do with vi.
@commodorehistory
@commodorehistory Жыл бұрын
You’ve got most of what you need to do with an editor covered then. I’ve been using vi my entire career, so a lot of it is muscle memory now.
@JanBruunAndersen
@JanBruunAndersen Жыл бұрын
At #23:41 - I am a bit surprised that you were able to do a search and replace of $0428 without having to escape the $-sign.
@mrsid6581
@mrsid6581 Жыл бұрын
And that‘s why people wrote disassembler tools, kids, because ain‘t nobody has time to do this manually… 😜
@twofour8127
@twofour8127 Жыл бұрын
This guy sounds exactly like the American scientist from The Fast Show 😂
@commodorehistory
@commodorehistory Жыл бұрын
No way. That guy has been copying my act for years!
@galen4778
@galen4778 Жыл бұрын
'promosm' 😔
@wiwingmargahayu6831
@wiwingmargahayu6831 Жыл бұрын
zamzam water
How Does Epyx Fastload Make Loading Faster on a Commodore 64?
29:16
Commodore History
Рет қаралды 37 М.
Basics - 6502 Assembly Crash Course 01
12:49
NesHacker
Рет қаралды 124 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
Hilarious FAKE TONGUE Prank by WEDNESDAY😏🖤
0:39
La La Life Shorts
Рет қаралды 44 МЛН
Advanced 6502 Assembly Programming for the Apple II
33:44
Stephen Edwards
Рет қаралды 29 М.
Best POKE Ever? For Commodore 64
22:21
8-Bit Show And Tell
Рет қаралды 49 М.
HUEY - a 6502 assembly scientific calculator
25:55
The 6502 Show
Рет қаралды 9 М.
Why Was the Commodore 1541 disk drive so slow?
33:15
Commodore History
Рет қаралды 18 М.
Commodore 64 Assembly Language Programming With Turbo Macro Pro
22:51
8-Bit Show And Tell
Рет қаралды 55 М.
Running MSBASIC on my breadboard 6502 computer
36:53
Ben Eater
Рет қаралды 233 М.
"Hello World" on Commodore 64 in Assembly Language, Machine Code
33:39
8-Bit Show And Tell
Рет қаралды 54 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН