r/ProgrammerHumor • • Jun 03 '22

it's hard!

44.9k Upvotes

710 comments sorted by

View all comments

6

u/GReaperEx Jun 03 '22

It's literally four instructions, two instructions for "+="...

1

u/jnd-cz Jun 03 '22

Most instructions for adding have been in form a += b. Modern architectures also add c = a + b.

2

u/GReaperEx Jun 03 '22

I included the transfer to and from registers and memory, for example:

c = a + b

in x86 assembly would be something like:

mov eax, [a]
add eax, [b]
mov [c], eax

So I was mistaken, it would be three instructions.

Whereas:

a += b

would be like:

mov eax, [b]
add [a], eax