Who Knows Assembly Language?
Assembly language is sometimes abbreviated to and called “ASM”. There are very few programmers today who learn Assembly language over another language as their first language. One of these reasons being that it is a low-level programming language.
Assembly language has an interesting history and was very important to the development of computers as it helped coders use something other than machine code which is just 0 and 1. This type of coding would take a long time and tire out a lot of programmers. It has a lot of benefits and a lot of negatives just like any language. It has an intensive history dating back all the way back to 1947. It is used by a lot of programmers even today and will be interesting doing a deep dive into the language.
You can learn a lot more about assembly language by understanding computer architecture or just by doing google searches and YouTube videos and learn on your own.
History:
The inventor of the first assembler is thought to be David J Wheeler who was a part of the team working on the “Electronic Delay Storage Automatic Computer”. But the person to first create the language is Kathleen Booth who wrote the first language as she started in 1947. Yes a woman played a key role in this! Yay! I can’t imagine how many women were in computer science in 1947. Never less, The first assembler ran on May 9, 1949, a day I am sure David Wheeler and his team will never forget and still remember to this day. It was made as a low language programming language. A low-level programming language is harder for people because it is machine friendly and is harder to understand, memorize and debug. Low-level languages are very abstract and most of the time don’t need an interpreter, unlike high-language languages. Examples of low-level programming languages would be assembly and machine language.
High Level Programming
High-level programming on the other hand is easier for people to understand and uses interpreters most of the time. Popular high-level code is Python, C, C++, and Java. Remember, assembly was the first step in turning those numbers into words and assembly was the first step in moving to something a lot easier for people to program.
Platform:
Assembly language unlike other high-level languages is platform-dependent. This means it will not work on all operating systems, so it is very hard to use assembly language on multiple devices. It brings up the concern of using something like assembly language on Microsoft windows and trying to also use it on a Mac. Hence, it does limit the use of the language a lot.
The people who still use assembly are who people are operating systems and compiler programmers. Languages that work on multiple operating systems these are most high-level languages like Java, Python, etc. Assembly language is also platform dependent which means it can be affected by the system software directly unlike other languages.
Benefits:
One of the many benefits of assembly language is that it works virtually with the hardware and allows the programmer to take full control of the system. Some of the other benefits of assembly language is that it runs a lot faster than a high-level language. It also is a very critical language to learn for a lot of people who work on operating systems and programmers who work on compilers. Surprisingly contradicting the look of the syntax and length of the syntax it is actually a lot more memory efficient compared other languages. One of the many benefits that people forget about is that assembly language is not a compiler language and doesn’t need a compiler. Also, learning assembly helps you understand how a computers function. More importantly, makes one appreciate languages like C.
Disadvantages:
Some of the Disadvantages would be the syntax is a lot harder to remember than a a typical programming language. Also, it takes a lot of time and effort to the code. A couple of other disadvantages of Assembly language would be it takes a lot longer to write and code as you will see below. Along with the increase of syntax and time, assembly comes a lot more bugs and problems. It also can be very hard to identify errors in your code unlike, Python and Java.
Examples of Code:
An example, of some code in assembly language, would be:
global _main
extern _printf
section .text
_main:
push message
call _printf
add esp, 4
ret
message:
db ‘Hello, World!’, 10, 0
This would print out the text “Hello World!”. This would be very scary for someone new to programming. I do recognize some similarities between the language like the use of quotation marks around strings. Overall, the language is a lot of code and syntax to output something very simple like “Hello World. In contrast, to print this in Python you would simply print the code:
print (“Hello World”)
Someone used to high-level programming might not be used to a language like Assembly because it is very detailed.
If-Else Statement:
A if- statement evaluates if a statement is true and if the statement is true it will produce output and if it not it will output the value of the else statement. In Python, this takes very little code. Example of an if statement in python would be:
If ax < bx:
X=-1
Else:
X=1
Now that code is pretty basic and very readable to even people who don’t know any code. Someone with little to no knowledge of coding can understand that statement. Now for an example of how this code would translate to assembly code would look like this:
cmp ax, bxjl Lessmov word [X], 1jmp BothLess:mov word [X], -1Both:
The assembly code is a lot more complicated and is a lot closer to machine code(1 and 0). Machine code is what the CPU can understand. We can see it does not make sense, but the assembly has words like “mov”, “il”, and “cmp” which are not real words in English.
While Loop:
Another example, of basic code, is a while loop function that is used by coders. An example of a while loop in Python is:
While x == 1:
Print (‘Do Something’)
This is an example of a simple while loop in python and only takes two lines. In comparison when we look at assembly code it is a lot more confusing to understand. An example of assembly code when using a while loop is:
jmp loop1 ; Jump to condition firstcloop1 nop ; Execute the content of the looploop1 cmp ax,1 ; Check the conditionje cloop1 ; Jump to content of the loop if met
For Loop:
An example of a loop in python would be:
For x in x++:
Print (‘Do something’)
An example of this same exact code in assembly code would be:
xor cx,cx ; cx-register is the counter, set to 0loop1 nop ; Whatever you want to do goes here, should not change cxinc cx ; Incrementcmp cx,3 ; Compare cx to the limitjle loop1 ; Loop while less or equal
Trends:
One thing that is pretty hard for people to believe is the way that assembly language is trending.
The Tiobe index is a widely recognized and reliable index when it comes to showing the change in languages over time. It has consistently been in the top 10 languages in the past year and is the top low-programming language on the index.
What is really surprising is that assembly code is ranked higher than languages like ruby and swift ! The reason people learning assembly is due to very small devices that only can run assembly. For example, toothbrushes and coffee machines that run assembly code. Despite it being a very old language as well it is still being used today for everything from operating systems to direct hardware manipulation.
Takeaway on Assembly
Learning assembly language can be of great benefit as it provides a clearer picture as to how hardware works. More importantly, though its harder to grasp it can be efficient when it comes to minimal usage of memory or processing power.