in reply to Re: Assembly language
in thread Assembly language
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Assembly language
by stevieb (Canon) on Dec 14, 2019 at 18:35 UTC | |
It's definitely fundamental. Assembly is machine code, the lowest level code a computer processor can understand directly. It's the foundation of all high(er) level programming languages, including scripting languages such as Perl. | [reply] |
by davido (Cardinal) on Dec 15, 2019 at 05:37 UTC | |
Assembly is not machine code. It doesn't help newcomers to this stuff to blur the distinction. Assembly is a symbolic language that has a very close to 1:1 mapping with machine instructions, though not exactly 1:1. But it provides named constants, named registers, named machine instructions, labels, memory addressing strategies, and a lot more that are not native to machine code. Assembly language is a human readable language, and cannot be run natively on the CPU any more than native machine instructions can be read by a human (without at very least first converting them to an unambiguous printable encoding such as hex -- but even then, good luck with that for anything that isn't super trivial. Assembly is useful as a teaching aid, or for programming very small systems that don't have C compilers available. It might be useful for hand-optimizing tight sections of C code. But on modern computer hardware, the need for hand-optimizing code at the Assembly level is quickly vanishing. I enjoyed learning 6502 Assembly. On the one hand it was a big pain. But on the other, it was fascinating. But even in the 80s, it was just about the slowest way to get anything done. I think that if someone wants to learn assembly, they should do it. They'll gain an appreciation for the fundamentals. But nobody's going to write a REST microservice in it. ;) To the OP: The days of being able to just input raw machine instructions for the CPU to execute ended with computers with switchboard face panels like the Altair 8800. And even then, it was hard enough that people would mostly just key in a short bootloader, and use it to pull down the actual program, written in a less tedious way. Nowadays, when you're typing at the Linux command line you are typing within a piece of software (the shell), and it doesn't expose the CPU directly, at least not easily. The shell doesn't understand 011101011101000101001010100001010111110101010000000101010101011011010110101. Dave | [reply] |
by LanX (Saint) on Dec 16, 2019 at 17:30 UTC | |
Yes and apparently there are at least two dialects for 8086 assembly, one from AT&T and the other from Microsoft. Apparently they are mapping different mnemonics to same machine code and using different syntax for addressing modes. Furthermore is assembly programming only fun if there is a macro language included. Back in the time of my 68000 jobs this made a lot of meta stuff non portable between different assemblers. > any more than native machine instructions can be read by a human Friend of mine claims that he can still read Z80 machine code in hex format.
Cheers Rolf
| [reply] |
|
Re^3: Assembly language
by harangzsolt33 (Deacon) on Dec 14, 2019 at 19:03 UTC | |
My understanding is that assembly language is a more simpler, fundamental language than languages like Perl and Javascript. Is that right? How could I write a program in assembly language? Yes, assembly is the most fundamental level. To write assembly programs, you need a compiler ((correction: you need an assembler)) that translates your human readable text file into binary code that runs on either DOS, Windows, Linux, OSX, or the boot sector. You need to pick a platform first. Each of these environments requires your program to work slightly differently, so you can't just write an assembly program that will work on all computers and all platforms. That's what I meant earlier when I said it is machine specific and OS specific. There are different processors. 64-bit processors use different assembly instructions than 32-bit processors. Cell phones use different instructions. There are various processors, and you have to decide which one you want to study first. I studied the Intel 80386 processor myself, and I wrote programs for DOS and the boot sector. And in order to do that, you have to download a program called A86.COM. To write Windows assembly programs, you can download FASM.EXE or something similar. In Linux, I am not sure what you would use. I encourage you to ask more questions. Do more research.. Until then, here is a simple assembly program which I wrote for DOS (16-bit):
Now, here is the same program in Perl. See, how shorter and simpler this is?:
| [reply] [d/l] [select] |
by marto (Cardinal) on Dec 14, 2019 at 19:09 UTC | |
"you need a compiler" not true, you need an assembler, not a compiler, this isn't how this works. ”Cell phones use different instructions." That would depend on the CPU they used. Few are x86, most are ARM. | [reply] |
by SkinBlues (Acolyte) on Dec 14, 2019 at 19:28 UTC | |
| [reply] |
by karlgoethebier (Abbot) on Dec 15, 2019 at 13:19 UTC | |
You may take a look at Xcode - if you really want to go over this bridge. A more comfortable alternative (smaller instruction set bla...) might be to buy an Arduino for little money and check out Atmel‘s Studio 7 - because the Arduino IDE accepts only this C/C++ subset as far as i remember. Unfortunately Studio 7 runs only on Windows. Therefore you will also need something like Parallels. Good luck and best regards, Karl Update: Lost + Found 😎 «The Crux of the Biscuit is the Apostrophe» perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help | [reply] [d/l] |
by GrandFather (Saint) on Dec 16, 2019 at 05:33 UTC | |
by karlgoethebier (Abbot) on Dec 16, 2019 at 13:52 UTC | |
by harangzsolt33 (Deacon) on Dec 14, 2019 at 19:38 UTC | |
It's fundamental in the sense that assembly doesn't translate into anything else. It is the lowest level machine language to give instructions to a processor. All the major tasks are broken down into the tiniest instructions. And they cannot be broken down into smaller pieces. It's like atoms. Atoms are the most fundamental building blocks of the world. And if you want to mix chemicals and do stuff, you probably need a science lab! But you might say, if they are the most fundamental, then why do I need a sciance lab? Why can't I just mix something in my backyard or in my hand? You can, but most chemical engineers don't do it that way. However, if you want to do it your way, in DOS, there's a program for that. It's called DEBUG.EXE. With this program, you can type your assembly code directly into the memory and run it. But I am not sure if Linux or OSX has a similar program. Most programmers, and I mean 99.99% of people type their assembly program in plain text and save it as a text file and then use an assembler to translate the code to machine language. Then they run the executable and watch it in action. Or they may load a debugger and use it to trace through the program to see how it works. | [reply] |
by haukex (Archbishop) on Dec 14, 2019 at 21:09 UTC | |
by marto (Cardinal) on Dec 14, 2019 at 19:55 UTC | |
by harangzsolt33 (Deacon) on Dec 16, 2019 at 00:25 UTC | |