Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Rom Hacking: hukka | 2 guests
Acmlm's Board - I2 Archive - Rom Hacking - Allright. Im ready to learn ASM. | |
Pages: 1 2Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Violent J

Melon Bug
Level: 41

Posts: 270/749
EXP: 479154
For next: 991

Since: 05-05-04
From: The Lotus Pod

Since last post: 8 hours
Last activity: 8 hours
Posted on 03-22-05 12:53 AM Link | Quote
Wow. I couldent believe this today. I asked my math teacher, who worked with coleco back in the day (hes like 55 now) and worked on games like Head to Head Boxing, Football, and Soccer, and a bunch other for the Colecovision. So I asked him if he learned Assembler code, and he told me yes, but he had also learned a level of programming below it, and he said Hex. So I ended up showing HH's code he posted to him in class by him letting me use the pc, and right away he told me some long drawn out explanation of what it ment. Im starting to wonder if he could teach me some of the components of ASM and Hex.
DarkPhoenix

Octorok
Level: 9

Posts: 4/31
EXP: 2669
For next: 493

Since: 03-08-05

Since last post: 23 days
Last activity: 16 hours
Posted on 04-26-05 08:26 AM Link | Quote
Personally, I'd say it'd probably be easiest to get a book on something like x86 assembly first, and/or possibly take a class in assembly programming. As was mentioned before, it's pretty easy to pick up on a new assembly language once you're familiar with the concepts behind assembly programming, so my suggestion is to learn an assembly language that's well documented first, and then move onto 6502, followed by 65816, if that's your goal. x86 (which is used by the pentium processors) is particularly well documented as it's still used, at the very least for inline assembly with higher level languages. Additionally, it's pretty easy to find a good assembler for x86 (NASM, MASM, or the GNU assembler) As far as whether to pick up a book or get into a class or something, that depends on how you learn. If you know you're not gonna be able to beat yourself into reading through a programming book on your own, then take a class somewhere, to give you some structure while you get a good foundation...but you're gonna need to beat yourself into reading through a lot of technical material eventually. Once you've finally learned an assembly language, then move onto learning the instruction set for whichever console you like, and get to know the intricacies of that particular system.


Aside from that, I think R2H2's code could use some line by line explaination, if for nothing else but curiosity:
LDA $0DBF ;This means LoaD the value at $0DBF into the Accumulator
; As he mentioned, this is where the number of coins you
; currently have is stored. In short, he's going to check how many
; coins you have
BEQ x ;Branch if EQual to the line labeled x - basically, he's going to go
; somewhere else in the program if the value now in the
; accumulator is zero.
JSR $00F5B7 ;if that value wasn't zero, the program didn't jump, so if that's the
; case, he's going to Jump to the SubRoutine at $00F5B7
; the subroutine at this location, as he mentioned, kills Mario
x: RTS ;this line is labelled x, where that BEQ line jumps to. The
; on this line simply tells the SNES to ReTurn from the Subroutine
; basically, go back to what it was doing before it ran this
; whole segment of code to check the coins. Note that this line
; may or may not be executed if there were coins, depending upon
; where the subroutine at 00F5B7 sends you. If it returns you here
; it will be executed, but it might send you somewhere else, like
; a gameover screen. You'd have to look at that subroutine's code
; to find out

My sincerest apologies for taking so much space to say so little. And for the sake of education, please, correct me if I'm wrong.
Parasyte

Bullet Bill
Level: 35

Posts: 469/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-26-05 01:27 PM Link | Quote
I suppose the only "correction" could be made to the following:
... go somewhere else in the program if the value now in the accumulator is zero.


This isn't entirely true, since it implies that the BEQ instruction works by checking the value in the accumulator. What's actually happening, of course, is the BEQ is checking the status of the Z-flag in the Processor Status Register. As any good 6502 manual will tell you, the [preceding] LDA instruction will set the Z-flag if the value loaded is zero.
Keep in mind that conditional branches check certain flags in the Processor Status Register, and most other instructions will set certain flags in the Processor Status Register, depending usually on the "result" of the operation. As mentioned earlier, the 6502 reference explains which instructions set which flags, and how/why. ;D

