jump to navigation

Why is learning assembler-democoding easier than C-democoding? August 24, 2005

Posted by winden in coding, demoscene.
trackback

This may be a shock for some of you, but in fact I think that’s true. Let’s take a simple thing… loading a texture to use it for a rotozoom for example. If you were coding in C, there is no easy way (for a complete beginner) to load an image into memory.

The C-approved method would be to use a library that takes a filename and decodes it into a memory area. But, first you have to learn how to link to libraries, and then how to use said library to load the image. And it even depends on the operating system, you will end up using quicktime, sdl, datatypes.library or some windows thing.

Compare it to the asm-approved method: using raw data. Take your image and load into a converter, save it to raw, and then use “incbin” to place the data into the executable. No libraries, no external files, no whatever. Just mere bytes, and only the bytes we really need, the image ones and not any extre header nor footer data to confuse things. Just learn to save the raw data from the converter and there you go.
Simplicity is golden, even more so to a beginner.

Comments»

1. blub - April 28, 2008

Hey, you didn’t notice, that
1) rawdatas are fat.. they take away way more space
2) you can do exactly the same trick with C/C++ just use an array filled with char/unsigned int/whatever…
(however using asm is great ;) )

2. Optimus - June 12, 2008

It is and it is not at the same time.

I like simplicity. I like when I had a BAS file in Quickbasic in the past and pressed F5 to run. Not having to create a new project, to search if it’s main or winmain, the linker/compiler options, etc, etc. At least when I first went from qb to C I was dazzled. Now I am used to C even if I still get confused when I get someone else’s code project with tons of file and I know 90% it won’t compile at the very first try :P

Assembly has the simplicity that it gives you some registers and some opcodes and let’s you do the rest. If you are not lazy or inexperienced it’s a breeze. It all depends to you and you don’t search if there is a linking error because of some stupid compiler option you didn’t specified or making sense of a confusing structured lib or having to write ten lines of something to open a window in MFC or anything.

Sometimes I need to open a compressed image for a specific project and so I have to use a lib in C. When I was too lazy to search for a proper lib I used the raw data technique but putting all into the exe file and let the executable compressor do it’s job. I might still be doing it in the future because I don’t like when demos have tons of files extracted instead one data file or everything on the exe. But I guess I’ll be using the SDL image library more frequently now I know how easilly it works.

Now I am used in C, at least not using very sophisticated libs but only what necessary and doing the rest myself, it’s harder for me to write in asm. Though when I do the feeling is still great!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: