Computer Science Canada

How to actually do....well anything in assembly.

Author:  mirhagk [ Sat Sep 11, 2010 1:19 pm ]
Post subject:  How to actually do....well anything in assembly.

I have been working with assembly lately, specifically HLA (High level assembly). I have read a couple book on assembly, I understand the concepts behind and I use exclusively the low level control statements instead of HLA's control strutures.

THe problem is, I want something more than super fast math algorithmns displayed in a console window. I want to use the math and assembly skills in a program that would test them to the fullest. I want to make a game. I can do everything else in the game, but I have been unable to find anything on how to actually make graphics. The only tutorial I have found about video mode does not work with HLA (It says memory violation if I try to call int 10h to switch to video mode) I suspect it has something to do the tutorial being about 16 bit assembly, when I'm working with 32 bit assembly.

What I need is a way to set a pixel on the screen, it does not have to be inside a window, (I'd prefer full screen anyways), it does not have to use any window type functions. I just want a way to change the colours of a pixel on the screen, it can even be something like 320x200 256 colour video mode, I don't care, I just want to be able to change a single pixel's colour.

Can anyone out there help me? I know it's a long shot, but please if you know how to do it, or anything, can you please help me.

Author:  DtY [ Sat Sep 11, 2010 5:59 pm ]
Post subject:  RE:How to actually do....well anything in assembly.

I assume you're working with Win32?

After DOS, you can no longer control the screen directly by writing to memory (this is 16 bit stuff you've found). This wont work past Windows XP, and may not even work on XP (also wont work on the NT line at all) (you can run them in DOSBox though). In Win32, you have to use the C libraries to create windows, draw to them and all that. Unfortunately, these were of course designed for C, and not for Assembly. But, you can still access them, it's just a bit more difficult.

First off, I'd suggest learning how to do this stuff in C, it will make it a lot easier when you try to use the library is assembly.

After you're familiar with the library, you'll have to learn how C functions are called. C is compiled to the same thing as assembly, so anything C can do, assembly can do as well. Basically, the way you do this is push all the arguments you would pass to the function onto the call stack, and then jump to the location of the function. When it returns, the return value of the function will be left on the stack. Just beware that you will have to manually cast all arguments to the right type, C will do this for you, but assembly has no knowledge of it. I haven't actually done this, so you'll have to look for a tutorial online for it.

Author:  mirhagk [ Sat Sep 11, 2010 11:43 pm ]
Post subject:  RE:How to actually do....well anything in assembly.

Thank you very much, I remeber the code working before, I thought it was because it was a different assembler, makes sense that it was because it was on an xp computer not a vista computer (the one I'm on now). Since I still have the xp one, and the school's computers are all xp, I may just stick with that, it's so much easier to do. Also I may get a dos emulator for it to run in.

I will try and attempt to use win32 with assembly, but I hate win32 regularly, it makes everything overly complex for no reason. so I'm not looking forward to a assembly version.

Well thanks so much, you just enabled me to finish my assembly raycaster.


: