Jump to content


asm engine


83 replies to this topic

#1 Sephir

    New Member

  • Members
  • Pip
  • 2 posts

Posted 05 May 2006 - 11:28 AM

Well, I've been programming for sometime now in C++ and honestly I got tired of it. Basically there's nothing else that attracts me more in C++ and since programming is a hobby for me, I wish to take a new, different path. I decided to go assembly.

I've been googling and taking a look at Devmaster.net but I can't really find a game (or just rendering) engine for the assembly medium. Maybe because people are afraid of programming in assembler due to the time spent to write and debug, or maybe people are really only interested in C++ because for some it might be more simple.

I took a look at the revamped TripleBuffer also and the asm resources are okay but none that really fullfills my needs (for description' sake).

My question is if anyone interested in programming in asm knows about any sort of asm engine out there. If any I think it would be a great addition to the programmers community. If there isn't then I think I will have to drop my hopes or start everything from the ground up which would take a lot of time.

Any useful information would be great.

Thanks for your time.

~Sephir.

#2 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 05 May 2006 - 03:20 PM

Be my guest, clicky

#3 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 05 May 2006 - 03:49 PM

I'm an assembly nut, but I still value C++ very highly. I regard C++ as a tool to write assembly code in situations where absolute control and performance is not required, which is the case most of the time. So I don't really understand how you got 'tired' of C++. Can I ask how many years experience you have? Personally I have about six years experience in both C++ and assembly, and I use both almost daily, but I can't imagine writing everything in assembly. That's just tedious, error prone, ugly and very hard to manage. I only use it where it's more suitable for the task.

I think all you need is an exciting project to work on, not another language.

#4 Ed Mack

    Senior Member

  • Members
  • PipPipPipPip
  • 1239 posts

Posted 05 May 2006 - 07:26 PM

Quote

I think all you need is an exciting project to work on, not another language.

Here here.

#5 cypher543

    Member

  • Members
  • PipPip
  • 74 posts

Posted 05 May 2006 - 08:37 PM

If you are still interested, here is an open source 3D RTS created entirely in 32bit Assembly: http://www.oby.ro/rts/index.html

#6 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 05 May 2006 - 08:49 PM

"Hostile Encounter RTS" said:

It is written in FULL 32bit Win32ASM for great speed and effects
...
* We want to make XBox, Linux and MacOS versions also.

Why the hell would you write all of a game in assembly if you are planning on porting it to completely different architectures? :wallbash: What a porting nightmare!

When they say MacOS, do they mean after Apple switches to Intel chips? :surrender
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

#7 kariem2k

    Valued Member

  • Members
  • PipPipPip
  • 207 posts

Posted 06 May 2006 - 12:39 PM

Why again you are bored from C++?Thats ok,but moving to assembly :blink: sorry for all assembly fans (I am one of them and i have experiance in asm) :) but assembly is not practical for todays gaming requirments and of course it is not for any indie who wants to develop a game.
There is a point i want to clarify,This is the learning path of assmbly: after learning some 8086 assembly for dos you will need to go to win32 assembler and after a bit you will find that you are ruled with the same windows APIs which you have in C++ but with much work to do and nearly no performance boost because the compilers makers are much much experianced than you(since you are a hoppiest) so the code generated with compilers will be much optimized than your code.
Assembly is interesting if you want to explore new things which are not represented to you by any higher programming langauge and if you want to learn reverse engineering (Thats why i have learned assembly), But it is not practical for medium to large applications and it will be a time waste.
If you want to learn assembly there is http://win32asm.cjb.net and "The art of assembly" free ebook and reading source codes.
If you want engines that use assembly,i did not hear about any new engine that uses assembly but there is TGE which uses assembly for some textures blending,Doom(gpl),Quake(gpl),and i think Quake 3(gpl).
Sorry for the negative feedback :).
bye

#8 juhnu

    Valued Member

  • Members
  • PipPipPip
  • 292 posts

Posted 07 May 2006 - 05:03 AM

Quote

Why all in ASM?
This is a complex matter of oppinion. Here are some of my arguments IMHO:

* We know ASM well. ASM is also very easy to learn
* Speed is of the essence in GAMES. ASM is 100% up to 300% faster than today "optimized" compilers
* There will allways be ASM code in a GAME so: Why NOT write all in ASM?
* ASM is free, cant tell that about Most HLL Compilers
* We dont like BLOATWARE generated by most of today HLL compilers
* Very good tutorials at Iczelion's site and web support from Hiroshimator's Win32ASM messageboard make the difference
* A Game req. maximum control over the hardware and software
* ASM gives total power and maximum flexibility
* It is FUN!


It's interesting how people assume hand-written assembly being always faster. Not that these other reasons why they chose asm are any better..:wallbash:

#9 Axel

    Valued Member

  • Members
  • PipPipPip
  • 119 posts

Posted 07 May 2006 - 08:48 AM

Let them learn it the hard way ;)

#10 Alex

    Valued Member

  • Members
  • PipPipPip
  • 152 posts

Posted 07 May 2006 - 04:37 PM

