I suspect that most coders could learn to coal mine. Probably wouldn't like it very much though.
Need Help Understanding Assembly Language
Moderator: Global Moderator
Re: Need Help Understanding Assembly Language
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
THANK YOU. You have been of tremendous help. Check this out!
Not quite a perfect score, but pretty close! I got some marks docked because I didn't provide an accompanying explanation to the graph I generated that detailed the performance improvement resulting from loop unrolling.
Still happy with the result. Thanks!
MB
Ruby on Rails rules all
www.allterraininvesting.com
Ruby on Rails rules all
www.allterraininvesting.com
Re: Need Help Understanding Assembly Language
Assembly language brings back bad memories!
Re: Need Help Understanding Assembly Language
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.
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.
MB
Ruby on Rails rules all
www.allterraininvesting.com
Ruby on Rails rules all
www.allterraininvesting.com
Re: Need Help Understanding Assembly Language
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.
This will probably be a waste of time for you in the future, as it is now, unless we somehow get to the point again where that matters but it was good mental discipline in thinking how computers work. At least IMHO.
- Mark Leavy
- Executive Member
- Posts: 1950
- Joined: Thu Mar 01, 2012 10:20 pm
- Location: US Citizen, Permanent Traveler
Re: Need Help Understanding Assembly Language
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.
Congrats. There is money in it. Maybe not in assembly, per se. But whatever gene allows you to grasp cache and registers and pointers will take you far.
Bonne Chance!