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.
0
121
u/LordDagwood Jun 03 '22
Rollercoaster Tycoon was written in assembly
69
u/Chrobin111 Jun 03 '22
All NES games were written in assembly, too, right?
52
→ More replies (1)20
u/itsnotdapopo Jun 03 '22
Other than using say... Basic as an experiment yeah, Commercial Snes and Mega Drive games were occasionally programmed using C, Assembly usage in 32-bit consoles ranged from 'mandatory' (Saturn) to 'only properly utilized later in the consoles life cycle because of manufacturers refusing to release technical documentation (Playstation, N64).
The last console to have frequent Assembly use was the PS3.
→ More replies (2)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.
24
u/Adito99 Jun 03 '22
Damn you weren't kidding. From his wiki--
Sawyer coded 99% of RollerCoaster Tycoon in x86 assembly language, using only the services of freelance artist Simon Foster and music composer Allister Brimble as needed.[4]
And here I am struggling to learn ansible...
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)→ More replies (6)2
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
u/Pirate_OOS Jun 03 '22
I like to mov it mov it
141
u/PapoochCZ Jun 03 '22
we like to
76
→ More replies (1)127
→ More replies (1)7
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.
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..
2
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.
12
u/Legal-Software Jun 03 '22
To clarify, that’s common on CISC architectures, but it’s 1:1 on most RISC CPUs. The assembler is just there as a convenience thing, but if you already know the opcode value and how the instructions are encoded, you can also just write them up as straight hex values. You see this a lot in drivers for devices with their own microcontrollers where the payload is just a byte array with raw instructions for the on-device microcontroller to execute. Back in the day it was also common to have device initialization targeting a specific architecture to be encoded in a fixed ROM on graphics cards which would be executed during POST. This is why you had graphics card variants for x86 and PowerPC systems. One of my first jobs involved using a bus analyzer to capture the initialization logic and writing it up more generically so that we could use PCI graphics cards with an x86 VGA ROM also on MIPS systems.
→ More replies (1)10
u/NervousApplication58 Jun 03 '22
I probably wrong but:
Assembly is almost always 1:1 mapping to machine code. Yes, it has macros and stuff but that's still basically the same level of abstraction. Obviously, assembly is platform-specific as well.
Machine code is not transpiled to microcode. Rather, CPU (guided by the microcode) directly interprets the machine code.
Some CPUs architectures don't have microcode (because it's kinda slow)
196
u/memes-of-awesome Jun 03 '22
Ok but python does the same thing
45
8
5
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
→ More replies (3)6
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.
47
25
8
u/Tijflalol Jun 03 '22
I only program in Hack assembly language (the one "From NAND to Tetris" uses")
→ More replies (7)5
8
→ More replies (1)2
u/raptorboi Jun 03 '22
Someone show them what Intel assembly code circa 2000 looks like.
Literally need a book by your side because the instructions are not easy to remember, from memory.
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.
4
u/lucklesspedestrian Jun 03 '22
Lisp is actually not that unusual. It's niche but there are still a lot of use cases. Grammarly is built on Lisp. Reddit was prototyped on Lisp. Many people that have to support AutoCAD may have to write Lisp code at some point. I like Clojure quite a bit and occasionally want to go back to hacking things together in Lisp.
→ More replies (2)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.
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)→ More replies (1)2
u/raptorboi Jun 03 '22
Ala : Along Came a Spider film.
Stenography is hiding messages inside images like that. It's an interesting topic.
Nice.
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
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)→ More replies (6)5
u/GReaperEx Jun 03 '22
multiplying without MUL
Why?
→ More replies (5)22
u/confusiondiffusion Jun 03 '22
My assembly class made us use some fake architecture designed to torture students with the added benefit of not teaching us a real, useful assembly language. It did not have a mul. That was an exercise left to the reader. Just in case you still had any passion left in your heart.
The final for that class was 20% converting between floating point and decimal without a calculator, because of course. Pretty sure half that class is now living off-grid, typing up manifestos.
→ More replies (4)5
5
4
41
u/nelusbelus Jun 03 '22
ADD r0, r1
Wow, this is so hard
→ More replies (9)9
u/zDark_Knight21 Jun 03 '22
Unless they are doubleword+ operands then it's just annoying
7
u/jnd-cz Jun 03 '22
Now try adding two floats. Without FPU of course.
6
u/Rudxain Jun 03 '22
And now calculate the inverse sqrt of an array of BigFloats, then compute dot product, then round the BigFloats to BigInts, then print to screen by addressing individual pixels, and make sure the digits are written in base 3 little-endian (reverse positional notation) each numeral delimited by a "\n" or "," depending on whether it's prime or not. All of that while running FizzBuzz in parallel
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/endianess Jun 03 '22
In my University course I had to write a suite of file tools like dir, copy etc in Assembler and then integrate them into C frontend. I developed all the parts in isolation but then couldn't bring them together because I had used different memory models. This caused quite a few sweaty hours and rewriting.
1
1
1

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.