[HN Gopher] The Art of Assembly Language Programming (1996)
___________________________________________________________________
The Art of Assembly Language Programming (1996)
Author : userbinator
Score : 86 points
Date : 2022-03-06 08:14 UTC (14 hours ago)
(HTM) web link (www.phatcode.net)
(TXT) w3m dump (www.phatcode.net)
| bch wrote:
| Related(?) I'm looking for recommendations for a good
| intro/reference to the intel arch wrt operations and registers,
| esp wrt Unix conventions (if unix differs from (eg) Windows wrt
| creating a process or pushing/popping stack...)
| canMarsHaveLife wrote:
| Can Assembly be considered a programming language? Isn't is just
| a language for... assembling?
| shadowofneptune wrote:
| This is true only for the most simple assemblers. In practice,
| each assembler comes with its own distinct set of features.
|
| Microsoft Macro Assembler for example offers:
|
| * Records/structs, bitfields
|
| * Typed labels/pointers. Intel in particular introduced this
| feature.
|
| * Procedure blocks which allow locally scoped labels within
| them
|
| * The automatic allocation of local variables onto the stack.
|
| * if/then blocks, for loop blocks
|
| * Memory model directives
|
| * Macros, equates, etc.
|
| Other assemblers like NASM omit some of these features, as
| introducing versions of these features which are completely
| compatible with the MASM ones would be difficult. For example,
| NASM allows MASM-like procedure blocks, but they are not block-
| scoped. They're just a notation for the programmer.
| ghaff wrote:
| Sure. It's less abstracted than anything except for machine
| code but that doesn't make it not a language.
| pavlov wrote:
| Most assemblers have macros and other directives that give you
| some level of higher-order control than just writing machine
| code.
| jazzyjackson wrote:
| One might say it is the only programming language, everything
| else is just macro expansion, converting pseudo-english
| mnemonics into machine instruction.
|
| Snark aside, yes, people program entire operating systems and
| programs and games in assembly. Famously, Rollercoaster Tycoon
| was written entirely in assembly.
| mdp2021 wrote:
| Yes, certainly Assembly is a programming language. If you could
| not express your program in it, all of our discipline would
| fall (if a script defined a process and what it translates to
| did not...). "Things work" because /other/ languages translate
| into it: that is the chief language, named ("symbolic") reading
| of machine code. It has conditionals and loops, it has logic
| and arithmetic operators, it has "exactly" what the processor
| has: it is the most precise definition of the program, how can
| it not be a programming language?
|
| You are probably thinking of the assembling process of pieces
| of machine code - through the assembler. But the assembler also
| translates symbolics into machine code, in the goal to join the
| different pieces of code and data - so it's more than just
| concatenating. To define the memory addresses to be encoded for
| jumps, for example, you must have defined them - so, in the
| assembler (e.g. concatenating subroutines) you imply the
| assembly (i.e. naming pieces of machine code, symbolically
| treated).
| shadowofneptune wrote:
| A very useful book for MS-DOS programming. MASM is also an
| excellent assembler, even in early versions. The proc/endp blocks
| for instance make reading a subroutine much easier. Does anyone
| know of a similar book for AMD64 assembly language programming?
| ranger207 wrote:
| The author (Randall Hyde) just released an x64 assembly book in
| October: https://nostarch.com/art-64-bit-assembly
| shadowofneptune wrote:
| Thanks, this looks great!
| ghaff wrote:
| Another interesting book--at least for historical context--is
| Michael Abrash's Zen of Assembly Language Programming. A lot of
| the optimizations are a good read if you're into that sort of
| thing but there's not a lot of practical interest for today.
| (Abrash in fact never wrote the Volume 2 he was planning to.)
| pan69 wrote:
| Which is also hosted on Phatcode:
|
| http://www.phatcode.net/res/224/files/html/index.html
| djmips wrote:
| People interested in this might also enjoy 'Inner Loops' (1997),
| an excellent book that covers optimizing x86 at that time but is
| instructive in general and the concepts are still applicable
| today.
|
| https://www.amazon.com/Inner-Loops-Sourcebook-Software-Devel...
| krallja wrote:
| Why does it call the processors the 886, 8286, 8386?
| galangalalgol wrote:
| That is a good question, maybe they had only heard it spoken,
| so they thought it was 83 86 instead of 8086,80386 etc.
| shadowofneptune wrote:
| No, the book introduces these serial numbers as idealized
| versions of the processors. It allows the reader, who is
| treated as a beginner to processors, to develop a mental
| model of them without any complications. The edge cases,
| pitfalls, and issues of the true processors are revealed over
| the course of the book.
|
| Not sure about the merits of calling the ideal processors by
| special names.
| agumonkey wrote:
| In France, 80386 was often read 80-3-86 (same for 80-2-86).
| And eigty SPC three === eighty three.
| makapuf wrote:
| Never heard of it that way in france with my friends, for
| me it was always 80-86, 80-88 or just 386 or 286 (or 80-286
| if you wanted to sound technical).
| agumonkey wrote:
| well well well .. I think I really heard it that way. Not
| that it means a lot anyway.
| djur wrote:
| They're simplified hypothetical variants of the x86 processors,
| according to one chapter.
| krallja wrote:
| Ah, I see it in Section 3.3: http://www.phatcode.net/res/223/
| files/html/Chapter_3/CH03-3....
| pan69 wrote:
| This version of the book is good! Great for beginners and experts
| alike. However, in later versions of this book (one of which I
| have on my bookshelf), the author uses High Level Assembler (HLA)
| which is according to the back cover of the book; "a
| revolutionary tool...". It is basically a proprietary compiler
| that uses a syntax that is "interesting" but not portable to the
| rest of the world of x86 assembler.
|
| So, if you buy the book (like I did), please be aware of this.
| userbinator wrote:
| I agree. HLA syntax can best be described as "if someone who
| knows only C decided to make an Asm syntax". I remember much
| flamewars on newsgroups about it.
|
| GNU GAS syntax is roughly as repugnant, but became popular only
| because of GNU/Linux. Deviating from the official docs has
| caused much divisiveness and confusion.
| pjmlp wrote:
| TI used to have an Assembly for a DSP that was like C written
| in SSA form.
|
| No idea how it was called.
|
| Fully agree with GAS syntax being a pain.
| vbezhenar wrote:
| I'm reading RP2040 Assembly Language Programming book right now.
| It's very interesting introduction to the assembly language. And
| using assembly for microcontrollers seems very fitting to me, at
| least for hobbyist level.
| phendrenad2 wrote:
| What's a good modern book for modern assembly languges?
| imiric wrote:
| Would this still be relevant/approachable for a beginner coming
| from higher level languages, or is there a more modern resource
| for learning assembly that would be better suited?
|
| I guess most of it is still relevant, but I'd rather not deal
| with DOS to follow along, and would prefer working on Linux.
|
| Also, the x86 instruction set seems daunting to pick up for a
| beginner. Would it be better learning on a 4/8-bit or toy machine
| first?
| Gene_Parmesan wrote:
| I found the book "Programming From the Ground Up" to be a
| pretty good intro to programming in x86, and importantly, more
| recent than this text. I had to do just a tiny bit of research
| to find out how to get my shell to emulate 32 bit mode, since
| it's x86 and not x86-64, but it is in fact Linux based. I
| imagine it'd be an order of magnitude easier than trying to
| figure out a DOS setup.
|
| The full x86 ISA is daunting, I'm sure, but for a beginner
| looking to get a sense of what asm is, you don't engage with
| the entirety of the ISA. The PFTGU text is great specifically
| because it assumes an audience of beginners who want to learn
| the basics of how asm operates to enable core programming
| concepts. It's not aiming to be exhaustive like the linked
| text.
|
| Edit: And also importantly, it's also (legitimately) available
| for free online.
| Shosty123 wrote:
| There's a new version of that book. Same author:
|
| https://link.springer.com/book/10.1007/978-1-4842-7437-8
| pedrolins wrote:
| I'm not an assembly programmer, but I've learned assembly as
| part of introductory CS courses (computer architecture classes)
| and the approachable alternative you're looking for is the
| assembly language of a RISC architecture such as ARM, MIPS, or
| RISC-V. I'd recommend learning the latter because of how
| approachable it is.
| userbinator wrote:
| If you want to start small, Z80 might be a good point, but it
| seems opposed to your not wanting to start with DOS; a small VM
| will be very useful, and with Asm you'll soon discover that
| even 64k is plenty to play with.
| xupybd wrote:
| The 8051 microcontroller is pretty easy to learn. I'd recommend
| that as a starter on assembly. But if you want to end up
| playing with x86 why not start there.
___________________________________________________________________
(page generated 2022-03-06 23:00 UTC)