Jump to content
IGNORED

Best Computer to Learn 6502 Assembly On


bluejay

Recommended Posts

I've been wanting to learn 6502 assembly for a while, and my VIC-20 seems too "weak", and my CoCo 2 doesn't even have a 6502. I'm planning on getting an AIIe, non-enhanced, and it's supposed to not have the assembly monitor built in, right? What's a good computer to learn 6502 assembly on, and what assembler is best on the platform?

Link to comment
Share on other sites

A CPU is a CPU is a CPU. Your secondary question about which software to use though is more relevant. For learning purposes, do you want something like a tutorial package or just a very good assembler that you can grow with? On the C64 side, things like Turbo Assembler has been popular for many years, but I'm sure equal software exists for most of the other systems too.

 

The BBC Micro is one of few systems that allow inline assembly code in BASIC, so you can type it in with line numbers and everything. Not sure if that makes it more suitable though. Even if you intend to use real hardware in the end, you could consider shopping around for emulators to get a feel about each system and available software before spending hundreds and hundreds of dollars on items you really didn't want.

 

Also since your signature is in the shape of a Fuji symbol, I would suppose A8 computers go into your mix of possible targets.

Edited by carlsson
Link to comment
Share on other sites

15 minutes ago, carlsson said:

A CPU is a CPU is a CPU. Your secondary question about which software to use though is more relevant. For learning purposes, do you want something like a tutorial package or just a very good assembler that you can grow with? On the C64 side, things like Turbo Assembler has been popular for many years, but I'm sure equal software exists for most of the other systems too.

 

The BBC Micro is one of few systems that allow inline assembly code in BASIC, so you can type it in with line numbers and everything. Not sure if that makes it more suitable though. Even if you intend to use real hardware in the end, you could consider shopping around for emulators to get a feel about each system and available software before spending hundreds and hundreds of dollars on items you really didn't want.

 

Also since your signature is in the shape of a Fuji symbol, I would suppose A8 computers go into your mix of possible targets.

I agree that the BBC Micro would be a great choice, except the original poster is in California so he'd have to deal with both voltage and television standards issues.  For a brief moment in time a North American version of the BBC was produced but I think it would be extremely hard to find now, there were so few sold back in the day!

 

I guess it would depend on what the original poster would want to do in the long run.  If it is game programming, the Apple is pretty tough to deal with--the graphics are weird (non-congruent graphical memory), the sound is primitive and dealing with joysticks is a pain.  The VIC-20 with memory expansion is a better environment overall (dead-simple graphics, joystick controls, sound), but typing for a long time with that screen font is a pain (I love 80 columns).  So that leaves what?  Maybe the C128 would be the best bet.  Or an Atari (or C64) with a 80-column adapter.

  • Like 2
Link to comment
Share on other sites

Actually most Beebs have the nice feature that it only requires a change of a jumper on the PSU (solder job, so probably you want to pretend to be a qualified electrician to do it) to switch it from accepting 220V to 110V. Few people are aware of that and involve the use of step-up transformers when it strictly is not required. But yes, PAL RF and/or digital RGBI outputs can put most people off.

Link to comment
Share on other sites

While I would not recommend this to anyone given much better options available, I actually learned to program 6502 on a Commodore 64 using the built-in ML monitor of the WarpSpeed fast loader cartridge.  I had dabbled a little by way of COMPUTE! Magazine articles and listings for both the Apple and Commodores, but actually creating small programs came much later.  I submitted one program I wrote with the WarpSpeed to COMPUTE!'s Gazette.

 

I will say it was a nice way to instantly enter code and be able to execute it, and the reset button on the cartridge allowed me to recover from a locked-up system and go right back in.  Of course it did not re-arrange code so if I had to insert or remove any parts I had to re-enter what followed, or sometimes I would pad with NOPs.  Even later when I switched to using a text editor and T.S.D.S. (Total Software Development System?) I still used the WarpSpeed to test segments of programs.

 

It reminded me of using the Line-By-Line Assembler on the TI-99/4A, but without labels and such.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

What machines are you familiar with?

 

I'm asking that because "learning 6502 assembly" is a two part affair.  One part is the CPU and how it works.  Frankly, almost any 6502 machine will help you get that done reasonably.  Very limited platforms, like the 2600 as an example, are hard largely because getting useful info into and out of the machine can be more difficult and obscure than you probably want to deal with.  

 

Ideally, you want one running a BASIC, that has a text display, or serial connection you can use.  Having those things helps a lot.  You can learn all you need to know about the CPU that way.  Topics include:

 

Math (or the lack of it, lol)  6502 CPUs only do 8 bit math.  Add, subtract, shift, rotate.  There is decimal mode too.  It's not much.  But, it's fast.  In my opinion, this can be one of the harder things.  Understanding how to do big numbers, or fixed point numbers, floating point numbers is important.  If I had to pick, just being able to do the basics on big (16, 24, 32 bit) integers will get you a long way.  Multiply, divide, add, subtract, rotate, shift, signed, unsigned.

 

Bit logic.  AND, OR, XOR, and friends.  These are very useful.  Masks, comparing bits, setting bits, resetting bits.  

 

Program flow.  Jump, branch on condition.  

 

Addressing.  Indirect, absolute, (ZP), Y, etc...  

 

That Zero Page, and how it can act like a lot of 16 bit registers.  6502 chips are really 8 bit machines.  Addresses are 16 bits, and understanding how those work is important.  Knowing what to use when and why.

 

Computer math.  This one is kind of CPU independent.  For example, it all applies to that spiffy 6809 in your Color Computer too, or that Z-80 in some other machine you may bump into one day.    On this topic, I suggest learning the first 16 powers of 2.  2, 4, 8, 16, 32, 64...  People will say stuff like "page boundary" and that is actually the upper 8 bits of a given address.  Each 8 bits worth of RAM is a page.  Zero page is a page.  The Stack occupies a page.  Some instructions present challenges, or take longer when part of getting the instruction done means crossing a page boundary.  Take some time to learn Hexadecimal.  So much will be clear once you can start thinking in hex.  

 

Little Endian vs Big Endian.  Your 6809 is a big endian machine.  The 6502 is a little endian machine.  What does this mean?  It's all about the order 16 bit values appear in memory.

 

Quickie example:

 

LDA $A025  (This copies whatever number is stored at address $A025 into the A register in your 6502)

 

The hex bytes on 6502 are:  AD 25 A0

 

See how the address is "backwards", little portion first, then the bigger portion?  That's little endian.  

 

On a 6809 that same instruction, for example, has hex bytes:  B6 A0 25

 

See how the address is different, bigger portion, then smaller portion?  That's big endian.  

 

It's just important to know what that term is early on.  Makes looking at listing files and data in memory easier.  Once you learn to see it, 6502 little endian is easy.  If you've never heard of this, it is possible to be very confused for a while.  I was.  So, maybe I can do a little good here.  LOL 

 

Status bits.  When a zero happens, an overflow?  Bits get set.  Decisions can be made based on those bits.  

 

I/O -- On the 6502, that is done with the memory mapped model.  Read a byte somewhere and the bits in it can tell you what position a game controller is in, or what key was last pressed on the keyboard.  Write a byte, depending on where you write it, and stuff can happen, like some character appearing on the text screen, just like if you were to use POKE in BASIC.  More on that in just a bit, hold the thought!

 

Anyway, that is the CPU.  

 

It is really fun to work directly on the machine.  But, few machines offer a great environment to do that.  If it were me today?  I would get an Apple //e Platinum, or C128.  The Platinums are the newest Apple 8 bitters, are not particularly collectable, and are not expensive, and have all the basics in the box.  80 character screen, monitor, line assembler.  I do not have an C128 right now, but want one, but also haven't gone looking.  I think these are pretty affordable too.  Same deal.  80 character screen, monitor, line assembler.  Great for starting out learning about the CPU, writing little programs, looking at memory, writing instructions.

 

Both have onboard memory monitor and some basic line assembler capability.  This is a lot like having BASIC on board.  You can type instructions in and then ask the CPU to run them, and view results.  For little, tiny programs, like making a sound by clicking the speaker a lot of times, or writing to the text screen, the on system capabilities are nice.  Bonus!  You don't really need a disk drive.  It's nice if you have one, but honestly, a simple cassette can do the work, if you want to even bother.  The main benefit here is the immersive experience, immediate feedback, and some sense of the speed of things.  

 

On the Atari, if you can find one, the MAC/65 assembler with DDT cartridge is really good.  I wrote some fairly large programs using that tool.  Recommended as an "on machine" experience for the Atari machines, but it's best with a disk drive or emulator.

 

I'm rambling...  Bottom line, get a machine that has an easy peasy text display or serial connection.  (And the serial is mainly referring to a more modern 6502 dev board of some kind really.)  The Apple can do serial, but I wouldn't.  just use the screen, keyboard, mouse, optional disk or cassette.

 

