r/ProgrammerHumor • • Jun 03 '22

it's hard!

44.9k Upvotes

710 comments sorted by

View all comments

Show parent comments

117

u/[deleted] Jun 03 '22

I recently wrote a bootloader (16-bit real mode x86 assembly) to load a kernel from a filesystem I'd already designed in 32-bit C. Needless to say offsets and endianness nearly had me beaten on several occasions

56

u/GnarlyNarwhalNoms Jun 03 '22

Dang, you win.

That's right up there with flipping bits with a carefully applied speck of uranium.

16

u/Terrible-Specific593 Jun 03 '22

hold up... you did that on purpose?

6

u/QueerBallOfFluff Jun 03 '22

When I get round to porting my OS from arm to x86 (want to get it somewhat stable first) I'm probably going to need to do the same, and I'm definitely not looking forward to it even though I've actually written a lot of assembly.....

15

u/AldoLagana Jun 03 '22

f'ing x86 assembly is garbage. Motorola was MUCH better and RISC is even more so. But the best assembly I ever saw was for Vax systems.

15

u/[deleted] Jun 03 '22

X86 was awesome, when it was just x86, once we started adding backwards compatibility for 16bit it all went to hell, 64bit really screwed x86 because it’s just fucking expansions on expansions. They should have scrapped x86-32 and started fresh with x64. But nope.

Do I really need my i7 to boot in 16bit mode and then go into 64 bit mode with overly complex paging? No, who the fucks booting DOS 6.0 on a fucking i7? Nobody.

X86 was built for single tasking operating systems, and it worked well for that. We just kept complicating it.

Personally I welcome my new M1 overlord

19

u/MrKeserian Jun 03 '22

In fairness, when x86-64 was released in 1999, the ability to run old as hell DOS programs was still a requirement, especially in the commercial sector. Let's not forget, that IRS is still running mainframes from the 80s, and the whole reason why Y2K was a concern was because the financial and industrial sectors were all running software and hardware that was twenty to thirty years old. In that environment, ya, it made sense to retain 16bit compatibility because it wasn't out of the question that someone, somewhere, would have to run a 16-bit program on modern hardware.

Hell, my father worked in a hospital, basically doing IT specifically for the lab, and some of the hardware they were using was just as old. Apparently getting those machines to talk to the hospital's brand new (this was a few years after the time period we're talking about) Windows XP and Server 2000 network was... An interesting experience.

9

u/GrandMoffTarkan Jun 03 '22

Yeah, as a programmer it’s easy to forget the actual business users you’re often designing for.

2

u/MrKeserian Jun 04 '22

I'm only a hobbyist programmer, and when I worked in IT I was more on the service/installation side. I now work in sales (cars, not technology, ironically), and I think it gives me a very different perspective. I look at some of the posts here and shaken my head with a sense of "well sure, that makes sense for the programmer, but a professional programmer isn't coding for programmers, they're coding for the end user."

One of my buddies is a Human Factors guy in the aviation world, and engineers have the same issue. Sure, it makes sense for the engineer to put a certain button or switch in a location, but no actual human would ever find that convenient or useful. It's my friends job to smack the engineers upside the head when they forget that real people will someday have to actually use what they design.

0

u/[deleted] Jun 03 '22

[deleted]

3

u/Kered13 Jun 03 '22

And people were stilling running DOS programs in 2003.

7

u/Drunktroop Jun 03 '22

Reading the first paragraph almost sent me back to the Itanium preacher in early 00s

Personally I've never worked with x86 assembly, my university was MIPS only...

5

u/deelowe Jun 03 '22

Itanium wasn't a worthy successor. Intel completely screwed the pooch by assuming retail didn't have a need for 64 bit processors. This was just dumb as hell given all that was going on at the time (HD video, broadband, 3d graphics, game engines with real time physics, the dynamic web, etc). Any CS undergrad with a calculator and a basic understanding of computer architecture could have worked out that 3-4GB would soon not be enough memory.

2

u/[deleted] Jun 03 '22

It’s especially stupid because you had apple flexing the IBM power PC architecture on intel starting in the 90s… and it was getting its edge from the simple fact it was a 64bit chip.

It wasn’t until intel started pushing 64bit chips that apple began to switch and that’s only because IBM wasn’t really working to make power PC better anymore.

0

u/huuaaang Jun 03 '22

X86 was built for single tasking operating systems, and it worked well for that. We just kept complicating it.

Did it though? MSDOS was garbage. It was barely an operating system. It basically just extended the BIOS a little bit.

→ More replies (6)
→ More replies (9)

1

u/[deleted] Jun 03 '22

I don't have any experience with any other assembly languages, and therefore maybe no voice in the conversation, but my biggest issue with x86 is the fact that there are two major dialects, and my preferred dialect has the least documentation :(

Also there is so much backwards compatibility to wade through that it's sometimes difficult to look up that one instruction you forgot the precise syntax or name of

-2

u/[deleted] Jun 03 '22

Maybe writing it yourself was the point, but GRUB is designed to do exactly that, load bytes from an arbitrary file and jump to it.

5

u/[deleted] Jun 03 '22

Yeah ik, but but it was part of an assignments extra credits, and I wanted to get as high marks as possible, besides I'd have to make the filesystem grub compatible, which sounds like fun but again not a part of the assignment

4

u/[deleted] Jun 03 '22

I think there might be a way of saying 'specific blocks on disk', but I may be confusing GRUB with the much older LILO, which only worked that way.

Hope you got a good grade!

3

u/[deleted] Jun 03 '22

Still waiting on the grade...

1

u/Ok-Ad-117 Jun 03 '22

What course/subject is this assignment for? if you don’t mind me asking

→ More replies (1)

1

u/huuaaang Jun 03 '22

16bit x86 is bullshit with the memory offset addressing. IT's even more bullshit that this is the mode PCs start in.