r00ty
link
fedilink
23M

I used to write z80 asm without an assembler back when I was a LOT younger. The ZX spectrum manual I had, had the full instruction list with the byte values.

I think it was oddly easier than some higher level languages for some tasks.

But, making changes was an utter nightmare.

TunaCowboy
link
fedilink
8
edit-2
3M

Syscalls are sitting right there, and you can always just link libc…

OS and embedded dev here. I use assembly all the time. I’ve even worked on firmware that was entirely in assembly of strict requirements that couldn’t be met in C.

Also even machine code hides a lot about how the underlying machine works so if you really want to do computing from scratch you really do hate to invent the universe because there’s abstractions all the way up the hardware stack just like there is in software.

fuy
link
fedilink
33M

For a university assignment, I built a compiler for x86; I cheated a bit by relying on LLVM, but it gave me a better understanding of the architecture. I also developed emulators for the NES (Ricoh 2A03) and RISC-V (RV32I) as a hobby. For the latter, I implemented it in FPGA.

Ha! I teach assembly and use this one every year to lighten the mood before midterms.

It’s now been 18 years since the last time an employer paid me to write assembly, but it’s only been a year or so since the last time I had to read assembly at work (in order to verify what the compiler really was doing).

Presi300
link
fedilink
English
53M

Nah, I don’t hate myself that much.

AFK BRB Chocolate
link
fedilink
English
83M

I had an assembly class in college. I didn’t love of at all. Got my first job after graduating and it was writing space shuttle engine control software, which was in assembly. I was kind of surprised at how fast it became natural after dealing with it full time. Still, it felt luxurious when we upgraded the controller and could do the software in C.

“oh no, I had to do literal rocket science”

Assembly used to be a required course for CS undergrads in the 90s. Is that no longer the case?

Also we had to take something called Computer Architecture, which was like an EE class designing circuits with gates and shit.

Required course work for electrical engineers in the early 2000s.

I had to learn assembly but was one topic of many we handled in architecture. Like one question of one exam. That was one of the toughest professors we had, class was about 2001

Cethin
link
fedilink
English
3
edit-2
3M

I think the university I went to phased out the EE requirements the year after me. Honestly, I think it should be required. Understanding how the computer “thinks” is such an important skill.

Kairos
link
fedilink
63M

Its still a thing

Which target did you use? Having to learn even a fraction of modern x86 would be ridiculous, but SPARC or something could be good to know, just to reduce the “magic box” effect.

This was a long time ago. I’m pretty sure it was 8086.

I learned MIPS as an undergrad. Pretty neat little RISC architecture.

I learned mips as graduate. In undergrad had to build with logic gates for things like 2 digit decimal counter and my architecture classes were diagram blocks for a simple CPU. But by that time we knew how to do moderate complexity circuits in VHDL simulation, and we had to make a simple VHDL circuit run for real in FPGA.

I attended two different Bachelor’s courses, one with a very technical (2016-2018) and one with a more high level focus (2018-2023). The first did have a class where we learned how to go from logic gates to a full ALU as well as some actual EE classes, but I didn’t go far enough or memorise the list of classes to remember whether Assembly would have become a thing. We learned programming with first Processing, then C and C++.

The second had C as an elective course, and that was as technical and low-level as it ever got.

I still had to do that in the late 2010s in college

Skull giver
link
fedilink
45
edit-2
3M

Assembly isn’t that hard. It’s the same imperative programming, but more verbose, more work, and more random names and patterns to remember. If you can understand “x += 3 is the same as x = x + 3”, you can understand how the add instruction works.

I wouldn’t be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

These days, you won’t be able to beat the compiler even if you wrote your code in assembly, maybe with the exception of bespoke SIMD algorithms. Writing assembly is something only kernel developers and microcontroller developers may need to do in their day to day life.

Reading assembly is still a valuable skill, though, especially if you come anywhere near native code. What you think you wrote and what the CPU is actually trying to do may not be the same, and a small bit of manual debugging work can help you get started resolving crashes that make no sense whatsoever. No need to remember thousands of instructions either, 99% of assembly code is just variations of copying memory, checking equality and jumping anyway. Look up the weird assembly instructions your disassembler spits out, they’re documented very well.

I wouldn’t be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

Well, they’ve got a point for the bigger machine codes. Just the barebones specification for x86 is a doorstopper IIRC.