All that said, emulators are pretty awesome!  But, I totally understand wanting to jam right on the old hardware.  It's fun.  I still do it.  Have fun.  If you get stuck, get a good emulator and you can run the very best tools, use PC assemblers, and all sorts of crazy stuff, if you need to.  No worries.  Don't let anyone give you any worries.  That's fun too.

 

Notice how I've not said much about machines?  The CPU and that text screen are kind of the core.  You can learn a ton right there, and I encourage you to do that.  Learn the instructions.  Do things like count from 0000000 to 999999 on the text screen.  (takes about 2-3 minutes on most 6502 machines, BTW)  If you've got a speaker to whomp on, click it a lot and make noises.  Make a stupid snake game.  All that stuff is great learning the CPU, and it's all pretty easy to do right on the machine, even with the basic + monitor and line assembler.

 

Oh, before I forget!

 

BASIC  You probably know what this is.  It's the interface to the machine.  10 print "Hello World" type stuff.  Cool.  Your BASIC is written in 6502 assembly able to take a more simple program you write and execute it.  This is really slow because you've got a 6502 assembly program that accepts your BASIC program, figures out what you asked it to do, then it does it, then repeats over and over.  Lots of instructions to do even simple things.  

 

Monitor  This is a machine language program with a much smaller scope!  It is your view into the RAM of the computer,  ROM too.  Monitors are small, and are often the first thing one gets going on a new computer early in it's development.  You can view memory, modify memory, copy, and do other things.  It is right here that actual machine language can be input.  Machine language is the actual bytes in a binary program.  

 

Take a look at this video:  

 

 

Assembler  These come in a lot of flavors.  On most machines that contain one, it's a line, or "mini" assembler.  You type a line, such as "LDA ($15), Y" and it translates it into the one, two or three bytes that an instruction can be represented by, and puts them in the memory for you.  When doing machine language in your monitor, you do this yourself!  Look stuff up on the datasheet, figure out the bytes, and enter them in.  Having a line assembler makes learning pretty easy.  You are freed from all the tedious detail of hand assembling, but it's still really low level.  Big programs are not easily done this way.  But little ones are.  Another kind of assembler is one that can take a full text file, assemble all of it and make a binary program from it.  If you are using emulation, you can use a cross assembler to make 6502 code on your Intel PC, for example.

 

I won't comment on the "best" assembler for a platform.  There are assemblers people are using.  I suggest getting setup to use one of those.  If you are following some tutorials, or books, get the assembler used.  Today, you can get basically all of them.  Or, you can use the one built in, if there is one, for little programs.  (Enhance that //e you are getting.  It's a good machine to learn on, and you could do much worse.)

 

Now, the machine!

 

Here's the second part!  Assembly language is intimately linked to the machine you are writing it for, or on.  Atari computers have a memory map, and lots of custom bits of hardware.  All this stuff has locations, and ways it works.  The custom bits of hardware are different on a C64 too.  

 

One nice thing about the Apple 2 series of computers is the near complete lack of custom hardware.  This makes some things easy.  And in the case of the Apple 2 computers, also made the add on cards kind of easy too.  The result was a lot of them.  In my view, each machine has it's killer thing.  The Apple 2 was a great workstation.  Lots of 6502 code for other machines got made on it because it had fast disks, 80 column display, and add on cards could do a lot, or connect to machines in ways that were harder on other computers.  The Atari computers are strong with graphics and a variety of game controllers, and some good I/O.  The C64 was similar, not so fast disks, but did have a user I/O port, etc...  I would not bother with "best machine" and just pick one you are familiar with, or that you are motivated by somehow.  

 

The familiarity helps, because you know a lot about the machine.  It may not be at the level of detail you want for assembly language, but it is a lot of hard learning out of the way, already done!  That helps, mostly because you may know how the machine works, can skip some basics about it.

 

Motivation is a different thing.  Have you ever wanted to see a particular machine do something?  That's good.  Learning assembly on it is a great way to get at that thing you might want to do.  Helps keep you moving.

 

Last thing, and it's important:

 

Assembly language programs --really understanding them, requires understanding the CPU, AND it requires understanding the hardware that CPU is connected to.  You gotta have some detail understanding of both.

 

Simpler machines do not do as many spiffy things in hardware, but understanding assembly language on them can be a lot easier too.  More is done in software.  

 

