Re: Need Help Understanding Assembly Language
Posted: Fri Nov 13, 2020 3:42 pm
Permanent Portfolio Forum
https://www.gyroscopicinvesting.com/forum/
https://www.gyroscopicinvesting.com/forum/viewtopic.php?t=11497
pp4me wrote: ↑Thu Nov 12, 2020 1:07 pm Good work.
Just a quick observation for now.
Thought they might all be the same but it appears you have 2 variations in the assembly code (I used DiffMerge to compare side by side).
The goto and do-while loops are identical
The for and while loops are identical except for some label names that don't matter.
As for the C code, I think it's more common to write "answer += i" than "answer = answer + i" unless things have changed in the last 5 years. With any modern optimizing compiler I doubt it would make any difference but it will save you some typing. Otherwise looks pretty good to me.
When all is said and done the only differences you need to explain are highlighted below. The for/while is on the left and the goto/do-while on the right.
objectives for exercise program
When I first started programming we had to look up the execution times of the machine language instructions to make sure we chose the most efficient ones.Smith1776 wrote: ↑Wed Feb 17, 2021 3:01 pm I just wanted to circle back to this thread and say that assembly has started to really sink in and make sense. It's that intermediary between pure binary and higher level languages. Honestly, I'm beginning to really love it. I can see now how the C programming language in particular maps directly down to the assembly level. You can intuitively see how C code will look within the assembly context.
A lot of this has given me a lot more appreciation for how computers work under the hood. My laptop is much less of an arcane black box now. Along with assembly I've learned a lot of techniques for optimizing code so that it's cache friendly, has good spatial locality, and has good temporal locality. One can even see how seemingly minor changes in code can turn a sprightly algorithm into a slow one.
You're one of the few, Smith. I think it's genetic. You either get it or you don't. Nothing you can do about it.Smith1776 wrote: ↑Wed Feb 17, 2021 3:01 pm I just wanted to circle back to this thread and say that assembly has started to really sink in and make sense. It's that intermediary between pure binary and higher level languages. Honestly, I'm beginning to really love it. I can see now how the C programming language in particular maps directly down to the assembly level. You can intuitively see how C code will look within the assembly context.
A lot of this has given me a lot more appreciation for how computers work under the hood. My laptop is much less of an arcane black box now. Along with assembly I've learned a lot of techniques for optimizing code so that it's cache friendly, has good spatial locality, and has good temporal locality. One can even see how seemingly minor changes in code can turn a sprightly algorithm into a slow one.