News for hackers. Stuff that matters.
Re:Some Assembly Required: An approachable introduction to a... by amelius on Tuesday June 28, 2022 @12:59PM (#31910201)
Assembly language is actually simple stuff. You just need to read the datasheet. No difficult type systems to deal with.

In the old days programming assembly language was nasty because one mistake could mean your computer had to be rebooted and you lost your work. Not anymore.

Re:Some Assembly Required: An approachable introduction to a... by weinzierl on Tuesday June 28, 2022 @01:23PM (#31910466)
This is like saying chess is simple stuff because you can learn how the pieces move in five minutes.

If all you want is a basic understanding of how things work, that level is ok. If you want to play/program, it is a completely different story.

I'd even go so far to say: Why do assembly if your goal is not to be better than the compiler, at least in some respect? Beating the compiler, now tell me that it's simple stuff.

Re:Some Assembly Required: An approachable introduction to a... by djmips on Tuesday June 28, 2022 @01:43PM (#31910702)
But chess is approachable because you can learn how the pieces move in five minutes. Contrast that with some German board games where going over the instructions is the first hour and even then you aren't sure if you understand.

Why learn assembly?, well for one, the non-abstract aspect of assembly is less abstract, and arguably easier to understand than even the simplest high level languages. Secondly, learning assembly is also learning how computers work and that paradigm will help you even as you largely work in a high level language.

And beating the compiler isn't as hard as you might think if that becomes necessary some day.

Re:Some Assembly Required: An approachable introduction to a... by galangalalgol on Tuesday June 28, 2022 @03:30PM (#31911985)
I only read assembly these days, not write it. Usually when looking at profiling outputs for my hot path. So knowing assembly is still very valuable when you routinely find your code isn't keeping up with your data, and scaling isn't an option.
Re:Some Assembly Required: An approachable introduction to a... by khalladay on Tuesday June 28, 2022 @07:47PM (#31914603)
Another use case for assembly is reverse engineering, even if you aren't better than the compiler, being able to understand what the compiler spit out is really handy.
Re:Some Assembly Required: An approachable introduction to a... by astrange on Tuesday June 28, 2022 @01:30PM (#31910557)
A compiler’s main virtue is patience, not smarts. That’s because there’s no value in smarts; the systems like Itanium designed to need them turned out to be unusable.
Re:Some Assembly Required: An approachable introduction to a... by wk_end on Tuesday June 28, 2022 @05:14PM (#31913097)
Just read the data sheet!

googles Intel CPU data sheet

Ah, here we go.

https://www.intel.com/content/www/us/en/products/docs/proces...

Just two volumes and 1000 pages of reading. Simple!

Re:Some Assembly Required: An approachable introduction to a... by pid-1 on Tuesday June 28, 2022 @08:48PM (#31915120)
Intel assembly is complex due backwards compatibility and extensions.

I've found working with a simpler, smaller processor can be an absolute joy.

Re:Some Assembly Required: An approachable introduction to a... by ryanjshaw on Tuesday June 28, 2022 @01:43PM (#31910706)
I taught myself x86 assembly from a book as a pre-internet teenager. My first .COM printed exactly what it was supposed to on the screen. Then it printed a bunch of random junk and my computer rebooted. This happened every single time I ran the executable.

Eventually I actually read the first chapter properly and added MOV AH,4CH / MOV AL,0 / INT 21H. When my executable returned to the DOS prompt this time after running it, I felt like my mind had just expanded 10-fold as I realised what had been happening.

Re:Some Assembly Required: An approachable introduction to a... by olddustytrail on Tuesday June 28, 2022 @01:48PM (#31910753)
Did you get that "This machine does whatever I can tell it to do!" feeling?

And then you wonder what can you think to tell it to do. The wonder of computers.

Re:Some Assembly Required: An approachable introduction to a... by ddingus on Tuesday June 28, 2022 @06:45PM (#31914062)
That is an amazing feeling!

Then it hits: that crash, bug, unexpected behavior is definitely my fault!

Lol, good times when one works on a routine that executes, crashes and burns long before that finger loses contact with the "return" key!

Re:Some Assembly Required: An approachable introduction to a... by raxxorraxor on Wednesday June 29, 2022 @10:06AM (#31920295)
What did cause the reboot? Is this some kind of DOS watchdog that reboots the system because your program didn't exit gracefully?
Re:Some Assembly Required: An approachable introduction to a... by throwaway_dcnt on Tuesday June 28, 2022 @02:28PM (#31911220)
Or? MOV DX, 200 / INT 27H
Re:Some Assembly Required: An approachable introduction to a... by pizza234 on Tuesday June 28, 2022 @02:26PM (#31911202)
Assembly is simple if all one does is printing hello world (even that is actually not trivial, because one needs to know/read the syscall and the ABI).

Anything beyond that gets complex quickly, in one way or another. On simple architectures, like the 6502, even doing a simple division is complex (heck, even additions are verbose, since 8 bits are too few for a lot of operations). On more complex architectures, like x64, there is a monstrous ISA full of inconsistencies.

Learning assembly as in learning an instruction set also doesn't include a lot of details of computer architecture, although at least some modern assembly books mix both domains.

Re:Some Assembly Required: An approachable introduction to a... by Salgat on Tuesday June 28, 2022 @02:47PM (#31911472)
It's simple in the same way C is simple. Sure it's a very small language with pretty straight forward commands, but once you try doing anything of significance it becomes extremely complicated and it's easy to do nasty things with it.
Re:Some Assembly Required: An approachable introduction to a... by davidhbolton on Wednesday June 29, 2022 @04:20AM (#31917664)
It may be simple but that simplicity is its downfall. How many databases, compilers, modern games. OOP classes or even file handling routines do you see in assembler? Few or none at all. Writing assembly language is slow and painstaking work. You can easily get 10x the productivity by switching to C or even better in higher languages. Games were written in assembler back then because Basic was too slow. And C compilers were only starting to appear on personal computers from the late 1980s.

Writing an assembler for 8-bit CPUS like 6502/Z80 was doable; I wrote a 6502 cross assembler (in Z80) so a Z80 development machine could output 6502 in 1985. It got harder with 8086 and 68000 chips.

Re:Some Assembly Required: An approachable introduction to a... by raxxorraxor on Wednesday June 29, 2022 @10:38AM (#31920767)
You still need to learn a lot of stuff. Problem is that it isn't portable. You have differences in architectures but most are quite similar if your goal is to make a program work instead of it being efficient for which you need deep knowledge about an architecture and its quirks. A few different mnemonic and register names is the far smaller problem.

But you also need to know about calling conventions of your operating system if you want to do any form of system call, which you very likely want to. Which registers supply arguments, which registers have to be saved, addresses of system functions which can change with OS or kernel version. You also need to learn what these function do. How would anyone know that writing a 48 into your accumulator and calling interrupt at address 80 opens a socket on Linux?

Thinking about this again makes assembly seem like a terrible, terrible idea...

To start with I would either recommend x86_64 for either Windows and Linux. I would prefer Linux here but I believe UEFI for example uses the Windows calling conventions, so taking a look at that might be practical. But these combinations usually offer the most learning helpers.

Usually you should only cause general protection faults at worst if you have something newer than a 386. But no guarantee...

Re:Some Assembly Required: An approachable introduction to a... by nsxwolf on Tuesday June 28, 2022 @01:37PM (#31910648)
The big hurdle for me was always understanding where assembly language ends and the assembler directives begin. That and the “now what?”, not knowing how to make a program do something interesting - needing to learn about the ROMs, the OS, etc.
Re:Some Assembly Required: An approachable introduction to a... by tengwar2 on Tuesday June 28, 2022 @05:53PM (#31913530)
I may be very out of date, as my last assembly language programming was in 80386 days - but types are important in x86. You definitely need to know your words from your bytes, and your index from your offset.