From what I’ve heard, writing big stuff in assembly comes down to play-acting the compiler yourself on paper, essentially.

Skull giver
link
fedilink
English
10
edit-2
2M

deleted by creator

What language is your pseudocode example modeled after? It vaguely reminds me of some iOs App code I helped debug (Swift?) but I never really learned the language so much as eyeballed it with educated guesses, and even with the few things I double checked it has been a few years, so I have no clue what is or isn’t legal syntax anymore.

Skull giver
link
fedilink
1
edit-2
2M

deleted by creator

I’ve heard of Kotlin in the context of Android apps, but never actually used or learned it. I did one mobile app dev project with Java in Android Studio, but never had any formal classes on it either and just learned as I went (the result was shit, but we got a decent grade for being able to evaluate the difficulties and shortcomings and point out learnings).

TIL. I had tried to understand it a bit, but felt lost pretty fast, and then eventually found out that’s because it’s huge. Is there a good intro to the basic instructions you’re aware of?

By “play act the compiler” I mean a fairly elaborate system of written notes that significantly exceeds the size of the actual program. Like, it’s no wonder they started thinking about building machine compilers at that stage.

Skull giver
link
fedilink
English
2
edit-2
2M

deleted by creator

Thank you!

Having toyed with video game reverse engineering, I definitely feel like I ought to learn a bit more. I understand mov, pointers and registers, and I think there was some inc and add in the code I read to try to figure out base pointers and pointer paths (using Cheat Engine), but I think knowing some more would serve me well there.

Skull giver
link
fedilink
1
edit-2
2M

deleted by creator

Assembly is hard, because you need to understand your problem on multiple levels and get absolute zero guidance by compilers.

Even C guides you a tiny bit and takes away some of the low level details, so you have more mental capacity to actually solve your problem.

Oh, and you have a standard library. Assembly seems to involve solving everything yourself. No simple function call to truncate a string or turn a char array to uppercase.

Missing “;” on line 148.

Skull giver
link
fedilink
English
12
edit-2
2M

deleted by creator

Noble Shift
link
fedilink
33M

NASM FTW

Cethin
link
fedilink
English
253M

Anyone who thinks OP asking about Assembly with this meme should play the game Turing Complete. It’s great. You have to design a computer all the way from the most basic logic gates (I think you only get a NAND gate to start), designing an ALU and CPU, creating your own machine language, and writing your own programs in the language you designed, and it’s all simulated the whole time. Machine language is pretty advanced as far as things go.

@bleistift2@sopuli.xyz
link
fedilink
English
143M

From your description this sounds more like a job in IBM’s R&D department than a game

Cethin
link
fedilink
English
133M

All the best games sound like jobs when you describe them.

factorio, satisfactory, oxygen not included, RimWorld, Stellaris, dwarf fortress, gregtech new horizons…

We got to do something simular in uni. We modeled the CPU in VHDL and had to set up our own language, then we were to program a game for it. One of the most fun and interesting courses we got to do!

Only on the VIC20 and Atari STe. On the VIC20 you had to write the assembler, manually convert it to machine code and enter that into the computer. There was a cartridge with an assembler, debugger and an extra 3.5Kb memory for it but I never got one.

Vic 20 was my first. I watched my dad struggle with and eventually give up on assembly. Something-something and the microbots. I was fearful of it until I took Assembly at Uni. That 2nd/3rd year class was where the final puzzle piece of how computers work fell in place for me.

My first job was writing assembly tests for a DSP hardware design team. Fell in love. Never looked back.

I’ve been studying Arm Aarch32 lately. I have a software development academic background but I have always been interested in Architecture.

Not exactly accurate, I think. Even machine language is bound by the CPU’s architecture. You can’t do anything in machine language that wasn’t specifically provided for by the CPU architects.

It would be more accurate to say it’s like creating a new universe using all the same laws of physics, thermodynamics, cosmology, ethics, etc as our existing universe.

I don’t think accuracy was the goal, it is a joke not a dissertation. It’s more about how it feels to try a language like assembly after working with higher-level languages.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 77 users / day
  • 211 users / week
  • 413 users / month
  • 2.92K users / 6 months
  • 1 subscriber
  • 1.53K Posts
  • 33.8K Comments
  • Modlog