Live data from Hacker News

Programming from the Ground Up [pdf]

download-mirror.savannah.gnu.org

31–40 of 56 posts

Re: Programming from the Ground Up [pdf]

#31

Learning assembly was probably the biggest thing that made computers click in my head. Since then, I've always thought that learning assembly as your first programming language would be a great place to start. Of course, I'm sure this doesn't apply to everyone. In CS you're usually started off with something like C, Java, or Python. But those languages are so HUGE (in comparison) that it can be really overwhelming. M…

I think this is tricky. I was exposed to 8086 assembly having only previously seen a couple flavors of BASIC, and I have to say that it mostly went over my head. It was hard for me to see the bigger picture, the useful functionality that we were painstakingly working toward with our little instructions moving bytes around and taking different paths based on flags. I remember system calls (which are covered early on i…

Assembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today.

Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones.

6809---my favorite 8-bit and it lends itself fairly well towards higher level languages. A nice register set (2 8bit general purpose registers, four 16bit index registers) and a regular instruction set makes it easy to program.

8080 (or Z80)---if you are going to start down the dark side of x86 line, it's probably best to start at the beginning. A mess of registers, most of which are somewhat general purpose but each has a specific use.

68000---a very nice 32-bit architecture with enough regularity to make it easy to write compilers for, with enough instructions to make it fun to write assembly code. 8 32bit data registers, 8 32bit index registers.

VAX---another nice 32-bit architecture with a very regular instruction set. 16 32bit general purpose registers.

MIPS---one of the original RISC architectures that's still in use. Perhaps a bit too spare on instructions. 32 32bit registers.

ARM---Kind of reminds me of a RISCish 68000 with unique features that make it, again, fun to program at the assembly level.

The x86 line is ... baroque due to its history (you can think of it as an overglorified 8080 that gained power over time, much like the MCP in TRON if you think about it) of ossified layers. It's hard to learn because it's almost all exceptions to a non-regular instruction format.

Re: Programming from the Ground Up [pdf]

#32
post #18

Does it make sense to learn x86 assembly now, or is x64 assembly simpler? All the machines I use are x64 and the binaries I generate are 64-bit. (I realize it's a superset, but I suppose I want to learn the smallest useful subset, since it's a big topic...)

Use x64 - the calling convention is simpler and you get more registers. Avoid the exotic instructions.

And just accept that half the registers are named (rax, rbx) and the other half are numbered (r8, r9).

Re: Programming from the Ground Up [pdf]

#33
post #22
post #15

Hah, just today I started to read "Haskell programming from first principles"[1] which also targets non-programmers but builds on lambda calculus instead of assembly. Would anyone actually recommend to a beginner to start learn assembly first? [1] http://haskellbook.com/

If you start with assembly I would suggest not picking x86. I would suggest a RISC or virtual assembly like LLVM. x86 just has too much historic weirdness.

MIPS is a great RISC instruction set to learn and has a ton of good emulators out there too, highly recommended.

Re: Programming from the Ground Up [pdf]

#34
post #18

Does it make sense to learn x86 assembly now, or is x64 assembly simpler? All the machines I use are x64 and the binaries I generate are 64-bit. (I realize it's a superset, but I suppose I want to learn the smallest useful subset, since it's a big topic...)

Use x64 - the calling convention is simpler and you get more registers. Avoid the exotic instructions.

Can anyone recommend the best resource for learning x64 then? I did computer architecture and assembly language 15+ years ago in school but haven't really needed to touch assembly language as a professional programmer.

So I know the basic idea of registers and addressing modes and pipelines and stuff, but nothing specific to any architecture. My goal is basically to be able to write faster C and C++ programs and analyze constructs like the cost of things like smart pointers, virtual dispatch, templates, etc.

Re: Programming from the Ground Up [pdf]

#35
post #31

Earlier quoted context omitted.

I think this is tricky. I was exposed to 8086 assembly having only previously seen a couple flavors of BASIC, and I have to say that it mostly went over my head. It was hard for me to see the bigger picture, the useful functionality that we were painstakingly working toward with our little instructions moving bytes around and taking different paths based on flags. I remember system calls (which are covered early on i…

Assembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today. Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones. 6809---my favorite…

6809 is vastly underrated I think. It is super simple, but also has everything you need to program efficiently. I think if I were to introduce people to assembly langue programming first, I would pick that one. Especially being 8 bit with 16 bit addressing gives you a good segue into byte ordering.

6502 was my first (and only really significant) experience with assembly. It is so minimal as to be awkward at times, but as you say with the huge numbers of emulators and instructional materials around, it's hard to discount it.

Personally, I would skip x86 altogether unless you actually want to do x86 programming ;-). I've never looked at ARM, but your description makes me want to play with it. The added bonus is that it is still relevant today.

Re: Programming from the Ground Up [pdf]

#36
post #31

Earlier quoted context omitted.

I think this is tricky. I was exposed to 8086 assembly having only previously seen a couple flavors of BASIC, and I have to say that it mostly went over my head. It was hard for me to see the bigger picture, the useful functionality that we were painstakingly working toward with our little instructions moving bytes around and taking different paths based on flags. I remember system calls (which are covered early on i…

Assembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today. Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones. 6809---my favorite…

I've been looking to buy "Introduction to 64 Bit Assembly Programming for Linux and OS X: Third Edition - for Linux and OS X". It's an introduction to x84-64 assembly, which I thought makes sense for me to learn, because it is the architecture all my computers use.

You say x86 is not a good choice to learn, but this book purports to make assembly for this architecture accessible. If you stand by your opinion, are there even CPUs readily available that support the alternative architectures you mention?

Also, can anyone recommend this or any other book or learning resource?

Re: Programming from the Ground Up [pdf]

#37
post #15

Hah, just today I started to read "Haskell programming from first principles"[1] which also targets non-programmers but builds on lambda calculus instead of assembly. Would anyone actually recommend to a beginner to start learn assembly first? [1] http://haskellbook.com/

>Would anyone actually recommend to a beginner to start learn assembly first? Yes, if you can find a good book about it. Assembler isn't particularly difficult, but the information teaching it is rather hard. Right now, the lowest-level language I know of with a really good beginner book is C, and it's this book: http://smile.amazon.com/Absolute-Beginners-Guide-C-2nd/dp/06...

If you have a Safari subscription: https://www.safaribooksonline.com/library/view/c-programming...

Re: Programming from the Ground Up [pdf]

#38
post #31

Earlier quoted context omitted.

I think this is tricky. I was exposed to 8086 assembly having only previously seen a couple flavors of BASIC, and I have to say that it mostly went over my head. It was hard for me to see the bigger picture, the useful functionality that we were painstakingly working toward with our little instructions moving bytes around and taking different paths based on flags. I remember system calls (which are covered early on i…

Assembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today. Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones. 6809---my favorite…

I'm not sure it's fair to group x86 with x86_64 - the latter is much more pleasant (or less unpleasant). It certainly is a huge instruction set, and if you really want to know the ins and out, it's going to be a long journey. But for playing around, it's actually kind of fun IMNHO. I don't think 32 bit x86 really qualifies as fun. Maybe fun, as in trying to solve a complicated murder mystery fun, but not so much as in playing with water colours fun.

Re: Programming from the Ground Up [pdf]

#39
post #36
post #31

Earlier quoted context omitted.

Assembly was my second language (BASIC being my first), but it was not the x86 line I learned first (it was my second assembly language). I can name half a dozen architectures that are probably better for learning than the x86, some of them relevant today. Probably in order: 6502---not my favorite, but tons of material and emulators exist. The most popular 8 bit CPU and one of the most simple ones. 6809---my favorite…

I've been looking to buy "Introduction to 64 Bit Assembly Programming for Linux and OS X: Third Edition - for Linux and OS X". It's an introduction to x84-64 assembly, which I thought makes sense for me to learn, because it is the architecture all my computers use. You say x86 is not a good choice to learn, but this book purports to make assembly for this architecture accessible. If you stand by your opinion, are the…

Source code etc on the book homepage for those interested:

http://rayseyfarth.com/asm/index.html

Re: Programming from the Ground Up [pdf]

#40
post #15

Hah, just today I started to read "Haskell programming from first principles"[1] which also targets non-programmers but builds on lambda calculus instead of assembly. Would anyone actually recommend to a beginner to start learn assembly first? [1] http://haskellbook.com/

>Would anyone actually recommend to a beginner to start learn assembly first? Yes, if you can find a good book about it. Assembler isn't particularly difficult, but the information teaching it is rather hard. Right now, the lowest-level language I know of with a really good beginner book is C, and it's this book: http://smile.amazon.com/Absolute-Beginners-Guide-C-2nd/dp/06...

Out of curiosity, have you looked at the 3rd edition?

http://www.amazon.com/Programming-Absolute-Beginners-Guide-3...

Post reply on HN