6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:06 pm

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Assembly programming
PostPosted: Mon Jul 02, 2018 5:23 pm 
Offline

Joined: Mon May 21, 2018 8:39 am
Posts: 41
I want to make practise all the things I read and learn about assembly programming for the 6502.

So my question is what's the best way to do that since I do NOT own a real machine (i.e. Apple II)?

Which emulator is best to pick up? How to make it work? What programs do I need to download? How to write assembly using the emulator? Will it be like writing assembly on a real machine?

Thanks in advance!

P.S. I use Windows 10 and Ubuntu

P.S I would appreciate for answers from people who've tried any working solutions and not just theory


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 5:36 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Might be worth starting with easy6502 which works within your browser and is both emulator and tutorial. You need to be aware that every assembler has different syntax, so be prepared to be flexible - that's better, in my opinion, than sticking doggedly to the first one you try. Kowalski's simulator is also highly thought of but you'll need some book or website to learn from, as it isn't a tutorial, it's a tool. Latest version can be found in this thread.

You may want to read Garth's primer, and probably a book too. I think I had Rodnay Zaks when I started, but Lance Leventhal is also a good choice.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 6:23 pm 
Offline

Joined: Mon May 21, 2018 8:39 am
Posts: 41
I'm reading (on a physical form) the "Programming the 6502" by Prof. Rodnay Zaks and (on a digital form) the "How to program the Apple II - Using 6502 assembly language" by Prof. Randal (Randy) Hyde.

In other words, I am mainly interested in learning assembly language for the Apple II home computer.

I have already tried the "easy6502" site but I have to admit that I didn't quite like.

I am oriented in using an emulator for the Apple II and an assembler.....


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 6:33 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
That's a perfectly viable idea. The question is simply what kind of problems do you want to solve with your assembly programming?

If you're trying to learn more about the Apple II through assembly programming, then, for sure, using an Apple simulator is the way to go.

If you're simply interested in the 6502 for its own sake, then the field is much wider open.

There are numerous generic 6502 simulators out there, simulators that's aren't tied to any specific machine. This site has all sorts of links to simulators and assemblers for all sorts of platforms. Many folks here just like to hack on the 6502, and make one off custom computers utilizing it compared to working on an Apple or Atari or Commodore. Those machines all have dedicated forums to help you there.

The advantage of running on simulators is that you can leverage your current machine and operating system, you can leverage tools you know, and, more important, you can leverage the performance of you machine. Native programming on vintage machines will try anyones patience today, even more so than in the past.

So if you decide to do assembly work for an Apple, I'd look in to tools such as cross assemblers and disk utilities that let you utilize more of your native machines tools than Apple native tools.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 6:42 pm 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 282
Location: Placerville, CA
The biggest advantage of using a simulator for learning is that you can actually step through the code one instruction at a time and verify that what you assumed it would do is actually what it's doing. I'd second the recommendation of Kowalski's simulator, simply because having an integrated assembler/simulator environment saves you the trouble of using two different programs and having to re-load your program into the simulator every time you change it. Then once you've got a comfortable grasp on the basics you can move over to an Apple II or emulator thereof.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 8:44 pm 
Offline

Joined: Mon May 21, 2018 8:39 am
Posts: 41
Guys, thanks a lot for your answers

As I mentioned before on the "Introduce yourself" section of this forum, the reason I started learning assembly language is because I want to keep my brain in shape. (that is the first and foremost reason)

Of course, someone would say that there are numerous other ways to do that (and easier to follow), but studying the assembly language is the only way I truly enjoy!

Assembly always looked like something exotic to me. Furthermore, I was always very keen on computers.

So, with that in mind, I think that I will try the Kowalski emulator to practise my "continually" growing knowledge on the 6502 assembly. What do you say? Wise choice?

P.S. Okay okay, Although I don't have any big hopes for creating a game on my own or even gaining an intermediate knowledge of the assembly language, I have to admit that the early life of Jordan Mechner is extremely appealing to me....... :) (that is the hidden reason why learning Apple II ASM)

I feel kind of embarrassed now..... :D :D


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Mon Jul 02, 2018 9:06 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
BTW, for you and also for future adventurers, its worth exploring the other parts of http://6502.org/ which are outside the forum. For example
http://6502.org/tutorials/ - Tutorials and Primers
http://6502.org/tools/ - Development Tools, Emulators and test suites
http://6502.org/books - Books for the 6502 Fanatic

It's normal these days to cross-assemble, typically running your editor and assembler on a PC or laptop. But for a more authentic experience you might seek out a native assembler for your platform of choice: Merlin and ORCA/M are popular (were popular) on the Apple II. (You might need to search a bit to find a copy.)

On the BBC Micro there's an assembler built into Basic. It's great! But not such an obvious choice outside the UK.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 4:55 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Learning for learning sake is all well and good, but I find that learning a language works much nicer if you have some problem to solve. Something that puts you above the assembly code. The goal being to solve the problem, and thereby learn assembly in the process.

Even know how to do math, or navigate an array, or whatever is much more useful when applied to a "real world" scenario. Otherwise, it's like a vocabulary to a foreign language that you never use -- and it fades with time.

When I wrote my simulator and assembler, my goal was to assemble and run a Fig-Forth.

