Assembly language?

Started by
21 comments, last by Embassy of Time 5 years, 8 months ago
15 hours ago, gaxio said:

You've strayed far, far into DIY territory and something that's not even practical or even in wide use in game development.  You will find generic information about assembly language programming, of course, but you won't really find anything about game development.

I have to add some caveats in here. True, nobody builds games in assembly. But there are certainly uses for it. It's still common to write SIMD routines in assembly, especially newer instruction sets where the compiler intrinsic support is either not available or just doesn't work that well. PS3 SPUs were frequently coded in assembly. And debugging often involves going over the assembly code being emitted and run, in order to understand what's going on. Performance optimization also frequently requires analysis of the compiler output to fully achieve the desired results. 

We're not writing in assembly or even reading it on a regular basis, but you better believe that it comes up plenty in games.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement

I also started with assembly in the '80s and agree it can be really good fun, and I'd recommend anyone to have a dabble with learning it, not so much because it is likely to be useful itself these days (except specific areas) but so you can understand how compilers work, how interpreted bytecode works, what is the difference etc. Those youtube tutorials brought back memories of writing sprite drawing routines etc.

As said the reason why it is less relevant now is because in the old days you had direct access to screen memory (and because the compilers now are so damned good!). Now everything is done through APIs, the CPU doesn't have direct access to screen memory (or you shouldn't write as if it does). So writing assembly to call OpenGL for instance is kind of pointless, because it's the same thing as calling OpenGL from e.g. C, you are gaining nothing by doing it in assembly.

And as promit says it is still used in the form of SIMD (mostly via intrinsics), which is really fun. Kind of things I've used SIMD for recently are for CPU graphics techniques, vector math and audio.

If you are determined to make a small game in assembly you might want to look at emulators for simpler (older) computers which do have a 'screen memory'. As a bonus the assembly will be easier I think because of less instructions. It's not that tough, it's the same concepts as writing modern games, just simpler .. game loop, input, displaying stuff etc. Back in the day we wrote all the tools in assembly too, sprite editors, map editors etc.

Just to make it perfectly clear, I am NOT turning my entire game creation hopes over towards assembly! Even I am not that outrageously insane ?

I had hoped to make a small game, just to test myself, in the style of ZX Spectrum or early Atari machines, just moving some dots around (Space Invader comes to mind). But am I correct to understand that assembly language cannot access the screen? I can't write assembly code that puts a series of dots on the screen without using some other, non-assembly language? Because that would defeat the entire idea of making a small game 100% in assembly language :(

[DEDACTED FOR SECURITY REASONS]

19 minutes ago, Embassy of Time said:

Just to make it perfectly clear, I am NOT turning my entire game creation hopes over towards assembly! Even I am not that outrageously insane ?

I had hoped to make a small game, just to test myself, in the style of ZX Spectrum or early Atari machines, just moving some dots around (Space Invader comes to mind). But am I correct to understand that assembly language cannot access the screen? I can't write assembly code that puts a series of dots on the screen without using some other, non-assembly language? Because that would defeat the entire idea of making a small game 100% in assembly language :(

You have a few choices, either get a really old computer with a really old graphics card and then you can do what you want, or you can just write to a block of memory and then copy that to the GPU. Come to think of it, you should also be able to just open a buffer on the GPU and write to that directly and display it, and then for the next frame do the same thing using a second buffer. Then you just flip back and forth like the normal swap chain. In any case I think you can do more or less what you want, you just need some minimal Direct X or OpenGL code to handle the setup and swapping of buffers. 

Assembly is very much alive in games development, but its in the "retro-revival" scene where you will find it.

Look to the C64 or ZX Spectrum 48K as a starting point, as they are backed up by a wealth of learning material, and their architecture are basic.  The community support is good and the emulators and tools are ideal for the beginner.

As a programmer I found Assembly to be essential study, as you get an much better idea on what is happening at the hardware level.  As a maker of games( well, demos in all honesty ) I don't see its use beyond the 16-bit era of machines, but lets just say the "language" fits the size of the programs you can expect to make for such classic machines. 

Whilst we are on the subject, would it be possible for GameDev to have a sub-forum dedicated to retro development?  It gets a little tiresome when met with the usual "why would you want to do that?" when posting on the subject, and it would help to connect those of us who do have such an interest...

Languages; C, Java. Platforms: Android, Oculus Go, ZX Spectrum, Megadrive.

Website: Mega-Gen Garage

For Uncharted 4, they used intrinsics to make the multicore architecture working at max potency for the Ambient Occlusion.
Assembler gives you the deepest control over the hardware.
You can combine the beginner tutorials with the documentation of Intel, which is extremely explicit and available for free online.
You can search for the assembler community in G+. They like to help and I have seen people there making games for assembler, still nowadays, still now.
If you are gonna use ASM, please be aware that in a perfect scenario ASM should be used in conjunction with C/C++.

I find it amusing, how .kkrieger is mentioned as motivation, given that it is written almost entirely in C++:

https://fgiesen.wordpress.com/2012/02/13/debris-opening-the-box/

https://github.com/farbrausch/fr_public

 

As for the main question - I would like to know the answer myself.

I'm rather sceptical of the video-tutorials (of pretty much any kind) on the subject. What I want is a proper textbook. And there doesn't seem to be many of those around.

I get the impression, that the mindset is like "whoever wanted to learn assembly did it in 90's already, and if you are trying to learn now - sucks to be you", which is unfortunate.

My best suggestion would probably be using books (& environment, e. g. DosBox) from 90's and then slowly assimilating information on more modern assembly, scattered on the net. Which is... suboptimal.

About the best recent textbook on assembly I know of would be "The Art of Assembly Language", which for one thing I would not call exactly 'modern' anymore, and for another has made some questionable choices for my tastes (fascinations with macros is one example: they might be useful to write assembly, but arguably not to learn it).

There is "Intel 64 and IA-32 Architectures Developer's Manual", of course. That is a great reference, but it is frightening trying to imagine someone trying to use that behemoth as a textbook.

I wouldnt waste time learning DOS 16 bit Assembly with its weird segmentation and quirky register use. If you want to learn Assembly, just start with a modern 64 bit form.

18 hours ago, wintertime said:

I wouldnt waste time learning DOS 16 bit Assembly with its weird segmentation and quirky register use. If you want to learn Assembly, just start with a modern 64 bit form.

Ha!

I already skipped DOS 16 bit assembly in the 90s, buying an Archimedes with ARM processor (whopping 8MHz, but out-performing a 386DX 40MHz), and foremost, a nice flat 32 bit address space.

This topic is closed to new replies.

Advertisement