5 ms·
Easy 6502
- hk__2 13y agoAlready posted: https://news.ycombinator.com/item?id=5180937 https://news.ycombinator.com/item?id=5180937
- transfire 13y agoA few years back some really smart guys figured out how to make optical diodes. That means optical computers, that means really really fast computers. They said the problem was the the size of the diode was on the order 400nm as opposed to todays transistors being around 40nm or so. What did I think? Screw that! I'll take a 1 THz 6502 over all these bloated multi-core pipeliney chips any day of the week!
- harrytuttle 13y agoYou'd need an MMU with more transistors than the CPU to make it useful though...
- forktheif 13y agoI hadn't heard about super fast optical transistors, but a few months ago I was reading about ultra fast transistors that operate at 600GHz. The idea came to me, to write a x86 emulator in 6502 assembly. Run it on a 6502 CPU built using ultra fast transistors, and boom, you've got a faster x86, just it's an emulated x86, MMU and all! Typical 6502 instructions take 2-8 cycles if I remember rightly, so as long as it takes under 200 6502 cycles to emulate one x86 instruction, you're beating a 4GHz x86 processor. I'm sure there are practical problems that make it difficult or impossible in reality. But still fun to think about. :)
- pgeorgi 13y agomost obvious practical problems: - 3 8bit registers vs. ~8 32bit or ~20 64bit registers. (so you're essentially working on memory at all times, and have to emulate all "longer" commands, such as addition, to do 4-8 carries manually) - 64k of memory (which includes the emulator), so you need to add some banking mechanism. - no support for integer multiplication/division or even float/SIMD in your instruction set. But you probably can provide a fast implementation of the decimal addition instruction :-)
- Terretta 13y agoAbsolutely adore 6502. Started to learn it just a few weeks after being exposed to AppleSoft BASIC and realizing assembly was playing in the machine itself. There was a holistic understanding of computing that came from the whole Apple II package: taking off the lid, looking at the chips, mapping that to the technical manual showing you the chips, their addresses, their wiring, their code, and being able to stick your hands in all of it. Even a kid could reason the whole machine's current state. For a while in the late '90s and early '00s, I wondered if we'd lose that kind of education. Tablets worry me for this reason--all screen, no insides. Thankfully "kids these days" (grownups too) have things like the Arduino so all hope of understanding computing from the inside out is not lost.
- gdubs 13y agoWoz talks about this a bit in his autobiography. About how lucky he was to have been around when you needed an understanding of the machine at a very low level, compared to growing up in a time where most of that was already abstracted away.
- Someone 13y agoFor those who do not know that: "the technical manual showing you the chips, their addresses, their wiring..." wasn't reverse engineered or smuggled out of Apple. It shipped with every Apple II. See http://archive.org/details/applerefjan78 http://archive.org/details/applerefjan78. Starts with fairly dull stuff (Basic commands, 6502 instruction set), so you may want to start reading from the end.
- mpyne 13y agoWish my Apple //c+ would have had it, would have made programming games a lot easier!
- lclarkmichalek 13y agoIt emerged recently on r/ReverseEngineering that the 6502 has fewer transistors than the number of pages in Intel's x86 documentation. Link to the discussion: http://www.reddit.com/r/ReverseEngineering/comments/1lp61a/intel_x86_documentation_has_more_pages_than_the/ http://www.reddit.com/r/ReverseEngineering/comments/1lp61a/i...
- rickjames28 13y ago6502 reminded me of one of my favorite books Hackers. http://en.wikipedia.org/wiki/Hackers:_Heroes_of_the_Computer_Revolution http://en.wikipedia.org/wiki/Hackers:_Heroes_of_the_Computer.... I wonder what happened to John Harris http://en.wikipedia.org/wiki/John_Harris_(software_developer) http://en.wikipedia.org/wiki/John_Harris_(software_developer... I heard he stubbornly refused to move to C from assembly.
- s_q_b 13y agoAh, this is great. I first learned assembly programming to modify one of my favorite video games, Earthbound. To my surprise, the game was a cult classic, and extensive efforts had been made to develop tools to modify every aspect of the game. As part of that effort, I learned 65816 assembly, a 16-bit descendant of the 6502. The day I modified the code to add a run button, thereby eliminating one of the most annoying aspects of the original game, I was ecstatic. I checked back on the community, PK Hack, a few months ago. The level of development was amazing. Virtually the entire game was mapped, byte for byte. There's a sophisticated visual map editor, and a cross-platform data editor. The coolest part was to see a tool I envisioned, for which I developed a lackluster proof of concept, come to full fledged fruition. Earthbound, as it turns out is a rather uniquely developed game. The second game in the Mother series, which is enormously popular in Japan, ran into severe difficulties. Co-developed by HAL and Ape, the coding was rather schizophrenic from the outset. Eventually large parts were rewritten by Shigesato Itoi himself, as the legend goes. The end result is a spaghetti soup of code generated by some type of macro system, compiled from some variant of C, and written in assembly itself. To manage this complexity, many of the events in the game used a text scripting language that abstracted away the underlying routines. This scripting was a series of in-line hex sequences, each its own set of instructions for how sprites, character entities, etc. were supposed to act when the code appeared, which we termed "control codes." 12-year-old me, supremely confident in his abilities and utterly lacking in all technical knowledge, suggested we build a scripting language on top of the control codes so that manual text editing would be eased. The result was a slapdash Visual Basic job that used a BASIC like syntax for simple substitutes for control codes. Of course at the time, I had no knowledge of parsers, DSLs, language design, or really basic computational knowledge. The result was a wreck. But that wreck stuck in someone's mind. Years later, after obtaining his computer science degree, one of the hackers with whom I had worked implemented a full-fledged language on top of the control codes. In retrospect, I don't remember the vast amounts of time I ostensibly wasted learning an obsolete game's design and building tools with which to modify it. I remember the heady moment when you suddenly knew how a data field worked, or after a whole night of hunting with a hex editor the data you wanted appeared, and the sheer giddy thrill of discovering new knowledge and seeing it implemented right there, like a physical mark on the world. I recognize this has been a long and tangential exposition, so if you've read any of it thank you for indulging me. Another glimpse of that low level assembly, like the smell of home after a very long time away, brings back so many vivid memories.
- danmaz74 13y agoMy first "serious" programming attempts were trying to use interrupts on a commodore 64 to play music in the background. It didn't work as I wanted - I was 10 - but I really learned a lot.
- illicium 13y ago>Well, I don’t think learning x86 is useful. Unless you are a security researcher and your day job is reverse engineering executables.
- __david__ 13y agoLove it! The 6502 was the first assembly I ever learned. I still remember a handful of opcodes from all the hand-assembling I did: a9 44 20 ed fd a9 41 20 ed fd a9 56 20 ed fd a9 49 20 ed fd a9 44 20 ed fd 60 About a year ago, in a fit of nostalgia, I wrote an Apple ][ emulator in javascript [1]. My 6502 emulator isn't quite perfect yet, but it runs most things. [1] http://porkrind.org/a2 http://porkrind.org/a2
- waterlesscloud 13y agoGood ol' hand-assembling, the only way to learn. I had a Radio Shack Color Computer, which in itself was more than my parents could really afford at the time, so I never got the pricey-for-us EDATSM+ editor/assembler. But I could afford a 6809 book that included op-codes. Then it was a matter of a lot of notebook paper and Basic programs that did a lot of POKEs. Heh. I did a little basic music synth program that way. I had a lot of spare time as a kid.
- lifeisstillgood 13y agoThere is a lot in that last sentence - I am worrying how we will find the time to fill in football, swimming, parties and gym for my eldest - yet for me the memories of my youth were acres of time to do what I wanted (even if I felt bored !) We should encourage just using up the time on anything - drawing, coding, playing an instrument. Anything that builds capital for later life.
- duncan_bayne 13y agohttps://en.wikipedia.org/wiki/Slow_parenting https://en.wikipedia.org/wiki/Slow_parenting "Slow parenting (also called simplicity parenting and free range parenting) is a parenting style in which few activities are organised for children. Instead, they are allowed to explore the world at their own pace. It is a response to concerted cultivation and the widespread trend for parents to schedule activities and classes after school; to solve problems on behalf of the children, and to buy services from commercial suppliers rather than letting nature take its course."
- harrytuttle 13y agoI never 'got' the 6502 and religiously went Z80 all over until someone described it in the following way: Think of it as a RISC CPU with 256 registers (zero page). It just clicked then. Wonderful processor.
- cmccabe 13y agoI disagree with the claim that learning x86 assembly is not useful. I occasionally use inline assembly in my day job. It's very rare, but it does happen. If you're doing C or C++, it helps to know a little bit of x86 assembly when debugging. There are also certain optimizations that you often need inline assembly for, such as using the built-in Intel instruction for CRC32 calculations. I learned Z80 assembly when writing software for the TI-85. But if I were giving advice to someone interested in learning assembly now, I would suggest learning x86... it's more useful, and just as fun.
- stevekemp 13y agoI started with z80 on the Spectrum, and was pleased that x86 was largely similar. I guess it helps that people from Intel founded Zilog.
- frozenport 13y ago`I don’t think you’ll ever have to write assembly language in your day job` Doing C++ work I have had to do this a few times, maybe once a year to optimize a critical routine that the compiler wasn't able to pick up on. When it helped, it really helped.
- cz20xx 13y agoCan't you load custom assembly into the 6502 screensaver on XScreensaver? Going to try that.
- sokoloff 13y agoThe first time I was paid for a programming job was writing relocatable 6502 assembly to put into a string and call from Atari Basic. What did it do? Computed the X-modem checksum of a block. Why? Because when 1200 baud modems first came out, the BBS I was a member of couldn't compute the checksums fast enough (directly in Basic), so 1200 baud transfers weren't much faster than 300 baud. And if you just paid several hundred bucks for the new 1200bps modem, you wanted to get some benefit. :) How much did I get paid? $20, which was about $0.50/byte. (Man, how I wish I got paid $0.50/byte for code I write now!!)