6 ms·
This is awesome! The media loves to say your pocketwatch is more powerful than X form $date. This is a fun technical rundown. I think at some point we have to
by crmrc114 7y ago
This is awesome! The media loves to say your pocketwatch is more powerful than X form $date. This is a fun technical rundown.
I think at some point we have to start talking about how far from optimized we are https://en.wikipedia.org/wiki/MenuetOS https://en.wikipedia.org/wiki/MenuetOS comes to mind when talking about what can be done in fasm. Are we ever going to get compilers to the point where we can squash things down to that size and efficiency? Is this yet another thing that AI can promise to solve someday?
- TazeTSchnitzel 7y agoIf it can be done efficiently in asm then it can be done in C, C++, perhaps even Rust. But there are sacrifices to be made: unmaintainable “clever” code without clean abstractions.
- vardump 7y agoThere are architectures that are just fundamentally C-hostile. Perhaps the most famous one is 6502. No efficient way to implement stack based parameter passing, generic pointer arithmetic, and lots of other bits and pieces. You can still use C on 6502, it's just not very fast. I guess you could define another language that mostly looks like C, but built around particular CPU architecture quirks.
- wwweston 7y agoWhat are some languages (other than its own instructions) that 6502 is friendly to?
- pvg 7y agoBASIC, arguably. People often say C is 'high level assembly' but in some ways BASIC is closer with the absence of block structure, scopes, etc. Control flow in a BASIC (basic BASIC, not fancy newer BASIC) program ends up looking a lot like that in an assembly one.
- int_19h 7y agoGiven that all that high-level control flow is rewritten into gotos anyway, why would that make a difference in general, or specifically for 6502?
- Tuna-Fish 7y agoAll high-level control flow is very definitely not rewritten into gotos. Almost all cpus have some form of function call instruction, and c functions are implemented by using it. Without such an instruction, or even a fast way to model it, C becomes much less efficient to implement.
- int_19h 7y agoOP was talking about block structure, not subprograms. In any case, BASIC has them.
- wk_end 7y agoFORTH was pretty widely used on 6502-based machines.
- TazeTSchnitzel 7y agoI wonder if you can write fast C for the 6502, though, but you'll have to constrain your use of the language considerably?
- spc476 7y agoThe 6502 is a very constrained CPU. It only has 6 registers, only one of which (PC) is 16 bits. The stack is fixed at addresses 0x0100 to 0x01FF, and the two index registers are 8-bits in size. So is the accumulator and the stack register (hence the fixed address for the system stack) and no stack-based addressing modes. You'll have a severe penalty in doing any 16-bit arithmetic. There is no general multiply or divide instructions. I think the architecture is about as hostile to C as you can get and still be popular.
- bsder 7y agoThe main problem is that most compilers really need lots of registers to optimize well. Without lots of registers, you're constantly spilling to memory and that makes things slow. If you program in assembly, you have visceral knowledge of when you overrun you registers and you will restructure the entire architecture of your program to avoid that.
- tdons 7y agoBen Eater has a fantastic series of videos where he builds a hello world program on the 6502 https://www.youtube.com/watch?v=LnzuMJLZRdU&list=PLowKtXNTBypFbtuVMUVXNR0z1mu7dp7eH https://www.youtube.com/watch?v=LnzuMJLZRdU&list=PLowKtXNTBy...
- Someone 7y agoI think that, partly, that it isn’t as much C-hostile as that C compilers mostly target other architectures, and that many C programs take too much for granted, such as the existence of huge 16-bit Numbers or efficient multiplication. A compiler/linker combo for the 6502 should, for example, analyse the call graph of the entire program to figure out what return addresses it needs to store on the stack at all (alternative 1: store it at a forced address in main memory (will work in single-threaded code that isn’t recursive). Alternative 2: instead of RTS, jump back to the caller (will work for functions that get called from only one place. Aggressively inlining those is an alternative, but may turn short branches into long ones, with their own problems) Similarly, a compiler/linker for the 6502 probably should try really hard to move function arguments to fixed addresses, and to reuse such memory between different functions (if foo isn’t (indirectly) recursive and doesn’t (indirectly) call bar and vice versa, their function arguments can share memory) And yes, self-hosting such a compiler would be even more challenging, given the 64kB memory limit.
- fpoling 7y agoSounds like it was targeting Fortran.
- lazyjones 7y ago> Are we ever going to get compilers to the point where we can squash things down to that size and efficiency? No, because we'd have to support bearded bride Emoji...
- bloopernova 7y agoSpeaking of fun technical rundowns, I've idly wondered: - Approximately which year's average desktop PC is equivalent to a current Raspberry Pi? - What year's worldwide computing power is equivalent to a current Raspberry Pi? I'm sure folks can come up with other comparisons to make. I know it's not very useful to the world, but it's fun to think of just how much astonishing compute power we have these days.
- ghaff 7y agoFor the first question, probably somewhere in the mid-2000s. Maybe early Core microarchitecture.
- hnuser123456 7y agoI'll give you a mid-2000s Celeron, before core, except 4 of them because it's a quad core, and with a few times more RAM since you can get pis with up to 4GB now. I had a 1.8Ghz single-core celeron with 512MB of RAM in 2005, upgraded to 3.0GHz with 768MB by 2006, then leaped to a Q6600/4GB in 2007. Not sure how my Radeon 9200 and later X1600 would've compared to the Pi GPU though. This guy puts the rpi 4's GPU at 8 GFLOPS: https://www.raspberrypi.org/forums/viewtopic.php?t=244519 https://www.raspberrypi.org/forums/viewtopic.php?t=244519 Looks like the X1600 was around 6 GFLOPS: https://en.wikipedia.org/wiki/List_of_AMD_graphics_processing_units#Radeon_X1000_series https://en.wikipedia.org/wiki/List_of_AMD_graphics_processin...
- numpad0 7y agoYou could do dual socket on Socket370, don’t know about quads though
- J5892 7y ago- How many Apollo 11 guidance computers would you need to run Doom?
- flatiron 7y ago
- gowld 7y agoApollo 11 used a heck of a lot more materials and energy than a USB charger.
- atoav 7y agoAnd it had a lot more redundancy and probably dealt with radiation better than a USB charger. Different designs for different applications.
- nostrademons 7y ago> Are we ever going to get compilers to the point where we can squash things down to that size and efficiency? Compilers are already that good. The problem is economics. If you have an OS that uses up 1% of the available CPU budget, there will be pressure from management & product to spend the additional 99% on additional bells & whistles. Maybe you add fancy animations and transitions to window opening. Maybe you add full-HD search and spend additional CPU cycles indexing. Maybe you add transparent cloud storage and spend the additional CPU cycles backing up files. Maybe you add new frameworks for developer productivity, all of which suck up CPU time. And the thing is - from a business perspective, these are all the right thing to do. Because having a slick, glossy UI and a long list of useful features will sell more copies, while being able to run it on a USB-C charger or 25 year old computer will probably not sell more copies.
- miohtama 7y agoWhat kind of hardware do pocket (/wrist) watches run? (Not smart watches) How much RAM/ROM/CPU? E.g. those famous Casios with LCD.
- miohtama 7y agoGod bless Richard Stallman for open source and GitHub for making sharing it easy https://github.com/carrotIndustries/pluto/blob/master/README.md https://github.com/carrotIndustries/pluto/blob/master/README...
- hyperdimension 7y agoMy TI Chronos "development kit" watch (AKA my normal watch) contains a CC430F6137 mcu, which has 32 kB flash and 4 kB RAM. It contains a MSP430(X) core and a CC1101 RF front-end for communicating with other accessories or a computer. It's running the (custom/not from TI) open-source firmware openchronos-ng-elf, which is on github. When I get around to it, there are a few features I'd like to add, but it's nice just to know that I can.
- numpad0 7y agoQuarts watches use 32.768kHz(1/2 * 65536 Hz) crystal, means its output through binary counters easily produce clocks at base 10 fractions of seconds. That could be then fed to decoders to LCD, so no need for uC.