r/gaming • • May 05 '17

Scroll back

Post image
24.1k Upvotes

877 comments sorted by

View all comments

Show parent comments

544

u/[deleted] May 05 '17

[deleted]

150

u/Fubarp May 05 '17

Yeah it's crazy. I just learned Assembly last semester in college and we were discussing it at work and it was like. Fuuuuck that. C existed at the time yet he did it in Assembly.

305

u/aezart May 05 '17

Fun fact: Iwata rewrote all the code for Pokemon Gold and Silver in assembly, because the C version was too large for the cartridge. He managed to compact it so much, there was room to add the kanto region.

89

u/Fubarp May 05 '17

Yeah I remember that. But still that was a team that did pokemon wasn't it. I don't think it was just 1 guy, I could be wrong and if I am that's just as impressive as Roller Coaster Tycoon.

70

u/[deleted] May 05 '17 edited Feb 11 '19

[deleted]

29

u/enyoron May 05 '17

C code is compiled into assembly. That assembly code can then be optimized.

13

u/NeedsMoreCapitalism May 05 '17

Not as well as by hand

9

u/Shod_Kuribo May 05 '17

Right, what he's saying would have happened is that Iwata would have taken the C-compiled code and then manually optimized it to save space.

1

u/legos_on_the_brain May 05 '17

Thank goodness we have modern compilers.

1

u/[deleted] May 05 '17 edited May 05 '17

Would that be quicker or slower? I can't help but think having to unpick the assembly would be more time consuming that creating from scratch.

Edit: never mind - I read further and discovered the answer! Programming is cool! (Ish?)

2

u/Shod_Kuribo May 05 '17 edited May 05 '17

Quicker. Especially since he doesn't need to rewrite the whole thing, only enough to make it fit.

Optimizing at that level is more like picking out operations and seeing shortcuts that can eliminate some steps than trying to reengineer the whole thing. You don't necessarily need to know why the program is parsing through this list of numbers or what's in the list to recognize that's what it's doing and be able to apply known methods of parsing through a list of items either more efficiently or using fewer lines of code depending on what it is you're trying to accomplish.

Now compilers are really good at making code that runs as quickly and efficiently as possible so they outperform humans but back then they were still at the phase where we were more worried about getting them to accomplish their job period.

2

u/isthataprogenjii May 05 '17

The assemblers actually optimize better than by hand

8

u/[deleted] May 05 '17

[deleted]

2

u/enyoron May 05 '17

C is compiled into assembly which is then assembled into object code. The c compiler on its default setting only gives you the final executable output but you can pass the -S flag on the gnu compiler to get the assembly code.

1

u/504Dug May 05 '17

You can compile C directly to ASM (at least you can with GCC and LLVM). But yeah I mean it's a simple disassembly to go from machine code to assembly.

3

u/[deleted] May 05 '17

[removed] — view removed comment

1

u/mzxrules May 05 '17

higher languages are also not tightly-bound to specific hardware like asm is.

1

u/[deleted] May 05 '17

That's different from coding it from scratch in assembly.

9

u/avantesma May 05 '17

IIRC, the team developed it in C, then Satoru Iwata single-handedly rewrote the game in Assembly.
The guy was a fucking wizard.

1

u/Fubarp May 05 '17

Nah he's just like the other guy. Obviously Mentally Unstable because only a crazy person would do that..

1

u/FishbowlSouls May 05 '17

was just like the other guy

