Need Help Understanding Assembly Language

Other discussions not related to the Permanent Portfolio

Moderator: Global Moderator

pp4me
Executive Member
Executive Member
Posts: 1190
Joined: Wed Apr 29, 2020 4:12 pm

Re: Need Help Understanding Assembly Language

Post by pp4me »

vnatale wrote: Thu Nov 12, 2020 9:30 pm
pp4me wrote: Thu Nov 12, 2020 2:09 pm Joe Biden told the coal miner's in Pennsylvania that they could "learn to code" if he put them out of work. How hard can it be if even a coal miner can do it?


!!!!!!!!!!!!!


Does the reverse hold true? All coders can coal mine?

Vinny
I suspect that most coders could learn to coal mine. Probably wouldn't like it very much though.
User avatar
Smith1776
Executive Member
Executive Member
Posts: 3532
Joined: Fri Apr 21, 2017 6:01 pm

Re: Need Help Understanding Assembly Language

Post by Smith1776 »

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.

Imageobjectives for exercise program


THANK YOU. You have been of tremendous help. Check this out!


programming assignment.png
programming assignment.png (273.28 KiB) Viewed 1428 times


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
ppnewbie
Executive Member
Executive Member
Posts: 865
Joined: Fri May 03, 2019 6:04 pm

Re: Need Help Understanding Assembly Language

Post by ppnewbie »

Assembly language brings back bad memories!
User avatar
Smith1776
Executive Member
Executive Member
Posts: 3532
Joined: Fri Apr 21, 2017 6:01 pm

Re: Need Help Understanding Assembly Language

Post by Smith1776 »

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.
MB
Ruby on Rails rules all
www.allterraininvesting.com
pp4me
Executive Member
Executive Member
Posts: 1190
Joined: Wed Apr 29, 2020 4:12 pm

Re: Need Help Understanding Assembly Language

Post by pp4me »

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.
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.

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.
User avatar
Mark Leavy
Executive Member
Executive Member
Posts: 1950
Joined: Thu Mar 01, 2012 10:20 pm
Location: US Citizen, Permanent Traveler

Re: Need Help Understanding Assembly Language

Post by Mark Leavy »

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.
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!
Post Reply