So, I find it's always easier to write something to learn something. Then you have a bunch of "real world" issues to solve one by one. And you can use it to get a feel for the tools, the language, the environment. Then you can come back and work on your technique, or start another program and start fresh.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 4:57 am 
Offline

Joined: Mon May 21, 2018 8:39 am
Posts: 41
Thank you BigEd for your reply

Question: In your opinion, from all the variations and derivatives that exist for the 6502 processor, which one is considered to be the most bug-free but at the same time, the most compatible (with the instruction set of the original NMOS 6502).

With a fast research I made, I came up to the conclusion that the CMOS 6502 processor (65c02) is the ideal compromise between compatibility and lack of bugs


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 5:08 am 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 282
Location: Placerville, CA
I don't think there are too many actually incompatible variants out there (unless your code is relying on bugs or quirks in the original like the invalid-opcode instructions,) but yes, the 65C02 is pretty much the standard for post-NMOS systems.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 5:10 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Kris1978 wrote:
Thank you BigEd for your reply

Question: In your opinion, from all the variations and derivatives that exist for the 6502 processor, which one is considered to be the most bug-free but at the same time, the most compatible (with the instruction set of the original NMOS 6502).

The 65c02, ie, CMOS 6502, fixed all the bugs of the original NMOS 6502, and added more instructions and addressing modes. Actually, there are quite a few other benefits as well. As for assemblers, there are so many of them out there that I don't think any one person can be very experienced in a significant percentage of them; so each user can only compare the ones they've used. I have not used any of the free ones (except the Forth one I myself wrote), but I've used both 2500AD and Cross-32 which are excellent macro assemblers, apparently much better than many of the ones people here have posted code for. If you need it to be free, one I expect is really good is A65 from Andrew Jacobs here on the forum, and if you have any problem, he's active here so you'll get the best support. Myself, I would not consider one that does not have the CMOS 65c02 instructions. You mentioned being interested in the Apple II. The IIc and IIe used the CMOS one.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 5:16 am 
Offline

Joined: Mon May 21, 2018 8:39 am
Posts: 41
Thank you Garth :)

Well, the truth is that I am a noob is assembly, nevertheless I truly enjoy reading ASM. The fact that I am a noob sometimes makes me feel confused and desperate about what to do and where to start. That's why I asked for help in here. The only thing I know for sure is that, from what I've read, the 6502 CPU is the ultimate platform for a beginner to start learning assembly language. It's fun. And I agree with that. And the only reason why I said that I'm interested in the original Apple II was because it was the machine that Jordan Mechner (one of my idols in gaming industry) wrote Karateka and Prince of Persia. Generally I'm more interested in the game-development field rather than making an O/S or a business application or a demo or something else. Furthermore, I am not interested learning any other 8-bit architecture or any other programming language. In the past, I made some 2-room adventure games (as a learning process) with the help of the A.G.S. engine (by Chris Jones) but I realized after a lot of effort (drawing backgrounds, music, sound f/x, speech, scripting, animation, dialogues, story, design, puzzles etc.) that I don't have the aptitudes (skills) for making an adventure game that many people will love to play. Making an adventure game on your own, is a very complicated process, at least in my case.

Hope I helped :)

Cheers


Last edited by Kris1978 on Tue Jul 03, 2018 5:37 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 5:31 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
GARTHWILSON wrote:
... The IIc and IIe used the CMOS one.

The Enhanced IIe came equipped with a 'c02 and updated ROMs that made use of the new instructions. The older IIe unit came with a plain old 6502, but could be user-upgraded to varying degrees.

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 6:54 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
If you're learning a computer language, any language, start off with silly little problems first. Say, print all numbers from 1 to 10 (this teaches you loops). Now print all numbers from 1 to 100 that contain the digit 7 (this teaches you branches). Write a game where the computer tries to guess the number (though pretty hard in 8-bit assembler from scratch because of I/O).

If you're really new to the language, expect to feel frustrated and confused at first (for me, Forth and Haskell were serious "Wait, what?!" languages), and be prepared to google a lot of simple things. But make yourself try first and accept that you will fail a lot, because that has been shown to strengthen the learning process more than just looking stuff up (see "Making it Stick" by Peter Brown, a book I can't recommend highly enough, https://www.amazon.com/Make-Stick-Scien ... 0674729013). Be willing to ask questions that you feel are probably stupid (for examples, search me on the Forth forum *cough*).

Once you have the basics down, as Whartung said, try a mid-size project. I usually write a 65c02 disassembler because it's actually quite simple to do but requires working with strings, different base numbers, arrays, etc.

Then, finally, try something big. I didn't come close to understanding Forth until I wrote the crude emulator for the 65816 and had lots of little "oh, that's what they mean!" moments. A big project forces you to learn how to structure the code at a whole different level.


Top
 Profile  
Reply with quote  
 Post subject: Re: Assembly programming
PostPosted: Tue Jul 03, 2018 11:44 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
+1 for 65C02.

Code for the 65C02 will also run unmodified on a 65816 in emulation mode (or with the accumulator and indexes in 8-bit mode), as long as you stay away from the (rarely used) instructions that were replaced, and also avoid using the "undocumented NOPs" that were also replaced with new instructions. Coincidentally, the replaced instructions were also omitted from the 65SC02. So for maximum compatibility, set your assembler to 65SC02 mode, if it has one.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: