4 ms·
I came across this when I was searching for resources to help better understand ALUs and assembler. I love it because: 1. My first computer (an Acorn Electron
by rahimnathwani 4y ago
I came across this when I was searching for resources to help better understand ALUs and assembler.
I love it because:
1. My first computer (an Acorn Electron) had a 6502 processor, and gave me my first exposure to assembler.
2. It's been built so you can do all the exercises in the browser. I really like stuff like this (e.g. Scrimba), as it makes it so much more likely that you'll get started.
A related point: as I go through it, I'm thinking about which instructions are really necessary (maybe all of them?) and why it would be inconvenient if you didn't have a particular instruction.
- jacquesm 4y agoThe simplest computer has only one instruction: https://en.wikipedia.org/wiki/One-instruction_set_computer https://en.wikipedia.org/wiki/One-instruction_set_computer There is even ZISC: https://en.wikipedia.org/wiki/No_instruction_set_computing https://en.wikipedia.org/wiki/No_instruction_set_computing Check out brainfuck if you are into stuff like this.
- rahimnathwani 4y agoHaha these are really interesting. It seems to program with such a reduced instruction set requires one to be either a genius or a computer (i.e. generated code). I'm neither :(
- jacquesm 4y agoEither that, or a compiler with such an instruction set as the target. For instance: https://github.com/arthaud/c2bf https://github.com/arthaud/c2bf It seems like this is a frivolous subject, but it is actually quite enlightening to realize just how little is required to get something that computes, it changes how you view the whole concept of computation.
- pkaye 4y agoSomeone wrote a C compiler that generates code using only x86 MOV instructs. https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator
- codedokode 4y agoVery interesting, never heard of this. I love Hacker News for being able to learn something new from comments. Although I cannot agree with labeling "horizontally nanocoded CPU" as "No instruction set". There are instructions, they are just low-level. I wonder, can Turing machine count as "Zero Insturction Set"? Technically there is no sequence of instructions.
- jacquesm 4y agoThat's a fair criticism. I think this article describes it better than I could and I get why they chose that name: https://www.lsmarketing.com/LSMFiles/9809-ai1.htm https://www.lsmarketing.com/LSMFiles/9809-ai1.htm
- pvg 4y agowhich instructions are really necessary (maybe all of them?) and why it would be inconvenient if you didn't have a particular instruction The ones added in the 65C02 offer some insight there, a very brief overview from the Wikipedia page: https://en.wikipedia.org/wiki/WDC_65C02#New_and_modified_instructions https://en.wikipedia.org/wiki/WDC_65C02#New_and_modified_ins... Somewhat related and mentioned in one of the comments downthread, you can view Woz's SWEET16 as a 'the 16 bit CPU a 6502 system designer and programmer wished they had' take.
- noobermin 4y agoTbf, the 6502 is super limited even by modern standards I think. I don't really think any of the instructions cannot find some use, not a single one. I think the only real instructions that you could think are not really "needed" are the "illegal opcodes[0]." Some games / demos including commercial ones use them, either for efficiency or just because I guess. A good "just because" reason I know of is for code obfuscation to deter disassembly and copyright infringement. [0] https://www.masswerk.at/6502/6502_instruction_set.html#illegals https://www.masswerk.at/6502/6502_instruction_set.html#illeg...
- hota_mazi 4y agoWell, if you really want to nitpick, there are quite a few instructions in the 6502 that are unnecessary. For example, STX. You could emulate it with PHA, TXA, STA, PLA. But overall, you are correct that the 6502 was extremely primitive in various ways, especially compare to the 8080 and followers.
- tom_ 4y agoYou'd need PHP/PLP too! STX doesn't affect the N and Z flags.
- tenebrisalietum 4y agoCLV is only there because the original 6502 had a SO (Set Overflow) pin, so if you wanted to test that pin, a CLV would be needed to remove the possibility your last ALU op set it. BIT isn't super useful and is generally used to allow multiple entry points into a subroutine with slightly different starting instructions, not something it was intended for and not really needed. There's a few instructions that aren't used that often unless you're being really hacky: - RTI isn't something you'll normally be using unless you're writing an IRQ handler. - TSX/TXS are only for changing the stack pointer, not a usual thing but might be used at times.
- hwd 4y agoMy first Computer was a Commodore 116 which also had a 6502 derivative processor. I stumbled accross Ben Eaters video series and nostalgia hit me hard. I started the ZeroMips project (https://zeromips.org/ https://zeromips.org/) and now I have the old Amiga Bouncing Ball demo running on my Western Design Center W65C02S together with FPGA based video hardware. This escalated quickly ;)
- kgwxd 4y agoI've used Easy 6502 a ton. A few years ago, I got into Atari 2600 programming. I personally haven't made anything useful but the community is very active and doing truly amazing stuff. I use desktop software (Stella and DASM) these days but 8bitworkshop[0] is a great site for playing with it. [0]https://8bitworkshop.com/v3.9.0/?platform=vcs&file=examples%2Fsprite.a https://8bitworkshop.com/v3.9.0/?platform=vcs&file=examples%...