I don't know about you..but C/C++/asm or any other language is just a tool to build what ever you want. The fun thing for me is to build something interesting (neural nets sim or what ever) using what ever tool is most apropriate. It doesn't hurt to know some asm because it can be helpful when debugging and it gives you some clues about how your systems works. But apart from some exotic problems you'll hardly ever code in asm...unless just for hobby fun...
Alex

#11 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 07 May 2006 - 04:50 PM

juhnu said:

It's interesting how people assume hand-written assembly being always faster.
It's true actually. It's just not always easy.

#12 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 08 May 2006 - 01:00 AM

Are things like instruction pipelining still doable on today's wide market of different x86 architectures? I mean, in the old days you knew the CPU your code was going to run on. Today, AMD and Intel processors totally differ from eachother, and with things like hyperthreading good pipelining seems like a waste of time (as stalls are filled up by the other thread, or according to the theory at least).

That was more like a serious question than it was retorical btw, haven't done any hand-written ASM in ages. The last time I checked an instruction reference manual was when AMD introduced their 3dnow :wub:
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#13 juhnu

    Valued Member

  • Members
  • PipPipPip
  • 292 posts

Posted 08 May 2006 - 02:40 AM

Nick said:

It's true actually. It's just not always easy.
My point exactly. What I meant was that it's true only if you know what you are doing and have enough time to actually do it. Just writing everything in asm won't automatically give you 100%-300% performance, which they think it does (especially when asm encourages micro-level optimizations instead of algorithmic ones).

#14 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 08 May 2006 - 08:23 AM

.oisyn said:

Are things like instruction pipelining still doable on today's wide market of different x86 architectures?
Ever since the Pentium Pro (1995), desktop processors are capable of out-of-order execution. This means they look for the next (independent) instruction to fill their pipelines themselves.

#15 Dias

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 08 May 2006 - 09:07 AM

Why stop at asm? write 1´s and 0´s for ultimate performance :P

Seriously though, if you want to do it just for fun/learning then go ahead,
but i doubt very strongly that that the speed gain overweights anything else
that higher-level languages offer.

#16 SmokingRope

    Valued Member

  • Members
  • PipPipPip
  • 210 posts

Posted 08 May 2006 - 09:16 AM

This thread is awesome! I wouldn't have ever thought to start reading win32asm source-code at 5:15 AM but thanks to this thread that's exactly what i'm doing!!!

#17 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 08 May 2006 - 12:29 PM

Dias said:

Seriously though, if you want to do it just for fun/learning then go ahead, but i doubt very strongly that that the speed gain overweights anything else that higher-level languages offer.
Do you know assembly or are you just guessing? :mellow:

High-level languages use the lowest common denominator, which is just basic 32-bit operations. Modern processors offer a whole lot more, like complex operations and vector operations.

One example of a complex x86 instruction is 'bsr', which stands for 'bit scan reverse'. It returns the position of the first 1 bit, starting from the most significant bit. This is equivalent to an integer logarithm, and can be very useful in some projects. In a high-level language it takes many operations to compute this value. Vector operations use MMX and SSE. SSE can make many floating-point intensive calculations up to four times faster. Examples of real-life software that use (some) manually written assembly code are: audio and video codexes, physics engines, raytracers, drivers, low-level libraries, etc.

Obviously I agree that writing everything in assembly is useless, but using it in some hotspots can be very rewarding to take the application to a whole new performance level. And even if you have no direct use for it, it's still very valuable for debugging. Issues that can take days to debug at high level can become amost trivial when looking through the assembly code.

#18 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 08 May 2006 - 12:44 PM

For those interested in learning assembly code, here's an excellent tutorial: PC Assembly Lanugage.

But avoid using an assembler directly (and skip the assembler specific topics in the tutorial). Instead, use inline assembly in C++ to make life easier:

#include <stdio.h>


int main()

{

	int a = 345;

	int b;


	__asm   // Start inline assembly block

	{

		mov eax, a     // Load 'a' from memory into eax register

		bsr ebx, eax   // Compute integer logarithm (base 2)

		mov b, ebx     // Store result to memory

	}


	printf("log2(%d) = %d\n", a, b);

}



#19 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 08 May 2006 - 02:00 PM

A fast equivalence in pure C++ without __asm blocks
int main()
{
	int a = 354;
	int b;

	unsigned value = a;
	// replicate top bit
	value |= value >> 1;
	value |= value >> 2;
	value |= value >> 4;
	value |= value >> 8;
	value |= value >> 16;

	// count bits
	value = ((value & 0xaaaaaaaa) >>  1) + (value & 0x55555555);
	value = ((value & 0xcccccccc) >>  2) + (value & 0x33333333);
	value = ((value & 0xf0f0f0f0) >>  4) + (value & 0x0f0f0f0f);
	value = ((value & 0xff00ff00) >>  8) + (value & 0x00ff00ff);
	value = ((value & 0xffff0000) >> 16) + (value & 0x0000ffff);

	b = value - 1;
	printf("log2(%d) = %d\n", a, :wub:;
}

C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#20 Dias

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 08 May 2006 - 02:23 PM

Nick said:

Obviously I agree that writing everything in assembly is useless, but using it in some hotspots can be very rewarding

I guess i could agree with that though :)
However i feel theres too many discussions about speed around development forums when there are many other important factors to consider as well.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users