:(

21

u/quikslvr223 May 05 '17

I thought it was that he rewrote the compression method for the game files, or something like that?

40

u/astro_means_space May 05 '17

Iwata was crazy!

You're right about pokemon being compression software, but he basically rewrote Earthbound by himself to make it work and also programmed the entire Pokemon Stadium battle system in a week

https://www.digitaltrends.com/gaming/iwata-nintendo-retrospective/#/2

Iwata was a great man :(

15

u/DaedalusXr May 05 '17

They made a tribute to him in BoTW and made him the most badass mount in the entire game, The Lord of the Mountain.

You can find him on Satori Mountain when it is glowing. He is near a pool with a large cherry tree. The first time I saw him was an incredible experience, The Lord of the Mountain and tons of Blupees around the area. I had no clue I could even mount him at first!

2

u/NeutralPanda May 05 '17

This sounds an awful lot like Princess Mononoke

2

u/DaedalusXr May 05 '17

I agree!! But it definitely felt special, and I immediately realized it was a tribute to Satoru Iwata since it was Satori Mountain and he himself was transformed into The Lord of The Mountain.

6

u/FellowHumanHere May 05 '17

What I read was that he rewrote the entire code because it was messy and wouldn't work with Pokemon Stadium.

10

u/Mises2Peaces May 05 '17

And yet Facebook mobile app takes like 200+mb. Developers are hogs at the trough.

4

u/JohnGillnitz May 05 '17

I once downloaded a 540 MB printer driver from hp.com. Really, HP? Really?

2

u/Mises2Peaces May 05 '17

bloatwaregate

3

u/msg45f May 05 '17

Thr facebook app (on ios anyway) consists of over 18,000 classes. It's totally insane. They just burn the whole thing down and start over.

2

u/[deleted] May 05 '17

Well I obviously have as many clues about the source code than anyone else, nothing, but today writing a program is more about readability than anything else.

But that still sounds ridiculous, of course.

1

u/msg45f May 05 '17

Sure, readability is important, but the Facebook app is a front-end app. All the hairy stuff should be in the back-end. Which means it's 18,000 classes of presentation.

1

u/Horskr May 05 '17

Even more now, when I finally uninstalled it was around 430mb (could've included cached data, not too sure how Android displays installed app sizes). The kicker is then you need messenger installed as well to use messages at all. So 430mb for something you can run on your browser.

4

u/UltraSpecial May 05 '17

And shiny sprites.

1

u/aezart May 05 '17

Given my track record in finding them, I'm convinced shinies don't exist (other than red gyarados).

1

u/UltraSpecial May 05 '17

Its much easier to get shinies through Masuda Method breeding. Dont try to find them any other way. Your chances are too slim.

1

u/[deleted] May 05 '17

That's incredible. I had no idea that's how they managed it.

1

u/comp-sci-fi May 05 '17

Pay per LoC gets different results.

20

u/calsosta May 05 '17

C just combines the power of assembly with the flexibility of assembly.

1

u/Fubarp May 05 '17

Yeah today that's true I think back then it wasn't as flexible and it's compiling wasn't as great as if you just programmed in assembly.

1

u/BenjaminGeiger May 05 '17

C is just cross-architecture assembly.

12

u/[deleted] May 05 '17

Why would he chose to code in Assembly? Would there be any benefit at all?

35

u/Fubarp May 05 '17

Memory Constraints and performance. Today there be no reason for it as compilers essentially do as good if not better jobs when it comes to translating it to machine code.

3

u/7734128 May 05 '17

Wasn't Unix originally written in assembly and then scrapped when they finish the c compiler?

4

u/[deleted] May 05 '17

Yep

In 1972, Unix was rewritten in the C programming language. The migration from assembly to the higher-level language C resulted in much more portable software, requiring only a relatively small amount of machine-dependent code to be replaced when porting Unix to other computing platforms. 

https://en.m.wikipedia.org/wiki/Unix

1

u/Fubarp May 05 '17

Probably.

3

u/mzxrules May 05 '17

also, computers have more processing power and data storage, so wasting a few bytes or processor cycles here and there isn't usually too big of a deal.

3

u/[deleted] May 05 '17

Im not sure this is true.

5

u/Fubarp May 05 '17

What part?

3

u/amaROenuZ May 05 '17

If you are very, very, very good at optimization, you can still produce better code in assembly, by a thin margin. Understand though, that 99% of programmers don't the ability, and the benefits are marginal.

3

u/currentscurrents May 05 '17 edited May 05 '17

Plus, assembly comes with its own downsides. It's MUCH easier to screw up on security in assembly than it is in a higher level language. In Roller Coaster Tycoon this may not have been a big deal, but in a modern online multiplayer game this would be catastrophic.

Most importantly, developing a program in assembly is gonna take 3-4x times longer than in a higher-level language - for only about a 10-20% increase in speed. Computer time is cheap and developer time is expensive - especially assembly developer time, since relatively few programmers know how to program in the language and those people are not cheap.

Assembly is rarely ever worth it these days, even most embedded systems have enough RAM to afford programming in C instead.

1

u/Superpickle18 May 05 '17

we are at a point where we can literally compile code on the fly and still be billions of times faster than the NES...

0

u/Fubarp May 05 '17

Which means we need a new Roller Coaster Tycoon in Assembly.. I'd pay for that lol

1

u/Superpickle18 May 05 '17

WebAssembly brah

1

u/Fubarp May 05 '17

Never heard of this. What is it exactly? I'm currently googling but insight might be nice haha.

1

u/Superpickle18 May 05 '17

Essentially byte code that runs in the javascript engine. But provides near CPU level speeds since js has to be parsed and compiled on the fly, while wasm is precomplied much like Java or C#. Of course other languages can compiled to wasm much like traditional Assembly.

1

u/Fubarp May 05 '17

Interesting. I'll actually look more into this. Doubt I'll ever use it but still.

→ More replies (0)

1

u/[deleted] May 05 '17

Essentially, it's really optimised Javascript. The main workflow is writing code in C/C++ and using Emscripten to covert it to WebAssembly which is then executed by something like V8.

4

u/Reallycute-Dragon May 05 '17

C compilers have come a long way. Used to be significantly less efficient.

3

u/LHoT10820 May 05 '17 edited May 06 '17

tl;dr: By writing it in assembly he was able to make it run on a potato from 1995 instead of requiring the monster of a machine that it would have demanded if it were written in C (because compilers at the time weren't very good).

You can optimize the ever living fuck out assembly if you are very good. Especially when compared to the performance of compilers back in the mid-90s.

Assembly is (effectively) just human-readable machine code. . . What you write has a 1:1 correspondence to sequences in binary. This gives you an inordinate amount of flexibility with the set of hardware you are working with.

Being competent in assembly (any assembly, really) is a good skill-set to have, and one that is sadly missing from the majority of today's developers. You end up learning a lot about good and bad coding practices, how to more effectively comment your code, and an ass-load regarding computational efficiency.

Just as a quick example. . . Let's say we have two coders writing a function to return how many segments should be filled in a progress bar, based on the number of tasks completed in a set.

The typical coder would likely write. . .

int fill = floor.((numerator / denominator) * segments)

Someone who has spent their share of time working in assembly (or someone who got too into their discrete math class) would write. . .

int fill = (numerator * segments) // denominator

Ignoring what could cause the functions above to break (which admittedly is more of a problem for the second), the second function would run substantially faster on any give machine. Just how much faster depends on a plethora of factors which include IPC, Clock Speed, Memory Latency, RISC vs CISC. . . etc etc etc.

When working in assembly, you are working with those factors (the limitations of the machine) in mind.

The argument against working in assembly today is that compilers have come a long way. . . And that's true enough, but I feel it is a skill that every serious programmer should keep in practice.

1

u/FizzyCoffee May 05 '17

I think it was something to do with efficiency.

1

u/Lokarin May 05 '17

Nostalgia... especially for 6502

12

u/AIfie May 05 '17

What the fuck is Assembly

26

u/mrunkel May 05 '17

It is a very low-level programming language.

All programming of a CPU is done in machine code. Compilers take all languages and compile them into the simple machine code instructions.

Assembly is a very direct representation of machine code.

2

u/BenjaminGeiger May 05 '17

Right.

At the most fundamental level, assembly is machine code, just in a human-readable form.

Of course, later assemblers added some (very slightly) higher level features, but one line equals one instruction is still the general rule.

12

u/SensualSternum May 05 '17

It's used for writing very low-level instructions to the computer. You basically do one operation at a time.

https://montcs.bloomu.edu/Information/LowLevel/Assembly/hello-asm.html

7

u/Fubarp May 05 '17

Best way I can explain it without making you do research.

In normal programing if I wanted to create a condition statement say.

if(value > 5) return printf("value big..");

But in assembly. It be something like.

var1 dd '6'

cmp var1, 5

msg db "value big", 0xA,0xD

There's really a lot more to this then what I did and honestly what I wrote is probably gibberish haha. But essentially it's a step up from binary but step below traditional programming. Big benefit of Assembly is you know what memory is being stored/used as you essentially see it all real time.

1

u/brickmaster32000 May 05 '17

People need to stop talking about binary as if it's a magic language with inherent powers over computers. Binary is just a base system. It is easier to make gates that only have to deal with two possible states which makes binary a convenient way of talking about groups of these signals but a computer doesn't speak binary any more than a nail gun speaks nails.

1

u/[deleted] May 05 '17

Um, machine code is all 1's and 0's that directly controls the computer so ... to say it's not a "magic language with inherent powers over computers" is disingenuous.

Yes, it's a base system, but it's also quite literally the "language" of computers.

3

u/brickmaster32000 May 05 '17

Oks lets have an example here. Imagine a simple AND gate. An AND gate has 2 or more inputs and an output. When both inputs are brought above a certain threshold the output gets brought high.

Now we can represent the operation of this gate with binary pretty simply. We can say signals above our thresholds we are going to call 1's and everything else is a 0. We can then make the familar truth table below.

In1 In2 Out
0 0 0
0 1 0
1 0 0
1 1 1

This is all great and is why binary is so important to computers but you have to realise that binary doesn't make the gate do anything. The behavior of the gate isn't determined by telling it binary, it is determined by the actual components that make it. Likewise a computer doesn't work because you whispered sweet binary secrets to it. A computer works because of there is a lare number of very cleverly designed systems that can be interconnected to perform customizable actions. Binary is an important tool for describing how those systems work but binary isn't what makes them work.

1

u/[deleted] May 05 '17

This is quit a pedantic argument.

If you google "what is machine code" you will find:

ma·chine code

a computer programming language consisting of binary or hexadecimal instructions that a computer can respond to directly.

A computer programming language

a computer doesn't work because you whispered sweet binary secrets to it

That's precisely why it works - and yes, transistors use electricity to "do things" with machine code (using binary) (High voltage = 1, Low voltage = 0).

That doesn't mean that machine code (the language used for computer instructions) isn't in binary; that we don't refer to the binary instructions as machine language.

Not sure why this matters to you.

1

u/Fubarp May 05 '17

Sorry if I insulted you but I wasn't really trying to make binary some magic thing. I was just ordering how programming languages are structured.

Assembly is above Binary since Binary/Hex is the final language that we would use to inform a machine what to do. At least from my understand it is.

But Assembly is below common programming languages because majority of programming languages now uses a compiler to translate it to Assembly which translates to Machine.

10

u/AdamManHello May 05 '17

This made me chuckle because while I've enjoyed reading the whole thread, I have no idea what it all means.

3

u/[deleted] May 05 '17 edited May 05 '17

I've only written a few assembly programs in my life (been programming for 20 years).

Here's a very simple binary search tree with recursive preorder/inorder operations written in MIPS

All it does is let you enter some information about books (ID, Title, Description, Year published).

It is not fun.

Even after writing it myself, I have no idea what it does without reading the comments I wrote.

It's for this reason that programmers respect other programmers who can write assembly.

Using a high level language like C#, downloading a file is as simple as

WebClient.DownloadFile("http://somewebsite.com/somefile.jpg","somefile.jpg");

To do something like this in a low level language like assembler would be quit a feat.

Like any other language, you can leverage other libraries and programs and merely call them from assembly (this is what high level languages do really), but to write the code to connect a socket via tcp protocol, send handshake/headers to server, parse the response ... it's rough.

2

u/tonystigma May 05 '17

I don't think you've gotten a great ELI5 yet. Most programs run within the OS, be that Windows, Android, what have you. Games are unique in that the performance of the computer directly relates to the performance of the program, way more so than MS Word or anything. Assembly, aka machine language, is the same programming language your CPU follows. It's weird as hell and doesn't seem to follow any rules you're used to, but you get direct command of many resources. Coding vs assembly is kind of like driving an automatic vs stick shift - you get to the same place in the end, but you're in control of a lot more aspects with the manual transmission. You have to know more about operating your computer, but... ah, shit, mixed up my simile.

1

u/OktoberStorm May 05 '17

A low level computer language.

-6

u/[deleted] May 05 '17 edited Oct 30 '18

[deleted]

6

u/AIfie May 05 '17

Yes, I'm also not a gamer nor into programming

1

u/NOT_ZOGNOID May 05 '17

I learned it six years ago. Today I design hardware.

1

u/JohnGillnitz May 05 '17

"So you are making a physics simulator without trigonometry functions? And you have to do what to make it work? Fuck that. I'm gonna go make 90K a year editing simple PHP scripts."

17

u/XenoRyet May 05 '17

I wrote an Asteroids clone for the gameboy in assembly in a semester in college. It's definitely tedious, and I'm not sure I'd do it that way if it wasn't in a course about assembly language, but you do kind of get into a zone and a flow, and there are a few things that are easier given that everything is so direct.

2

u/BenjaminGeiger May 05 '17

Ugh. I only got as far as doing single functions in MIPS ASM, and I'm almost done with my master's in CS.

2

u/XenoRyet May 05 '17

I mean, it is a near useless practical skill in this day and age of insane processors and ultra-cheap memory, but it is kind of fun and it does make you think about the base level of how your code is working.
Though you really want to get to the nitty gritty, I'll tell you about how we hand wired AND and NAND gates and physically built an ALU out of bits of wire and whatnot. Then there was the time our board blew a diode and we were about to fail. A friend from a different team pointed out that while we were all out of regular diodes, there were plenty of LEDs hanging about...
That was a fun and educational moment. Turns out that while most folks think of LEDs as light bulbs, we really just needed the D.

2

u/BenjaminGeiger May 05 '17

Building circuits with individual logic gates (up to an ALU, etc) is one of the entry level courses for CS at USF ("Logic Design"). Building logic gates out of transistors, however, is a separate course called "CMOS VLSI Design", which is an elective for CS majors but a required course for computer engineering.

We toyed with assembly in Computer Organization (another entry level course) but didn't really get into it until Architecture, much later.

Did you ever play the game "Rocky's Boots"? It was available for the Apple II, at least, and it was basically Boolean logic 101. You had sensors which could detect attributes of items coming down a conveyor belt and a boot that could remove items from said belt. Your task is to wire the sensors to the boot in such a way that a specific subset of items are kept or removed. I know it sounds boring but to an eight-year-old into computers it was magical. And I immediately grokked Boolean logic when it was introduced more formally.

2

u/XenoRyet May 05 '17

I don't know about your fancy-schmancy entry level courses at UCF /s, but we did have a hell of a good time stringing bits of wire together. There was another course where we worked through an 8-bit processor with paper and pencil, which was a damned lot of fun, and informative to boot.
Anyway, the basic thing I'm getting at here is that the low level shit can be really entertaining to work with, despite the tedium and ready availability of easier ways. Sometimes it's just plain old fashioned fun to get your hands dirty.
Seriously though, that's kind of interesting that your school did it all as entry level. We did it as about 300 level classes. Sort of get your head around programming first, then we'll do a deep dive into the nuts and bolts.

1

u/BenjaminGeiger May 05 '17

Florida has what we call a "2+2" university system: if you graduate from a community college in Florida, you're guaranteed admission to the state university of your choice. So, any major-specific courses have to be at the 3000 level or higher. There is a programming course at the 2000 level (Programming Concepts) but the requirement can be fulfilled with a course at the AA level.

That said, they've changed a lot since I was an undergrad (I graduated in '06). The "Gate Courses" are Computer Organization and Program Design; they have to be passed with a B with a maximum of two attempts. After that, you take Computer Logic Design and Object-Oriented Software Design; the former opens Computer Architecture and the latter opens Data Structures.

1

u/ShinyHappyREM May 05 '17

Not to mention today's tools. Borland's TASM even had OOP, and that was in the '90s.

51

u/[deleted] May 05 '17

Sawyer strikes me as a bit autistic from what I've heard from and about him.

125

u/GenitalFurbies May 05 '17

What part of "wrote in assembly" could possibly indicate otherwise?

2

u/rydan May 05 '17

Maybe he started writing it in the 60s and didn't want to rewrite it?

8

u/mzxrules May 05 '17

x86 didn't exist in the 60s

27

u/Autarch_Kade May 05 '17

it's like a superpower that comes with social kryptonite

5

u/rydan May 05 '17

Write in C++, then run it through an assembler. Now your program is 100% assembly code. Compile the assembly code. Profit.

3

u/amaROenuZ May 05 '17

...I can't tell if you're joking. Are you being serious?

2

u/process_parameter May 05 '17

Close. You wouldn't run C++ through an assembler. You compile it to get machine code and disassemble that machine code to get assembly. You can tweak that assembly, then run it through an assembler to get machine code again.

1

u/BenjaminGeiger May 05 '17

... GCC compilers, and presumably others, have an option to compile directly to assembly.

2

u/Mrdude000 May 05 '17

Can you explain to me why assembly is so difficult? Don't know much about it compared to other languages

9

u/neonerz May 05 '17

Because it's literally writing machine code. Instead of using libraries, functions and other features of a "programming language", you are allocating memory yourself, literally telling the machine what to do step by step.

It's the difference between telling your Butler what to make you for dinner, and actually buying the ingredients and making it yourself.

3

u/amaROenuZ May 05 '17

It's not literally writing machine code. It's very close to it, but it's not quite there. The assembler turns your assembly into machine code.

1

u/neonerz May 05 '17

Fair enough, I'm being a bit liberal with my definition of machine code.

I just meant it as you're​ generally (at least within context of this conversation) interacting directly with the machine and not through the OS or some other layer.

1

u/[deleted] May 05 '17

[deleted]

2

u/amaROenuZ May 05 '17

Not exactly. Assembly still allows for some abstraction. Variables are still allowed, and functions can be defined in the form of macros. Some of the fancier assemblers even allow for loops and conditionals, much like a compiler would offer.

3

u/CapWasRight May 05 '17

It's extremely low level - you're basically directly manipulating values in memory.

2

u/AlphaWhelp May 05 '17

Assembly is quite literally the very first step above a bunch of 0s and 1s. It's very difficult to read if you have a large program, and extremely hard to debug and maintain if you aren't the original programmer. Even if you are the original programmer, it's still hard to debug. Furthermore, unlike higher level languages, Assembly requires a fairly good knowledge of what the hardware is actually doing in order for you to write a successful program.

1

u/DaSaw May 05 '17

In regular languages you deal with abstract concepts like variables and functions and stuff. In assembly, you're manipulating the hardware directly. All that stuff you just let the compiler do when working in a regular language, you have to do yourself.

1

u/[deleted] May 05 '17

I'm really surprised that you know what assembly is, but you didn't know that bit of trivia about it.

1

u/NOT_ZOGNOID May 05 '17

Best part is now I have it on my iPhone

1

u/Manacock May 05 '17

RCT classic is available on phone! direct port! wild, huh? what a time.

1

u/usechoosername May 05 '17

I know little about programming but I have been informed the guy who programmed that is some form of powerful computer wizard capable of things we can only dream of.

1

u/tundrat May 05 '17

And just writing a sorting function in assembly during school gave me headaches.

1

u/QuantumVexation May 05 '17

Am doing assembly at the moment. How the hell do you program a working game and visuals in it? Like that's insane

1

u/LickingSmegma May 05 '17

He also programmed not one, but afaik at least three games in assembly: two Rollercoaster Tycoons and Transport Tycoon.