I really like the Apples for this reason.  They are nearly all software machines.  On the other extreme, in 8 bit land, the Atari, NES, C64, and friends do a ton in hardware, and you've got to get to know that hardware well to understand assembly language programs on those machines.  I happen to like the C128 too, and that's because it's on board tools are pretty good actually.  And you can always work on the simple stuff, ignoring a lot of that hardware.

 

And, part of "the hardware" is the ROM in your machine.  Often, assembly language programs call routines in this ROM.  You need to know about that so you can call them, or understand what another program does.

 

For any machine you pick, get the hardware books that describe the machine in detail, and the "learning 6502 on" books.  All that info is still as valid today as it was back then.  Plus, you've got all the crazy good online info and people to talk to.  It's easier now than it was back in 1983 when I started!  My lifeline was the magazines in the grocery store!  Good times that.  And you've got those too, if you want to go looking at the Internet Archive for type ins!

 

I lied.  One last, last thing!

 

Right now, getting a real machine isn't too terribly expensive.  So pick one.  Get a basic setup going and get into it.  Type some stuff in and watch it go.  Don't break the bank.  Get a working machine, maybe a disk emulator of some sort, and maybe a cassette for that authentic experience once or twice...  (then no more, because cassette is a slow PITA), and go!  

 

If you find you want a different machine, you can get that one too, or trade, or whatever.  Once you learn 6502 assembly, each of the classic machines has it's charm.  It's fun to program on or for any of them.  I am sure many of us had our machine, back in the day.  For me, that was Apples at school, Atari 8 bit at home to start.  Learning 6502 got me going on both of them.  Started on the Apple, because it actually had some tools on board.  In the box, so people, me, just used 'em.  Once I understood enough to want more, I mowed lawns to get my MAC/65 cart for the Atari.  Wrote a lot of programs for that Atari, and years pass.  Now, I'm having fun with an Apple and a CoCo 3.  (Just like the 6809)  Over the years, I've given many different machines a go. trying this and that.  It's been fun, and today, that's what this is all about.  

 

Having fun matters.  Just make sure you do that.  And if your machine isn't fun, go and get another one.  

 

Some people have asked, "why bother?"  And the answer is generally these older machines are simple.  One person can get their head wrapped around one and do some stuff.  Modern hardware is so much more complex and powerful.  It's not so much fun, IMHO.  Well, it can be, but it takes real work well beyond what one can get with some work on an older 8 bit machine.  The computer math skills, and general understanding of assembly language is useful in a more modern context too.  There is a progression.  At first, one learns AN assembly language, or particular CPU, if you want to think about it that way.  Then, learning a second one changes things!  It's sort of like learning Microsoft Word, then Word Perfect, and suddenly the idea of word processing itself is a thing that isn't just using Microsoft Word all the time.  It's that thing, that grokking what CPU's do which is fun for me.  It's been a life long hobby.  I like computing at this level.  It's where the bits are.  And these classic computers just don't have all that much in the way of you getting to those bits too.  Beyond that?  Who knows.  That's your call.  Just figured I would share what it all means to me.  

 

Best setups are those that allow you to use a modern storage, such as SD card, or a serial connection, or something to get bigger programs, save your programs, or load tools onto your machine with low hassle.  This also sets you up to use all the stuff online with ease.  Most machines have some reasonably inexpensive option for doing this.  Some have very expensive ones with all kinds of crazy features too.  You don't need one of those, unless you get serious about all this.  

 

Hopefully, the topics I've put in here will lead you to do some searching.  Lots of good YouTube videos out there on this stuff.  Search on machine name, plus topic, and or "assembly programming" and you can see it done, on a machine you plan to get, or have.  This is also a big help early on.  Just seeing the process beats out what we all had back in the day, unless we had a guru to watch.  Many of us didn't, or became that guru...

 

 

 

Edited by potatohead
  • Like 3
Link to comment
Share on other sites

On 11/28/2019 at 8:58 PM, bluejay said:

I've been wanting to learn 6502 assembly for a while, and my VIC-20 seems too "weak", and my CoCo 2 doesn't even have a 6502. I'm planning on getting an AIIe, non-enhanced, and it's supposed to not have the assembly monitor built in, right? What's a good computer to learn 6502 assembly on, and what assembler is best on the platform?

Maybe check this out?   6502 assembly in your browser with tutorials.   It might be easier to learn the basics this way

http://skilldrick.github.io/easy6502/

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...