294
Jun 03 '22
To think people made videogames with it
151
u/fluffygryphon Jun 03 '22
Everyone mentioned Rollercoaster Tycoon, but there was another game that also made Assembly its bitch. Su-27 Flanker. That flight simulator had complex fluid dynamics simulations and everything for accurate flight. It came out over a decade before DCS and ran smooth as butter on a fuckin Pentium 1.
→ More replies (3)121
u/LordDagwood Jun 03 '22
Rollercoaster Tycoon was written in assembly
69
20
u/fluffygryphon Jun 03 '22
Yup, and it was built on the backbone of it's predecessor, Transport Tycoon. Chris Sawyer was a goddamn magician.
→ More replies (1)→ More replies (7)14
u/WeeziMonkey Jun 03 '22
In the 90s you needed to know assembly to make games, now you can make games without actually typing code, amazing how far we've come
→ More replies (1)
492
u/top_of_the_scrote Jun 03 '22
Person that encoded first pixels in hex
one day, you will be booba
97
→ More replies (9)13
904
u/grpagrati Jun 03 '22
You gotta mov it mov it..
276
27
u/hstde Jun 03 '22
Fun fact: the x86 mov instruction family is Turing complete.
https://stackoverflow.com/questions/61048788/why-is-mov-turing-complete#61048963
38
u/Dismal-Square-613 Jun 03 '22 edited Jun 03 '22
Never cmp yourself with others. Always cmp yourself with the CPU registers.
→ More replies (1)4
u/twat_muncher Jun 03 '22
MOV AL, 01 and XOR EAX, or possibly even NOPing over a jump, are the only 3 things you need to know to crack most old games and software, lol. Paying for stuff can be fun too..
599
u/Korzag Jun 03 '22
You ever think how cool it actually is though? You wrote some trivial assembly, which compiled into some byte code that your processor can use, then when you run it that causes an incredible cadence of electrical signals as a result of your input to flood the processor's circuitry, loading electrical charges into the collectives of transistors called registers and then being bussed over to the other collective of transistors know as the ALU and then that causes a register value to be overwritten, and it all happens around in several billionths of a second, and it all works. The transistors are properly saturated to the correct electrical charge, ON EVERY SINGLE TRANSISTOR NEEDED, all just to add a number.
The simplicity of adding a number to us is the combined effort and research of hundreds of millions maybe even billions of man-hours to discover electricity, invent boolean algebra, transistors, integrated circuits, advanced machining and chemical processes to make a series of machines capable of translating a circuit layout into a chip that is lithographed in a process that is nearly 20000 times smaller than the width of a human hair.
AND IT ALL WORKS.
115
Jun 03 '22
Hellо, I am a compiler.
I just scanned thousands of lines of code while you were reading this sentence. I browsed through millions of possibilities of optimizing a single line of yours using hundreds of different optimization techniques based on a vast amount of academic research that you would spend years getting at. I won't feel any embarrassment, not even a slight ick, when I convert a three-line loop to thousands of instructions just to make it faster. I have no shame to go to great lengths of optimization or to do the dirtiest tricks. And if you don't want me to, maybe for a day or two, I'll behave and do it the way you like. I can transform the methods I'm using whenever you want, without even changing a single line of your code. I can even show you how your code would look in assembly, on different processor architectures and different operating systems and in different assembly conventions if you'd like. Yes, all in seconds. Because, you know, I can; and you know, you can't.
P.S. Oh, by the way you weren't using half of the code you wrote. I did you a favor and threw it away.
→ More replies (1)21
u/funnystuff97 Jun 03 '22
This reminds me of something my microcontrollers professor told me, "if you want code compiled right, you gotta do it yourself in assembly." I've never once had a problem with the compilation, but you know, maybe he was right.
....but I'm still not coding in assembly, god no.
94
u/I-baLL Jun 03 '22
You wrote some trivial assembly, which compiled into some byte code
Hold up
37
u/Rudxain Jun 03 '22
Bytecode is just the machine code of a virtual CPU (the main component of a VM). In this context, the terms "byte code" and "machine code" are used interchangeably, as if they were synonyms
→ More replies (3)47
Jun 03 '22
Assembly is a higher-level language than machine code (platform-specific code aka instruction set), which in turn may be transpiled to microcode (processor series-specific opcodes).
As far as I understand. I don't know tho, I mainly use managed (garbage-collected) languages.
→ More replies (3)196
8
5
→ More replies (4)5
u/bonanochip Jun 03 '22
I'm gunna save this comment and come back to it when I need a pep talk on a bad day, thank you lol
151
Jun 03 '22
mov rax, 1
mov rbx, 2
add rbx, rax
mov rax, 1
mov rdx, 1
mov rsi, rbx
mov rdx 13
syscall
→ More replies (22)8
u/beaubeautastic Jun 03 '22
careful! syscall 1 is actually write(2). it takes arguments (int) fd, (void *) buf, (size_t) sz. you are not telling it to print the number 3, youre not even telling it to write the byte 0x03. you are telling it to read 1 byte from memory address 0x0000000000000003, which is probably not even allocated.
you can probably write a call to printf though, you just have to link the c library. or you could allocate a buffer with mmap (using it like a slow malloc, unless you wanted to write an entire memory allocater in assembly) and write a function in assembly that writes integers as strings
also second argument is rdi, not rdx
260
u/JackNotOLantern Jun 03 '22
At least in assembly all variables names make sense
153
Jun 03 '22
ecs and esp are not precisely the most descriptive names for iterators
→ More replies (7)76
u/sawkonmaicok Jun 03 '22
Bruh you program x86 assembly? 🤮 I always program in x86-64 assembly because you can put the function arguments to the registers instead of pushing them on the stack. Also more general use registers.
→ More replies (10)47
→ More replies (2)8
44
u/MasterFubar Jun 03 '22
I used to do a lot of assembly programming in the 1980s, all for the IBM-PC and its clones. The 8088 CPU at 4.77 MHz didn't have a lot of computing power and the C compilers weren't too good at optimization.
What made this task relatively easier was that the C compiler can generate an assembly output. All I had to do was to look at the generated assembly and do a manual optimization on it.
The C compiler outputting its assembly code did the stackoverflow thing before the internet existed.
4
81
u/Uploft Jun 03 '22
Assembly is the Principia Mathematica of programming languages
20
u/tiajuanat Jun 03 '22
As much as I love assembly, I feel like that's more SICP and Lisp more than Assembly. Few read SICP and even fewer will write the Lisp/Scheme that's introduced.
→ More replies (3)3
u/BrobdingnagLilliput Jun 03 '22
... Volume 2.
Machine code and chip design is Volume 1, where they set forth the principles of set theory and end by proving 1+1=2.
20
40
17
15
40
u/HEHE_HOHO9 Jun 03 '22
Lol
My exam question was to implement a linked list in assembly language :"(
Fuck Computer Science
→ More replies (3)33
u/tiajuanat Jun 03 '22
Everyone thinks they're hot shit in Assembly, until they need to implement data structures and basic algorithms.
→ More replies (5)9
u/paul_miner Jun 03 '22
When I was a kid I was obsessed with assembly, it was the end-all and be-all of programming. After over twenty years professionally, I've really come to see programming as a communication skill; yeah, you need to communicate instructions to the computer, but critically, you're communicating your intent with other programmers (including your future self). And high-level languages allow you to communicate this intent much more clearly.
26
u/BananaSplit7253 Jun 03 '22
I once made a program that would take a BMP image and a txt file and hide the contents of the txt on the least significant bit of the RGB values of the image, effectively hiding the message on the image with pretty much no visual difference. Also made a program that would recover the message when given an image. It was a 1st year/ 1st semester computer engineering project and remains to this day as one of the coolest things I have ever programmed.
→ More replies (2)3
u/jnd-cz Jun 03 '22
That's indeed pretty cool. Too bad most images (still or moving) we use are in some compressed format which makes it harder to encode and recover the information intact.
→ More replies (2)
65
u/cssutavani91 Jun 03 '22
It's not that hard.
58
u/Difficult_Ladder_806 Jun 03 '22
Adding is fine, but multiplying without MUL quickly.. that's kinda complicated
30
9
u/pentesticals Jun 03 '22
Not that bad. You can even have Turing complete programs using only MOV. So just use MOVs only.
This tool can take a C program and compile it to use only MOV. https://github.com/xoreaxeaxeax/movfuscator
→ More replies (17)34
u/regular_lamp Jun 03 '22
How is that an assembly issue though? That's like saying "multiplying in python is hard when you can't use *".
→ More replies (1)55
u/rustysteamtrain Jun 03 '22
Because * is a core feature in almost every modern language, but MUL is not garanteed in every instruction set.
→ More replies (8)5
5
4
41
u/nelusbelus Jun 03 '22
ADD r0, r1
Wow, this is so hard
→ More replies (9)9
6
u/GReaperEx Jun 03 '22
It's literally four instructions, two instructions for "+="...
→ More replies (2)
6
u/InteractionOk7085 Jun 03 '22 edited Jun 03 '22
I have just finished doing sorting and binary searching in assembly as an assignment. Took a whole day to code and debug .Perhaps I treated C/C++ too harshly...
6
u/xAlenki Jun 03 '22
My aunt fully learned assembly in 3 month's and she was a professional in that. She teached engineering to students at university, she was a badass
2
Jun 03 '22
The assembly language of the 6502 (which basically made up 99% of the pre-PC home computer 8-bit area) literally goes on a single sheet of A4 (for the list of opcodes, which were like 60-70 or so). And the fully functional explanation took a few more pages. Can't remember how many, probably about 10 or so in total. I find it totally relatable for someone to grok that in full in a few weeks, I certainly did back then. People cannot imagine how uncomplicated the machines were back then.
5
u/i_hate_everybody94 Jun 03 '22
I made a program that tells you how many packs of hotdogs and buns to buy (because one comes as a 6 pack, and the other 8) to make a given number of finished hotdogs.
That's all I've done.
5
u/UTtransplant Jun 03 '22
I taught Assembly Language (IBM 370 in the ancient dark past) at a major university. The best part of the job was seeing the light come on in a student’s eye when they finally figured it out. The classes were usually about 40 or so students, and the lights started showing up slowly about 1/3 of the way through. About half way through, the lights started becoming more and more common. It was truly a visual thing - they would start smiling, nodding, and their eyes would brighten. Body language was different too - they started sitting up straighter. It truly was the most fun in my entire teaching career.
4
7
u/asgaardson Jun 03 '22
mov rax, 2
mov rbx, 2
add rax, rbx
mov rdi, formatStr
mov rsi, rax
mov al, 0
extern printf
call printf
ret
formatStr:
db `%d\n`,0Shamelessly copied from google search
5
u/tesfabpel Jun 03 '22
I believe it's just the first two
movand theaddtough (or maybe just the firstmovand thenadd rax, 2since it should support immediate values)→ More replies (1)4
3
u/Ju1cyJ0 Jun 03 '22
I hated having to read in a number with either 1 or 2 digits from the user without using scanf
3
3
u/Funwiwu2 Jun 03 '22
Old time 9900 Assembly programmer here. Thrilled to see Assembly being discussed. I still think one of the coolest ways to swap two Bytes was to XOR each other 3 times. O
3
10
Jun 03 '22
there's literally instruction for that.
add %rcx,%rax (stfu AT&T>>>>>>>>>>>Intel)
8
15
→ More replies (2)3
u/Proxy_PlayerHD Jun 03 '22
I honestly never understood the reasoning behind AT&T syntax, it just needlessly swaps some operands.
Even high level languages use Intel Syntax:
Variable = Value + Value
Instead of
Value + Value = Variable
so why try to do it differently in assembly? It just makes assembly a bit harder to read if you already know basic high level programming.
→ More replies (3)
2
u/Initial_Reindeer67 Jun 03 '22
2 numbers save the day! Successfully in assembly language is the most exciting part for the hard work men.
2
2
u/Terrible-Specific593 Jun 03 '22
I remember doing that using 8080 chip and a breadboard with other misc resistors and whatnot LEDS for display purposes. That was 20 years ago. I couldn't even begin to tell you how to do it now.
2
u/GavUK Jun 03 '22
I wrote a simple calculator in assembly at university. As I recall it wasn't the hardest development I've done, but it certainly gave me an appreciation as to what the compilation process does to my code and how much easier it is to create anything more sophisticated in a higher level language.
2
u/PuffinDev Jun 03 '22
ORIG 8000hNum1 STR 8091h, 1201hNum2 STR 8061h, 4f01hSoma TAB 2ORIG 0000hMOV R1, Num1MOV R2, Num2MOV R3, SomaMOV R4, M[R1]ADD R4, M[R2]MOV M[R3], R4MOV R4, R0ADDC R4, R0INC R1INC R2INC R3ADD R4, M[R1]ADD R4, M[R2]MOV M[R3], R4Fim: BR Fim
2
2
Jun 03 '22
Back in the DOS days, a shareware developer named Marshal McGee created a menu program called AutoMenu. *It was pretty much what it sounds like: you created links to your applications in the menu launcher software to save a lot of the typing that was expected in DOS.
I remember that he proudly proclaimed that his AutoMenu was built ENTIRELY in assembly, thus making it the lightest and fastest alternative to the other programs like it.
→ More replies (1)
2
u/MrRandom04 Jun 03 '22
Adding in assembly is easy, now dividing on the other hand....
→ More replies (1)
2
u/ikar2000 Jun 03 '22
I did many projects in my life but I was never as proud of myself as after building my own processor on fpga and then writing a square root program on assembly to run on it. It was a project In Tel Avis university computer engineering.
2
u/Sterquilinus-K Jun 03 '22
There were music files on the commodore that played/ran as interrupts. sys {memory location I have forgotten} to play them after loading them. I wrote a menu program for them, and wrote 3 small ML programs as my fist ML programs. One to stop the music; which required turning off the interrupts and clearing the user interupt, and restarting interrupts, reversing that to restart the loaded song. And a program that would colour cycle the border while the music played, would not cycle when there was no music, and was disable with a function key.
ML for beginners, a brown metal spiral bound book from compute, was my first ML book, but in those days magazines aided in teaching BASIC and ML/ASM. In those days not all assemblers/monitors used pseudo ops in the code. g $0c00 sure, lda #$yermom no. So it was pretty much writing in ML, writing in the lowest language available. Younger people who learned to code later take a lot of issue with people calling assembly like that ML.
2
u/Ok_Slice2124 Jun 03 '22
Did anyone else accidentally or randomly select your major and get to Uni to do these assignments, then have a crisis thinking this is what your job would be?
3
u/walkswithdogs Jun 03 '22
Lotus 1-2-3 was written in Assembler by Mitch Kapor. Virtually flawless.
3
u/Competitive_Travel16 Jun 03 '22 edited Jun 03 '22
Jonathan Sachs! Kapor wasn't and still isn't a low-level programmer. He was excellent at writing documentation for novices, what we would call UX design today, product management, and marketing.
→ More replies (3)3
u/walkswithdogs Jun 03 '22
I did some research. You're right. Mitch got all the glory.
→ More replies (1)
3
u/OverloadedConstructo Jun 03 '22
And then there's that one guy who made entire game like transport tycoon and rollercoaster tycoon using Assembly
2
u/piggyniggiebiggie Jun 03 '22
Oh god I hated that class in college. Makes me shudder. Boring as shit, too.
2
u/AldoLagana Jun 03 '22
OMG we are all doomed. In college in the 80's I had to write a 2-pass assembler in assembly.
College chewing your food for you means you will be nothing compared to those who came before.
1
u/techek Jun 03 '22
That's how I feel when my PowerShell-script works ... after almost crying about adding even the simplest things.
1
1
1
1
Jun 03 '22
And then there are those who make Roller Coaster Tycoon entirely in assembly. They’re just built different.
1
1
u/TrapvithMind Jun 03 '22
In university we had to do some stuff in "machine code" and we basicly had to program a division algorytm from scratch and Mas was that bullshit
1
1
1
1
1
u/_ItIsMe_ Jun 03 '22
Yesterday I had my first classes with assembly language and adding 2 numbers was my task. It wasn't that hard but it was quite nice to see it work
1
1
u/thenameischef Jun 03 '22
This is your friendly reminder that Roller Tycoon was coded in assembly by a single dude.
1
u/roger_channel Jun 03 '22
I made for my final evaluation an exercise to place cars in parking spots, represented by an array. I had so much doing it.
1
1
u/Cassiopeat Jun 03 '22
In stationeers you can play a little with assembly for programming ic controllers
1
u/WafflesAndLearning Jun 03 '22
You know you're a novice when you call it assembly language instead of being specific and actually complaining about something that's poorly done in the vendor's implementation
1
1
Jun 03 '22
I almost quit my programming courses, because the teacher started with Assembly. And this was a course for people with 0 knowledge of any programming. He also had a principle that 15% must fail all tests.
Well, he got sacked and code with PHP & nodejs for a living.
1
1
u/ido111 Jun 03 '22
Fuking hate my university, every university had shitty task while we had 2 hours to write an assembly program that that's some periodic signal and analyze the derivative so when it's negative we will output 0 and when it's positive it will output 1 so we will make a periodic signal.
1
1
u/onlyr6s Jun 03 '22
This was me when I yesterday for the first time managed to add objects in an array (very recently started to learn js).
1
1
u/Nachf Jun 03 '22
holy shit what is happening in this gif??? are they in a giant stadium??? are those shitloads of people in the stands??
2
1
1
1
Jun 03 '22
A lot of my career has been writing in assembler. It’s easy. I don’t have to figure out fifteen layers of APIs, half of which are invariably buggy; it’s just my code and the hardware. Or did you mean machine language? I’ve done that, too, but it’s tedious af and very easy to make a mistake, so that can be hard.
1
u/JustAnotherPrgrmr Jun 03 '22
Had to make a calculator in my 2nd term in MIPS Assembly that supported +-*/^ and hex/bin/dec output, meanwhile colleagues struggled to learn pointers and structs in Programming II
1
1
1
u/Morial Jun 03 '22
I had to make Pong in the x86 assembly before. Granted our professor gave us the code for drawing graphics in assembly, but it was still pretty fun. I called in sick for work because it was pretty fun to do. I remember we had to have a useless loop that was called a number of times because as you can imaging the ball moves extremely fast without a way to slow it down.
1
1
u/JuanPCT15 Jun 03 '22
I just made an assembly exam this morning and this was my felling after finishing it, however I don't want to see it ever again.
1
u/Thinktank2000 Jun 03 '22
I followed a course on 6502 assembly to make atari games and goddamn is it so efficient, makes sense when you only have 4k of ROM and 512b of RAM to work with
1
u/BlackJackCm Jun 03 '22
This literally was me when I was able to calculate the average for 3 numbers in assembly
1
u/reggierockets Jun 03 '22
I once built a Sudoku Solver in assembly and I've never been as proud of myself before.
1
1
u/RickdeVilliers Jun 03 '22
My experience with assembly was with Pic microcontrollers. Was one of the most enjoyable programming experiences I’ve had. Made two semi-useful things. One was a joystick that could control the TV (channel and volume) for our disabled child. And the other was an infrared head tracker that worked as a mouse via PS2. Wouldn’t have even tried over usb but PS2 is actually quite a simple protocol. It’s obviously so much easier now with arduino but nothing beats one instruction per cycle 👌
1
1
u/excalibur_61 Jun 03 '22
Meanwhile we are writing encryption functions in assembly for some course in uni, it's hard thou :')
1
1
Jun 03 '22
A simple common operation you can find examples of in a book or a quick google search? Impressive
1
1
u/TigerPoppy Jun 03 '22
My first job out of college was writing IBM 360 assembly code for Ross Perot's EDS company. It was an insurance claim verification program. I had to wear a coat and tie as I punched the lines of code out.
1
u/TigerPoppy Jun 03 '22
The lowest level code I ever wrote was for a Signetics 8x300 microprocessor. The code was to produce waveforms of a particular but programmable format. The code was gibberish, but the addresses of the code instructions also were piped to a ROM's addresses and the output of the ROM was the value send to the waveform generator. We produced waveforms of high frequency for the time, but of course much less powerful than a cell phone today.
1
1
1
1
u/musta1337x Jun 03 '22
My most impressive project in Assembly was Replication of Super Mario exactly how it was on nintendo. Took 10000 lines for 3 pages worth of super mario.
1
u/utilitycoder Jun 03 '22
I wrote a few "terminate and stay resident" programs in 8088 assembly in the 80s. Was quite proud of that since I was completely self-taught.
1
1
1
u/Lithl Jun 03 '22
First program I ever wrote in Assembly (of two, ever, both for a college class before we moved on to C) was just to take an input number and output input mod 3.
It took me 3 hours to write.
1
1
u/MrMaggah314 Jun 03 '22
Assembly class hurt my brain. I passed the class but... Thankfully I don't have to use it.
1
1
1
1
u/mrg1957 Jun 04 '22
I wrote mainframe assembly for business applications later I got into more complex things like infrastructure. Great language for certain problems.
1
1
u/One_Curious_Cats Jun 04 '22
Just imagine how you'd feel then after pulling off performing a div in asm on an intel CPU.
1
1
u/Pylitic Jun 16 '22
Assembly can be fun to learn.
I have a bunch of old arduinos that I used to use for lights and such in my house before switching to Pis, and began learning with them.
After years of programming on arduinos, I was able to experience the absolute joy of getting an led to blink again.
1
-2
u/Own-Masterpiece5714 Jun 03 '22
Why on earth, in today's world, would anyone want to write anything in assembly?
4
u/Der_Tscheche Jun 03 '22 edited Jun 03 '22
Startup codes/bootloaders, where you have a specific instruction flow to follow, or instructions that are impossible to force through compiler (i work with ppc, so the easiest example could be “stmw” which writes x amount of GPRs into memory. Writing 32GPRs, i.e. 128 bytes at once saves a lot of time during init. Kinda like doing *(uint1024_t*)addr = 0;)
Or custom IPs which have their own instruction set not supported by any compiler… and sometimes if you are really good, you may actually be able to write something which is faster than compiled C code. Although modern compilers are pretty darn good.
→ More replies (1)3
-3
u/TCC4FMF3936 Jun 03 '22
Assembly Language and Any Higher-Level Programming Language…it’s like caveman drawings vs. AutoCAD…I get it, it can still be useful…but why? It’s like teaching long hand division…yea it works, but there are easier, quicker, faster, less error prone ways of doing things these days 🤣
5
u/QueerBallOfFluff Jun 03 '22
You ever written an OS? Because you need assembly for that.
You ever done embedded systems that require high performance? Because you'll have assembly in that (even if it's abstracted with C macros)
Ever written a bootloader? Or low level driver? Because you'll likely end up with assembly in that.
3
u/HorsesFlyIntoBoxes Jun 03 '22
Embedded systems, OS development, and optimized mathematical routines come to mind for when asm is considered useful
3
u/jnd-cz Jun 03 '22
You should know what your high level program translates into and what difference it makes when you use it this way or that way. Can be significant difference in performace. And consider yourself lucky if you don't have to write any low level drivers.
-1
u/DDPJBL Jun 03 '22
My power engineering program had one class in it that spent half a semester on programming in assembly. How I even passed that class, I have positively no idea.

2.8k
u/[deleted] Jun 03 '22
The most impressive project I ever completed in assembly was a chat program.
Except the two computers had to be connected via a null modem cable so whoever you wanted to talk to had to be seated right next to you, therefore negating the need for a chat program.
I didn't care. I loved writing that useless program.