LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-13-2017, 02:17 PM   #1
patrick295767
Member
 
Registered: Feb 2006
Distribution: FreeBSD, Linux, Slackware, LFS, Gparted
Posts: 660

Rep: Reputation: 137Reputation: 137
Is anyone still using assembly language?


Hello,

Since Assembly language is today being less and less used, I would like to start this thread about Assembly.

Is there any interests today in learning Assembly language?

Best regards
Patrick
 
Old 08-13-2017, 08:42 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,240
Blog Entries: 4

Rep: Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263
For the most part, "no."

Hand-coded assembly language is only found, in the Linux kernel, in the so-called "trampoline" modules that are used to initiate the boot process. (For instance, tossing a freshly-reset x86 microprocessor from real to protected mode, and "bouncing it off the trampoline" on a one-way trip into the Linux kernel startup-code.) Otherwise it is found, as asm{...} blocks within "C" source files, only in the architecture-specific /arch directory.

This is typical.

Modern microprocessors really aren't designed anymore to accept hand-made assembly code: they're designed to accept the output of compilers, and microprocessor designers work closely with the architects of those compilers (and, produce compilers of their own) to cause compilers to generate optimal machine-code sequences for different architectures and models.

If you want the very best machine-code to do something, write a small "C" program. Seriously. You simply won't come up with anything better, doing it by hand.

Last edited by sundialsvcs; 08-13-2017 at 08:45 PM.
 
1 members found this post helpful.
Old 08-14-2017, 06:48 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,357
Blog Entries: 13

Rep: Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411
Using it right now on a 4-bit processor.
 
Old 08-14-2017, 08:56 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,240
Blog Entries: 4

Rep: Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263
Quote:
Originally Posted by rtmistler View Post
Using it right now on a 4-bit processor.
I never had an Intel 4004 ...
 
Old 08-14-2017, 09:29 AM   #5
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
If you are into reading dumps you will be??
That is where I learned assembler - solving dumps at 3 O'Clock in the morning.
 
Old 08-14-2017, 10:56 AM   #6
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 5,791

Rep: Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153Reputation: 2153
These people are still using it!
http://kolibrios.org/en/
 
1 members found this post helpful.
Old 08-14-2017, 12:31 PM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by sundialsvcs View Post
Modern microprocessors really aren't designed anymore to accept hand-made assembly code: they're designed to accept the output of compilers, and microprocessor designers work closely with the architects of those compilers (and, produce compilers of their own) to cause compilers to generate optimal machine-code sequences for different architectures and models.
Can you provide a link backing this up? As far as I'm aware ASM (machine code) is the only language a processor understands. All the High Level Coders are compiled into ASM so that they can run on the processors. Cross compilers are so that you can move the code from one processor type to another but is should still be ASM code that the processor is getting.

If I'm wrong then I stand corrected.
 
Old 08-14-2017, 01:50 PM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010
ASM is a mnemonic for remembering binary instructions. It's one instruction per mnemonic (per line). Processors run binary code, not ASM. All programming languages compile to binary before they can run on a processor.

Assembly is still used a lot. But, unlike C, assembly is bit different for every processor architecture, and it's different between Microsoft and Linux. The compilers are also different. You would think either the language or the compiler could be standardized, but no.

You don't need assembly on PCs much anymore, because of processing power. But on small systems, such as clocks, digital watches, locks, sensors, electronic instrumentation, vehicle control and sensors, aircraft navigation, smart cards; speed mission or time critical application such as nuclear weapons and guidance systems, industrial process and control, sensor integration; and security applications.

I have a digital multimeter. It must process 50,000 readings per second in order to fully exploit the onboard A/D converter, which converts the analog reading from the internal voltage sensors to a digital representation that can be converted to a digital readout.

The device is actually a specialized computer that measures electrical signals and displays the correct value. It has memory and a processor. Because it must execute code as fast as possible, it's firmware must be written in assembly.

But assembly is tied to the processor architecture. So, learning assembly for one processor type does not completely carry over to another processor. Some aspects of microprocessors are universal, such as basic programming constructs like stacks, registers, jumps, skips, branches, etc.

So, if you're talking about PCs, most programmers don't use assembly anymore.
 
1 members found this post helpful.
Old 08-14-2017, 01:52 PM   #9
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
Assembler is often synonymous with machine code, but not always. It is still a general language and needs translating (Assembling)for a specific machine. In most cases it is pretty much a one for one translation, but it only if the proccessor itelf has a fairly complex instruction set. Many risc machines need several instructions for each assembler statememnt.
Quote:
and it's different between Microsoft and Linux.
On the same machine there will be no difference. MS code and Linux code that perform the same action will use pretty much the same assembler at individual code statement level.

Last edited by dave@burn-it.co.uk; 08-14-2017 at 02:00 PM.
 
Old 08-14-2017, 02:31 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 20,995

Rep: Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406Reputation: 3406
MenuetOS is the current poster child for ASM. All the tools exist and many folks still can use it.
 
Old 08-14-2017, 07:06 PM   #11
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010
Quote:
Originally Posted by dave@burn-it.co.uk View Post
On the same machine there will be no difference. MS code and Linux code that perform the same action will use pretty much the same assembler at individual code statement level.
But the assembler programs are different.
 
Old 08-14-2017, 07:38 PM   #12
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 10,053

Rep: Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624Reputation: 4624
Quote:
Originally Posted by patrick295767 View Post
Since Assembly language is today being less and less used, I would like to start this thread about Assembly.

Is there any interests today in learning Assembly language?
If the question is learn, and not use? Yes.
 
Old 08-15-2017, 02:47 AM   #13
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
Quote:
But the assembler programs are different.
They won't be very different at all.

It is like translating a simple sentence in two languages into a third language. If the original sentences mean the same thing then they will both translate into the same output in the third language.

A request for a cup of tea, for instance in English and German. will both translate to the same in French.

Last edited by dave@burn-it.co.uk; 08-15-2017 at 02:56 AM.
 
Old 08-15-2017, 11:18 AM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,240
Blog Entries: 4

Rep: Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263
Quote:
Originally Posted by lazydog View Post
Can you provide a link backing this up? As far as I'm aware ASM (machine code) is the only language a processor understands. All the High Level Coders are compiled into ASM so that they can run on the processors. Cross compilers are so that you can move the code from one processor type to another but is should still be ASM code that the processor is getting.

If I'm wrong then I stand corrected.
As others have said, the microprocessor executes binary instructions – machine code. One way to express those instructions and thus to construct a computer program is "purely by-hand," using an assembler to specify those instructions one-at-a-time.

It's an arcane art, but most of us have done it, and it is valuable to know how to do it – to know what the (conceptual) architecture of the target machine looks like. Today, however, it isn't a practical development strategy in most cases. (Even for many microcontrollers and embedded systems.)

Modern microprocessors are very complex beasts which feature pipelines and internal paralleism which, if exploited properly, can greatly increase execution speed. Creating appropriate instruction sequences to achieve this is quite difficult, however, if attempted "purely by-hand." On the other hand, an optimizing compiler can do so quite readily.

Microprocessor manufacturers engineer their systems to accept the output of optimizing compilers, and they work with compiler writers to develop (and, they put into their own compiler) optimization algorithms that will generate the best instruction sequences in a particular case for a particular processor model. (You can, if you so choose, tell gcc exactly what model, as well as family, of microprocessor you wish to produce machine-code for, and the output will be dovetailed to that chip's design quirks.)

If you study a "disassembly" of the output of a modern compiler, and compare it to the source, you'll find that it is probably considerably different: parts of the logic have been moved around, you encounter arcane instructions that you've never heard of before, several instructions were generated where only one will do, and so on. There's a lot of voodoo going on! And yet, this is what an optimizing compiler is designed to do, and this is what a microprocessor today is designed to accept.

Even within the /arch directory of the Linux kernel, most of the assembly-level code is (selected portions of) specific subroutines. Few of those subroutines consist entirely of assembly code. Only the "trampoline" is likely to consist entirely of assembly code. Basically, assembly is used "only when there is by definition no other choice." The vast majority of the kernel is written in a high-level language. And this is the modern-day role of assembly language programming in most use-cases, but, not all.

Last edited by sundialsvcs; 08-15-2017 at 11:28 AM.
 
1 members found this post helpful.
Old 08-15-2017, 11:59 AM   #15
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,357
Blog Entries: 13

Rep: Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411
A colleague of mine long ago uttered the statements that all a computer is capable of doing are (1) read-modify-write, and (2) test-and-conditional-branch.

They were absolutely correct. If you take the microcode, all it is, is a bunch of different instruction which are capable of manipulating data, between memory (however it is referenced - direct, indirect, register, pointer, etc) and other memory, and then making a decision to branch or not branch based on test criteria. Similarly when you consider interrupts they were merely prioritized instructions of the same nature, governed by the set of rules we identify IRQ processing with.

Higher level languages do wonderful things, however understanding exactly what those languages do is sometimes very important.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] A problem. When using assembly language to call the C language function mirage1993 Programming 3 10-03-2014 08:15 AM
Assembly Language ashish anand Programming 9 10-18-2011 10:53 PM
assembly language ramorous24 Programming 4 08-21-2011 11:31 PM
Is Assembly Language considered a Structured Language? theKbStockpiler Programming 4 01-30-2011 09:09 AM
Assembly Language syntax ashlesha Linux - Newbie 4 06-30-2006 04:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration