News for hackers. Stuff that matters.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by crmrc114 on Thursday February 06, 2020 @01:18PM (#22258580)
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 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?

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by nostrademons on Friday February 07, 2020 @05:06PM (#22271559)
> 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.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by bloopernova on Friday February 07, 2020 @03:56PM (#22270838)
Speaking 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.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by ghaff on Friday February 07, 2020 @04:10PM (#22270984)
For the first question, probably somewhere in the mid-2000s. Maybe early Core microarchitecture.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by hnuser123456 on Saturday February 08, 2020 @05:40AM (#22275099)
I'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

Looks like the X1600 was around 6 GFLOPS:

https://en.wikipedia.org/wiki/List_of_AMD_graphics_processin...

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by numpad0 on Saturday February 08, 2020 @08:25AM (#22275592)
You could do dual socket on Socket370, don’t know about quads though
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by J5892 on Friday February 07, 2020 @04:20PM (#22271086)
- How many Apollo 11 guidance computers would you need to run Doom?
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by flatiron on Friday February 07, 2020 @04:41PM (#22271271)
I believe you require a 32 bit computer and I think those were 15. So no doom :(
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by grawprog on Friday February 07, 2020 @05:06PM (#22271553)
Though, where there's a will there's a way...

https://doom.fandom.com/wiki/16-bit

>After the release of Doom II on the PC, the original three episodes were released to some 16-bit consoles that used special 32-bit enhancement hardware. For the Sega Genesis, the 32X allowed for additional address space to enable Doom to run its demanding resources of the time which a 16-bit system wouldn't have handled. Whereas with the SNES, the Super FX 2 chip inside the DOOM cartridge allowed for an internal co-processor of the game cartridge to eliminate the need for bulky addons for the aging SNES.

Would it count if you somehow built in a 32-bit coprocessor for your 15-bit apollo doom port?

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by flatiron on Friday February 07, 2020 @05:57PM (#22272047)
Question was could it do it which it can’t. But yeah you could use the Apollo for controller IO and put the rest on a raspberry pi but that kinda defeats the purpose.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by plapetomain on Friday February 07, 2020 @11:17PM (#22273833)
But the data width is the least of concerns anyway. You should realize a 15 bit computer can compute everything a 32 bit can?

The bigger problems are more pedestrian like complete lack of suitable IO.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by dang on Saturday February 08, 2020 @02:14AM (#22274459)
Could you please stop creating accounts for every few comments you post? We ban accounts that do that. This is in the site guidelines: https://news.ycombinator.com/newsguidelines.html.

HN is a community and we want it to remain one. For that, users need some identity for others to relate to. Otherwise we may as well have no usernames and no community, and that would be a different kind of forum. https://hn.algolia.com/?sort=byDate&dateRange=all&type=comme...

You needn't use your real name, of course.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by twic on Friday February 07, 2020 @06:37PM (#22272350)
So you'd need 2.13 of them is what you're saying.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by 75central on Friday February 07, 2020 @04:53PM (#22271417)
My idly wondering one day was when in history did the worldwide available compute power (roughly) equal that of my iPhone 11?
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by TazeTSchnitzel on Friday February 07, 2020 @02:44PM (#22270028)
If 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by vardump on Friday February 07, 2020 @04:17PM (#22271066)
There 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.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by Someone on Saturday February 08, 2020 @10:51AM (#22276325)
I 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.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by tdons on Saturday February 08, 2020 @03:03AM (#22274629)
Ben 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=PLowKtXNTBy...

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by TazeTSchnitzel on Friday February 07, 2020 @05:19PM (#22271720)
I wonder if you can write fast C for the 6502, though, but you'll have to constrain your use of the language considerably?
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by spc476 on Saturday February 08, 2020 @12:52AM (#22274201)
The 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by bsder on Saturday February 08, 2020 @02:27PM (#22277805)
The 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by wwweston on Friday February 07, 2020 @05:06PM (#22271552)
What are some languages (other than its own instructions) that 6502 is friendly to?
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by pvg on Friday February 07, 2020 @05:42PM (#22271927)
BASIC, 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by int_19h on Friday February 07, 2020 @08:58PM (#22273196)
Given that all that high-level control flow is rewritten into gotos anyway, why would that make a difference in general, or specifically for 6502?
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by Tuna-Fish on Saturday February 08, 2020 @09:32AM (#22275871)
All 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by int_19h on Sunday February 09, 2020 @12:10AM (#22280492)
OP was talking about block structure, not subprograms. In any case, BASIC has them.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by wk_end on Friday February 07, 2020 @06:05PM (#22272119)
FORTH was pretty widely used on 6502-based machines.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by fpoling on Saturday February 08, 2020 @04:19PM (#22278415)
Sounds like it was targeting Fortran.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by miohtama on Friday February 07, 2020 @05:23PM (#22271755)
What kind of hardware do pocket (/wrist) watches run? (Not smart watches) How much RAM/ROM/CPU? E.g. those famous Casios with LCD.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by miohtama on Friday February 07, 2020 @05:39PM (#22271906)
God bless Richard Stallman for open source and GitHub for making sharing it easy

https://github.com/carrotIndustries/pluto/blob/master/README...

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by hyperdimension on Friday February 07, 2020 @06:05PM (#22272112)
My 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.

Re:Apollo 11 Guidance Computer vs. USB-C Chargers by numpad0 on Saturday February 08, 2020 @08:55AM (#22275701)
Quarts 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.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by gowld on Friday February 07, 2020 @04:43PM (#22271288)
Apollo 11 used a heck of a lot more materials and energy than a USB charger.
Re:Apollo 11 Guidance Computer vs. USB-C Chargers by atoav on Friday February 07, 2020 @06:34PM (#22272336)
And it had a lot more redundancy and probably dealt with radiation better than a USB charger. Different designs for different applications.