Just trying to avoid confusion...
DarkPhoenix

Octorok
Level: 9

Posts: 5/31
EXP: 2669
For next: 493

Since: 03-08-05

Since last post: 23 days
Last activity: 16 hours
Posted on 04-26-05 07:24 PM Link | Quote
As far as learning assembly, the aforementioned NES ASM tutorial seems good, but if it's a bit more than you can chew, you might want to start at one of these:

PC Assembly Language by Paul Carter, downloadable at
http://www.drpaulcarter.com/pcasm/index.php

Art of Assembly Language Programming by Randall Hyde,
http://webster.cs.ucr.edu/

Assembler, Inside and Out by Harley Hahn. Microsoft Press, c.1992.
ISBN 0-07-881842-7

They're more x86 oriented, but they're a bit more geared toward people who haven't programmed before. I particularly recommend the last one, since it's what I learned assembly from (but it might be a touch hard to find now), but the DOS version of the Art of Assembly one is pretty good, too. They both start out simple, with number systems, like Hex, and deal primarily with 16 bit registers and 24-bit addressing (if I'm remembering correctly) like the SNES. Art of Assembly's particularly nice, because you can buy the book, or look at it in HTML or download the PDF or a Zip file. The first one's more 32-bit processor oriented, and only in PDF format, but good if you need another source, if something gets confusing. Also, if anyone needs a guide in french or portuguese, the first site is the way to go.

As far as more NES relevant sources, The NESDEV tutorial listed at Zophar.net I think is the best for beginners, and the 6502 reference Parasyte mentioned is far and away the best reference for the instruction set. For the SNES, the near equivalent references (though harder to navigate) are 65816info.txt and the 65816 docs, both here. Most of the assembly stuff for the SNES requires a background in 6502, or at least some background in assembly. So again, I recommend the x86 stuff first, since it's more geared toward those with no prior experience in assembly, and since it's easier to find stuff that's more complete, as well as revised and edited a few times over.


(edited by DarkPhoenix on 04-26-05 02:29 AM)
(edited by DarkPhoenix on 04-26-05 02:43 AM)
Dish

Spiny
Level: 38

Posts: 363/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 04-26-05 11:08 PM Link | Quote
I don't know how/why x86 got introduced here, but I have to say it's a strange idea -- and I'm not sure it will really benefit S&T much for what he's trying to do. I mean the whole reason he's learning a different assembly language before 65816 (which is what he ultimatly wants to learn) is to soften the blow with an easier language. x86 would just intensify that blow -- not to mention it doesn't share the similarities 6502 has with 65816. I mean if he's going to sit down and learn x86, he might as well sit down and learn 65816 and save himself some time and trouble. 6502, on the other hand would be taking a smaller step in the same direction (65816 is just a 'beefed up' 6502, so after learning 6502 he'll only need to look at a few extra things and he'll have 65816 down).

I mean it's not like 6502 tutorials or learning resources are in short supply or anything.
Rockman

Flurry
Level: 26

Posts: 197/250
EXP: 96387
For next: 5888

Since: 03-17-04

Since last post: 18 days
Last activity: 16 days
Posted on 04-26-05 11:34 PM Link | Quote
I agree with Disch. Start out with 6502, and stick with it for a little while. Practice some hacks, and learn what you can learn. And if this happens to be your first language, stick with it for a good while. When you are comfortable with it, move on to 65816. Then, by this time around, you should have a good understanding, and you can read up on another language and probably grasp it easily. One of the things that are very helpful in learning assembly languages in hacking games, is a debugger. I can't get over how useful they really are. It is possible to hack without one, but it would probably be too difficult for a new person. If you are interesting in ASM hacking for the NES, use FCEUXD. You can't go wrong. But, if you feel comfortable with 6502, and want to move on to Super NES hacking, check out Geiger's SNES debugger. If you have taken a computer science class before, and have an understanding of how programming works, you shouldn't have too much trouble getting into ASM hacking. I for one though, had a very difficult time. I gave up a lot. So, I documented what I learned to make it a little easier to start out.

http://www.zophar.net/tech/files/6502.txt <-- This is very helpful. I have this bookmarked.

Also, you can check out my tutorials. These tutorials actually walk you through ASM hacks. (Thanks to Chill Penguin for hosting them)
http://www.geocities.com/bjb138/rockmanXasm/asm1.html
http://www.geocities.com/bjb138/rockmanXasm/asm2.html

Use your resources, and ask questions when you are stuck. There are also other ASM hacking-related threads on this board. Check them out!
Dish

Spiny
Level: 38

Posts: 364/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 04-27-05 01:18 AM Link | Quote
Originally posted by Revenge

http://www.zophar.net/tech/files/6502.txt <-- This is very helpful. I have this bookmarked.



This doc does cover things nicely, however it does have the occasional error/misprint, so for the technical stuff (opcode lists, cycle counts, stuff like that), use the link Para provided instead.

Some problems with 6502.txt and other things I feel like bringing up:

6502.txt documents Relative addressing mode all wrong. It implies that a branch of $FE is a branch of -126 when it's really a branch of -2. Relative addressing mode arguments branch in the usual "two's compliment" fashion: $FF = -1, $FE = -2, $FD = -3 ... $80 = -128, $7F = +127, $7E = +126, etc. Not the method covered in 6502.txt.

6502.txt refers to the high status bit as 'S' (Sign flag), whereas pretty much every other doc on the planet refers to it as 'N' (Negative flag).

There isn't really a 'B' status flag -- or an 'unused' status flag. When processor status gets pushed to the stack (via IRQ/NMI/PHP/BRK) -- the bit representing the 'unused' status flag is always set, and the 'B' bit is set on BRK/PHP (and cleared on IRQ/NMI) -- however the status of these bits aren't tracked as the CPU runs (so the only "real" status flags are C, Z, I, D, V, N)

The V flag is not explained very well at all usually. On ADC: V is set when Positive + Positive = Negative, or when Negative + Negative = Positive. Under all other circumstances V is cleared. On SBC: V is set when Positive - Negative = Negative, or when Negative - Positive = Positive. Under all other circumstances V is cleared. Other instructions that change V don't rely on any such logic (BIT/CLV/PLP/RTI -- all pretty straightforward)
DarkPhoenix

Octorok
Level: 9

Posts: 7/31
EXP: 2669
For next: 493

Since: 03-08-05

Since last post: 23 days
Last activity: 16 hours
Posted on 04-27-05 02:01 AM Link | Quote
I don't think getting a good conceptual foundation is anywhere as strange an idea as asking a person to learn something completely irrelevant to his ultimate goals (C++), or for that matter, as cruel as telling them to jump headfirst into material that college CS students often have trouble with, with only amatuer tutorials and reference manuals, regardless of which is theoretically faster (jumping headlong into 6502) or which would provide for the most theoretical background (C++). Ideally one would go straight to 6502, but I've yet to see a 6502 document that's anywhere near as thorough, or for that matter comprehensible as a book on x86. Sure, it's another language, and it's not exactly like the 6502, but the concepts are the same, and there's some good professionally written material on it that's more appropriate for those with no prior programming experience. I think learning x86 strikes a rather happy medium between learning C++ first, and going in with no prior experience at all, and I think the time spent learning x86 would only be replacing time wasted with confusion from incoherent, deficient, or otherwise incomprehensible material. So in short, I think a person starting with x86 would be less prone to giving up.
Pages: 1 2Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Rom Hacking - Allright. Im ready to learn ASM. | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.053 seconds.