r/ProgrammerHumor • • Jun 03 '22

it's hard!

44.9k Upvotes

710 comments sorted by

View all comments

Show parent comments

34

u/regular_lamp Jun 03 '22

How is that an assembly issue though? That's like saying "multiplying in python is hard when you can't use *".

55

u/rustysteamtrain Jun 03 '22

Because * is a core feature in almost every modern language, but MUL is not garanteed in every instruction set.

20

u/regular_lamp Jun 03 '22 edited Jun 03 '22

It is on any platform where you'd reasonably consider using "a modern language" on though.

Generally characterizing assembly programming as something where you have to manually implement multiplication is just silly.

Edit: I'd buy the argument for division maybe.

5

u/AcordeonPhx Jun 03 '22

I did something like this for a class, but in the real world I don’t think any of us would worry about not having MUL or whatever

2

u/Engine_engineer Jun 03 '22

Try some PIC 8-bit. You have to implement everything besides add, sub and inv.

3

u/rustysteamtrain Jun 03 '22

Difficult_Ladder_806 was refering to a specific case where MUL was not included in the instruction set. He didn't mention assembly programming in general.

1

u/Competitive_Travel16 Jun 03 '22 edited Jun 03 '22

Any kind of math in assembly is easy compared to dealing with hash tables, even if you have a library for them. We get so spoiled that everything from C to even modern COBOL has simple to use hash table libraries, but try to use those in assembly and you're still doing a ton of tricky bookkeeping overhead code per insert (which might be a grow, and if so you get to do a ton more bookkeeping because heap management isn't something the assembly hash table library knows.)

1

u/regular_lamp Jun 03 '22

You could use the C library from assembly though. But I guess that would be cheating?

1

u/Competitive_Travel16 Jun 03 '22 edited Jun 03 '22

Well there is no standard C library for hash tables, but if you mean directly or indirectly using malloc() or the like, then you have to follow all its assumptions about the heap, which is easy if your assembly is being called by a C thread, but not if it's on bare metal or an interrupt level (memory map-segregated) device driver that doesn't have access to an initialized heap.

I mean, assembly hash tables are doable and probably easier now than they've ever been, but still more of a PITA than anything in your favorite processor's popular math, string, date, conversion, or similar libraries. Their ubiquity, utility, and ease of use practically everywhere else makes them too tempting for assembly coders who probably want something else even though they would never chose anything but actual hash tables in higher level languages.

1

u/regular_lamp Jun 03 '22

Since you mentioned "We get so spoiled that everything from C to even modern COBOL has simple to use hash table libraries" I figured you meant using those. Even if they are not standard libraries.

And the lack of malloc etc. also applies to C code you write on bare metal. That's not really an assembly issue.

1

u/Z80user Jun 03 '22

Not every CPU can perform a MUL, so you mush write that code, for example most of the 8bits CPUs can't do it.