I believe 6502 instruction set is a good first assembly language
111–120 of 297 posts
Re: I believe 6502 instruction set is a good first assembly language
#1126502 was my first assembly language (back in the 80s). It was fine. However, when I later had to do some Z80 assembly programming I considered that instruction set a lot nicer. It had more registers. It had a swappable register set. It even had a few 16 bit instructions. Really nice. I guess most people just give up once they see the ugliness of what they got from Intel.
The 6502, on the other hand, is a derivate of the 6800, a genuine microprocessor design that takes fast random access into account. And thus, taking fast memory for granted, it became viable to outsource some of the internals. From this perspective, the 6502 provides a plenitude of 256 slightly slower registers in the zeropage. – However, if you're using the 6502 like this, you may discover that you lose some of the much acclaimed advantage in cycle count per instruction.
Re: I believe 6502 instruction set is a good first assembly language
#1136502 was my first assembly language (back in the 80s). It was fine. However, when I later had to do some Z80 assembly programming I considered that instruction set a lot nicer. It had more registers. It had a swappable register set. It even had a few 16 bit instructions. Really nice. I guess most people just give up once they see the ugliness of what they got from Intel.
I guess, it's a matter of perspective. The Z80 is derived from the 8008 (actually the 8080), which was an on-a-chip implementation of the processor of the Datapoint 2200. Notably, the DP2200 was designed around an early Intel shift-register for memory (meaning, sequential memory), hence the multitude of internal registers in order to minimize memory access. (It's probably only for the 8080, which provided better supp…
Besides increasing the number of registers, Z80 has added many features that were standard in any general-purpose computer (e.g. signed integer support and indexed addressing), but which were missing in Datapoint 2200/Intel 8008/Intel 8080, simply because Datapoint 2200 had not been designed to be used in general-purpose computers but only for implementing the logic required inside a serial terminal.
However many programs for Z80 did not make good use of its additional functions, because they were intended to remain compatible with the legacy Intel 8080 systems.
Intel 8086 did not have this problem, because it was only source-code compatible with 8080, not binary compatible, so any application had to be recompiled for it, and fully using the new ISA did not have any additional disadvantage.
Unlike 6502, Intel 8080 and Z80 had a few 16-bit operations, which were intended for address computations, while data operations were expected to be handled using the 8-bit accumulator.
Despite the intended use and the limited set of 16-bit operations, implementing complicated arithmetic operations, e.g. floating-point arithmetic, was still faster using the 16-bit address registers and operations for handling data. With properly optimized programs, Z80 and even 8080 could be much faster than 6502 for number crunching. (Though faster is only relative, because FP64 floating-point operations took many milliseconds per operation on any 8-bit microprocessor, many billions of times slower than on a modern laptop or desktop CPU.)
Re: I believe 6502 instruction set is a good first assembly language
#114I prefer RISCV as an starting assembly language because: it has good design, it's more intuitive, it has modern language and tool support (GCC, LLVM, Rust, etc.), and it runs on QEMU and real available hardware.
Re: I believe 6502 instruction set is a good first assembly language
#115Can anyone speak on how it is to move from an older assembly, to a modern CPU? I asked to take an assembly class in local/public college, and was told they wouldn't hold the class because not enough students were interested. This was in 1998, and I truly couldn't believe my ears. I feel like learning modern assembly would be more useful, but maybe 6502 assembly is far easier to pick up? The first language I learned w…
- learn assembly as subroutines inside your "daily driver" language on your regular PC, which is going to be x64
- microcontroller with in-circuit debugger where you can connect it to flashing lights (obvious candidate is Arduino, which is AVR, or STM32 which is ARM)
Back in the day the first of these was easier in environments like BBC Basic inline assembler or MS-DOS COM files (which are headerless executables that can be extremely small.) You could also learn either of those in emulators.
Re: I believe 6502 instruction set is a good first assembly language
#116The hairy part the 6502 instruction set is Subtract With Carry, and the confusion about how the carry flag works as a result of subtracting or comparing. SBC is implemented by adding the ones-complement (XOR FF) of the number or register. And the carry flag is backwards compared to other architectures, such as the Z80. On input, Carry Set means that you don't want an additional one subtracted, and Carry Clear means y…
(So, technically, the carry is like a ones' complement / two's complement switch. And this is also all we need to implement a borrow in two's complement math.)
Re: I believe 6502 instruction set is a good first assembly language
#117Eventually, I ended up doing ASM with 68000 (Mac Plus), but by then, I was well on my way with higher-level languages.
Starting from Machine Language helped me a lot in understanding some of the more fundamental concepts of software. It was also an excellent troubleshooting teacher, which has probably been the most valuable software development skill I have.
These days, though, with the current complexity of CPUs, I don’t think it would be reasonable to start folks off with assembly/machine languages, anymore. I’m not sure that “retro” CPUs would really represent some of the difficulties experienced with highly parallel processors. I would worry that it might encourage an “idealized” view of the underlying architecture.
Re: I believe 6502 instruction set is a good first assembly language
#118If you want to learn a small, yet powerful instruction set with a few quirks go for ARM v6M. It‘s still in meaningful production (no the Monster 6502 doesn‘t count), has good platform support in the latest open source toolchains (debuggers, compilers, assemblers, linkers, etc.).
If you value openness of the architecture enough to deal with a less mature platform (as of early 2025) then pick a RISC-V MCU instead. If you can‘t decide pick a RP2350 :-).
The ARMv6M instruction set is small and no loading constants doesn‘t require long winded instruction sequences if you do it as documented (PC-relative load instead of shifting in immediate data). You don‘t have to deal with self modifying code and/or the zero page to index memory. Your registers are the same width as the address space. Yes it‘s 32 bits, but that makes it simpler to learn, use and teach than all 8/16 bit and most 16 bit instruction sets I’ve seen because you don‘t have to work around to narrow registers for common operations. To anyone who thinks this sounds boring: don‘t worry ARMv6 still has enough quirks you can use for code golfing.
Re: I believe 6502 instruction set is a good first assembly language
#119It was for me. In 1977 I lived in a little cabin in Oregon. I bought an Apple II as a diversion. Within a year I was working on a program that later became "Apple Writer" (https://en.wikipedia.org/wiki/Apple_Writer), written entirely in assembly.
Some in this conversation identify 6502 assembly as rather clunky and difficult to use. In retrospect I have to agree, but in 1977 I didn't have a basis for comparison.
There were no fast, high-level languages available for the Apple II, so my little program became an Apple product, primarily from the lack of alternatives.
Consider this -- Apple Writer lived in 8 kilobytes of RAM, but actually did things. It even had a macro language people used to process address lists.
I just boosted my main system to 96 gigabytes of RAM to be able to more easily host DeepSeek locally (I have an RTX 4090). I just realized that's enough RAM to hold almost 12 million copies of Apple Writer.
This is all pretty surreal ... but I've had occasion to say that a number of times since 1977.