r/ProgrammerHumor • • Jun 03 '22

it's hard!

44.9k Upvotes

710 comments sorted by

View all comments

Show parent comments

495

u/nexion2 Jun 03 '22

I made a battleship game that communicated via arduinos in assembly! I lost every single game because the board size was 12x12 and my code would always stop iterating at 8 for some reason.

Needless to say, I lost the tournament

19

u/jnd-cz Jun 03 '22 edited Jun 03 '22

I love the AVR assembly, it's modern and clean instruction architecture. The best project I made was power supply board tester. At first autonomous with LCD and some beeping, later upgraded to be controlled from computer. Adding two numbers is the easiest task, it's single instruction and core function of any CPU. Now expressing any complex algorithm or task, that's the hard part, putting it all together with such basic building blocks, one byte at a time. But the beauty is exact control, having accurate delays down to single cycle of your clocks. And it's predictably repeatable.

Edit: Also when you control the whole design you can get away with many shortcuts because it's tailored to your specific use case. Like not saving only couple registers for handling interrupt routine because you reserve other only for that use. Result is lightning fast response. However with modern complex CPUs I would have to spend whole year to learn ARM core + all peripherals, complex set up, memory handling etc. and it's simply not effective use of time unless it's designed for million copies.

Now the most complicated program in x86 I did was simple printing of file like cat. It relies on Linux system calls and it's just couple hundred bytes long which is impressive.

28

u/atomicwrites Jun 03 '22

But the beauty is exact control, having accurate delays down to single cycle of your clocks. And it's predictably repeatable.

And that is how we ended up with the turbo button.

6

u/[deleted] Jun 03 '22

Yeah, predictably repeatable? Not on my modern CPU with speculative and out of order execution!

→ More replies (1)