Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Thomas Koenig Newsgroups: comp.compilers Subject: Re: fledgling assembler programmer Date: Wed, 22 Mar 2023 06:49:31 -0000 (UTC) Organization: news.netcologne.de Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <23-03-003@comp.compilers> References: <23-03-001@comp.compilers> <23-03-002@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="27736"; mail-complaints-to="abuse@iecc.com" Keywords: assembler Posted-Date: 22 Mar 2023 15:06:01 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:3405 gah4 schrieb: > On Tuesday, March 21, 2023 at 2:40:22 PM UTC-7, Alan Beck wrote: > >> I have started to learn Assembler out of an old book. At the risk of stating the blindingly obvious: There is more than one assembler language, each computer architecture has its own (with extensions over time, too). There are also sometimes different syntax variant, for example AT&T vs. Intel. [...] > Compilers today don't write out the generated code in the same way, Quite the opposite. The standard on UNIXy systems is to write out assemblly language to a file, which is then further processed with the actual assembler. Use "-S" to just generate the foo.s file from foo.c. Plus, you can disassemble object files and programs with "objdump -d". > and there aren't so many libraries around to read. Not ones written in assembler. But it is possible to download the source code to many libraries, for example glibc, and then examine what it is compiled to. Another possibility would be to use http://godbolt.org, which shows you assembler generated for different systems with differnt options. To really make sense of it for different architectures you are not familiar with may be difficult, though). Or build clang/LLVM yourself and set different options for the architecture. >And, personally, > 8086 is my least favorite to write assembly code in. I like 6502 even less :-) > Learning C, and thinking about pointers and addresses, is a good start > toward assembly programming. That, I agree with. And it helps a lot to also look at the generated code. [...] > C programming works so well, that there are only a few > things you can't do in C, and so need assembly programs. Bringing it back a bit towards compilers: Reading assembler code is a good way to see where they generate inefficient or (more rarely) incorrect code. In some special cases, writing in assembler can bring benefits of a factor of 2 or even 4 over compiler-generated code, usually when SIMD is involved. Assembler is a bit like Latin: For most people, there is no need to speak or write, but one should be able to read it.