News: 11 March 2016 - Forum Rules

Author Topic: Asm 6502 help  (Read 422 times)

Gilberto9

  • Jr. Member
  • **
  • Posts: 24
  • Hack is good
    • View Profile
    • My Channel YouTube
Asm 6502 help
« on: July 02, 2021, 03:25:02 pm »
I need to learn 6502 assembly, which way is easier ?? what better tutorial ? and material ?? remembering that I don't understand anything yet :-\
Game good

FAST6191

  • Hero Member
  • *****
  • Posts: 3279
    • View Profile
Re: Asm 6502 help
« Reply #1 on: July 02, 2021, 04:27:01 pm »
Not sure why we are in scripts and language rather than one of various other sections but OK.

Do you know any programming already, and what language if you do? If you say know C then pointers, ideas of loops, memory handling and more will be nothing too unusual where something high level like python might mean you get loops but other things get harder. If you have to learn programming and this is your first brush with it then you will have to learn how programs tend to go together. If you are familiar with cheats ( https://web.archive.org/web/20080309104350/http://etk.scener.org/?op=tutorial ) that can also help with general ideas of data types, memory arrangements and more.

The 6502, especially the NES one, is a fairly simple setup. Personally I find it has some quirks compared to more common modern processors and certainly has limitations in things you can do that you might expect if you are more familiar with newer stuff or can go from basic maths.

I figure there are three ways, maybe four.

1) You start small and work from there. Some of us might be able to talk about memory windows, instruction cycle counts, limitations and bugs in the CPU itself but that can be left off for later. If you can start by changing instructions (something that subtracts might be changed to a NOP, and in doing so you might give yourself infinite lives in a game -- if dying never loses a life... also why you want to know how to make cheats), maybe making a new function to jump to, basic tracing ( http://fceux.com/web/help/CodeDataLogger.html https://www.romhacking.net/documents/361/ ) then you can do useful things and work up to the hard stuff.
A bunch of NES games already have fairly complete disassemblies (Final Fantasy, Mario, Zelda to name but three) you can look at and think up ways to change.
Getting the code you want to change into the ROM can be tricky but I am going to leave that to you to figure out (generally you want to overwrite existing ROM data rather than assemble the whole thing when ROM hacking, your basic disassembly an emulator or something static will give you is not going to assemble as is without some extra work).

2) It is entirely possible to do a more formal approach where you study it as a whole thing. Done properly you will have fewer gaps in your knowledge and possibly a more formal approach to fall back on, however it will certainly take a while longer to get to the interesting stuff or do useful things. Nobody has really used the 6502 in decades at this point but it was once very popular so there are likely some books around (indeed I have a paper one I found once within arm's reach). I don't know how good paper ones will be at this point as they might teach programming in an older style without some of the modern concepts (test drive, safe programming and other such things). Most will also not cover the NES hardware ( http://wiki.nesdev.com/w/index.php/NES_reference_guide ) and instead look more at the business machines or general concept. Will almost certainly not teach you any kind of game design ( https://docs.google.com/document/d/1iNSQIyNpVGHeak6isbP6AHdHD50gs8MNXF1GCf08efg/pub?embedded=true https://www.gamasutra.com/view/feature/3374/the_internet_sucks_or_what_i_.php?print=1 https://gdcvault.com/ https://www.youtube.com/watch?v=GXdfU2DoF8o https://www.youtube.com/watch?v=hZDxLi6Xc40 ) either where many around here will tell you such things are sometimes even more valuable than programming knowledge, and I will certainly say being able to think like a developer (and developers are not flawless people as any number of bug fix hacks in the databases here will allude to) has allowed me to figure out problems others might not. The nesdev wiki link from earlier ( http://wiki.nesdev.com/w/index.php/NES_reference_guide ) will have some good stuff though and might serve to get you started at least.

3) You learn assembly for something modern and popular and move sideways. PC (aka X86/X64) has some of the best stuff, though some like ARM ( http://www.coranac.com/tonc/text/asm.htm https://blog.quirk.es/2008/12/things-you-never-wanted-to-know-about.html which is also used on many things including the GBA, DS, 3ds, Switch, android, apple devices including the phones and tablets and aspects of older home consoles too) might also do and will also avoid getting quite as bogged down.
https://www.plantation-productions.com/Webster/
https://stuff.pypt.lt/ggt80x86a/asm1.htm is a bit simpler but gets to worked examples quite easily.
https://www.youtube.com/watch?v=hE7l6Adoiiw&list=PL6B940F08B9773B9F&index=1 is good stuff, not necessarily all about assembly (though there is some and it is quite gentle) but wonderful introduction to computing.
Can be harder to go to the NES as again it is lacking things you might consider basic, and some of the ways people think could be a bit strange -- I always find the way people think of registers on the NES as odd when I come from a modern X86 base for my assembly knowledge/thoughts but working around what you might consider restrictions is fine.


4) You write your own emulator. Does not have to compete with anything at all but if you can manage to write your own emulator which will handle a basic game then you will end up knowing the hardware, knowing the instructions and more, all at a level that will allow you to move trivially into ROM hacking. You could substitute this for writing a game from scratch or maybe porting/remaking another but that might still miss some things.



In all things having a project that holds your interest will be a good thing -- I don't care at all for football games and if that was all I had to learn with I would have struggled, give me a nice action game or RPG or something that I like and that gets far easier. Nothing to say you can't blend aspects of all the numbered things above as well (1 and 2 being most likely).