5 ms·
My memory is dim on this (having last done 6502 assembly almost 40 years ago), but the extreme lack of registers on the 6502 meant many programs were a tedious,
by Scubabear68 3y ago
My memory is dim on this (having last done 6502 assembly almost 40 years ago), but the extreme lack of registers on the 6502 meant many programs were a tedious, endless parade of lda, sta instructions.
- pstuart 3y agoIt was the first CPU I learned assembly on, also 40 years ago ;-) Yes, the constrained registers made things challenging but I have positive memories about the experience. I was introduced to Chuck Peddle ~20 years ago at a friend's wedding and got a chance to talk with him (it was kind of like meeting a rock star for me). What stuck with me was him recounting that his travels to Sri Lanka for a business there convinced him that the bustling cities in south east asia were breeding grounds for a pending viral disaster that would cover the globe thanks to advances in air travel. When Covid came along I felt like he was somewhat validated but fortunately not to the degree he had forecasted.
- eru 3y agoWell, for all we know, Covid came out of China and did not hit South East Asia any harder than any other region. (Even more so, if you control for wealth, I guess?)
- selcuka 3y agoNot only that, but X and Y registers were slightly different too. You could use one for indexing in a certain way, but not the other (it's been 30 years for me, but still the memory is hazy). There were no 16-bit registers a la Z80 either.
- dietrichepp 3y agoThe main difference between X and Y is in the indirect addressing modes. You can use X as an index when you are looping through an array of pointers. You can use Y as an index when you are looping through an array, where you have a pointer to the beginning of that array. There are also a couple operations that always use X as a source or destination. There’s TXS/TSX, but no TYS/TSY. https://www.masswerk.at/6502/6502_instruction_set.html https://www.masswerk.at/6502/6502_instruction_set.html
- dietrichepp 3y agoI think of it as having a nice set of 256 “registers”, in the zero page at addresses 0-255. I think of the A register as kind of an intermediate location for data that is going from memory to the ALU or the ALU to memory. The article says as much: > In effect the 6502’s ‘page zero’ in memory provides a large number of ‘pseudo’ 8 and 16-bit registers, slower than real registers, but still faster and more versatile than having to use other parts of memory. A skilled programmer making effective use of ‘page zero’ could write code that was fast when compared to other 8-bit designs. I haven’t done a lot of 6502, though. I learned Basic on the Apple II when I was young but moved to Think Pascal, HyperCard, and CodeWarrior on the Mac.
- bogantech 3y ago> I think of it as having a nice set of 256 “registers”, in the zero page at addresses 0-255. It becomes a pain making sure the monitor/bios and any programs don't stomp on each others zero page locations though. Then if you start daydreaming about multitasking you have to worry about shoveling the contents off somewhere else whenever you switch tasks. The 65816 at least can relocate zero page & the stack but if you're going 16 bit you're better off going M68K
- Brananarchy 3y agoBetter off unless you're targeting the SNES
- artemonster 3y agoI loved the simplicity of it. This was my first assembly that I have learned (at 15) and I had SO MUCH FUN with it. Maybe this is "first love" bias, but nothing else compared with the fun factor later on (AVR, PIC, X86, RISC-V)
- bArray 3y agoNot really, I think it would be better to implement a series of smaller functions and utilize the stack [1]. That way you avoid lda and sta'ing tonnes. I much preferred the 8086/8088 instructions though [2], pop and push are nice to have. [1] https://en.wikibooks.org/wiki/6502_Assembly#Stack https://en.wikibooks.org/wiki/6502_Assembly#Stack [2] https://en.wikipedia.org/wiki/X86_instruction_listings#Original_8086/8088_instructions https://en.wikipedia.org/wiki/X86_instruction_listings#Origi...
- colanderman 3y agoThe stack only helps a little. Even basic operations like "add two numbers together" require the use of memory (as there is no opcode to add two registers together).