Qbasicnews.com
Cobra - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Projects (http://qbasicnews.com/newforum/forum-12.html)
+--- Thread: Cobra (/thread-59.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19


Cobra - relsoft - 04-30-2003

Pardon my ignorance but if Linux runs on the x86 architecture, x86 assembly would too. :*). In fact ASM is not a language at all but a syntactic way to issue instructions on a machine level.

If linux do run on the intel x86 architecture so would any flavor of asm that supports it.

BTW, my code is not TASM or MASM or NASM based, it directly index the stack(manualy) registers so porting it would not be an issue. :*)

TASM is different from NASM or MASM as Basica is Different from QB.


Cobra - na_th_an - 04-30-2003

Assembly in Linux for i86s is just the same as it is in DOS/Windows. They only differ in the syntax.


Cobra - ak00ma - 04-30-2003

ASM is important for every codin' language...everytime something is too slow, you might use ASM to tune it up


Cobra - Blitz - 04-30-2003

Are we talkinga bout asm now? neato. Well, i replied to the same thing in the challenge post loose.

Asm is still used allot in the gamedev industry. Becuase there you have lots of innerloops which are time critical. In those situations nothing can replace asm. Not even the best compiler comes near a good asm coder. And it never will, until the day when computers learn to think (and do not twist my words on this one).

However, this does not say that coding something in asm will make it faster then a good compiler. DQB is the perfect example why some people should not use asm and compilers instead.

But compilers ( such as your precious gcc) generate general code. And they can't use such things such as mmx (i'm well aware of vectorC and intel c++), atleast in a good way. For instance, when when coding a sound mixer, you can process up to 24 samples in the same times it takes to process one with normal code.

But ignoring things like that, knowing asm makes you a better high level coder as well. Becuase you know how the computer works and you're able to analyze the code the compiler generates.

That's enough reason to learn it.

And personally, i try to get my code to run as smooth on a p133 as it does on a 3 ghz cpu.


Cobra - toonski84 - 05-01-2003

so true.

nate, the one i gave him came from a raycaster antoni gual made, i think. it uses a poke to clear the buffer each time, and it fixed, at least with me, the problem with the arrow keys locking up.

i'd still recommend milo's though, because only assembly can properly set interrupt vectors and do it properly.


Cobra - LooseCaboose - 05-01-2003

Okay, okay. Im not trying to say that asm is completely useless to learn, just that I would (personally) recommend that people learn high level languages instead. For someone getting into general programming with an interest in making hobbyist games or simple applications, asm is way down the list of programming languages to learn. Moving to the future, things like Java and .NET are pushing programmers even futher away from needing asm. We are probably coming from different angles also, Im mostly into low-level system coding, and you guys are arguing from a game standpoint.

Quote:And they (C compilers) can't use such things such as mmx (i'm well aware of vectorC and intel c++), atleast in a good way
My version of gcc has arch flags for at least the following: pentium, pentium-pro, pentium-mmx, pentium2, pentium3, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp and can compile code that utilises the extended instruction sets provided by each of those architectures. This is difficult for a pure assembley coder because each instruction set is different and multiple asm files would be needed to ensure portability (with a C version you just need a architecture detection script).

Quote:Assembly in Linux for i86s is just the same as it is in DOS/Windows. They only differ in the syntax.
They aren't quite the same when you get into more elaborate asm coding because you have to adhere to the operating systems conventions, such as function call setup, available interupts, alignment rules, etc.

Quote:In fact ASM is not a language at all but a syntactic way to issue instructions on a machine level.
Not quite, most symbolic asm languages contain pseudo-ops and shortcuts. The assembler directives are all pseudo ops, and even some instructions can produce multiple instructions once at machine level. The only example I can think of off hand is one for the sparc where the set operation actually produces a sethi and an or instruction at machine level because a 32-bit word cant fit into a single 32-bit instruction.

Quote:But ignoring things like that, knowing asm makes you a better high level coder as well. Becuase you know how the computer works and you're able to analyze the code the compiler generates.
This is true, but again relates more to someone who is coding at system level, when programming in a highlevel language it is generally a bad thing (IMHO) to be trying to program to the architecture. As I said, most of the asm work I do I work at a high-level language first and then compile to assembler to get a head start. The strcpy code I posted early is an example of knowing what produces better object code in a high-level language.

As for speed of algorithms etc, I disagree completely on using asm. If an algorithm is too slow in a high-level language then it is time to start looking at your data structures and algorithm code to see if you can improve it mathmatically, asm should be a last resort for speed here. (Especially as most modern compilers support optomizations such as loop unrolling and inline functions).

Quote:Asm is still used allot in the gamedev industry. Becuase there you have lots of innerloops which are time critical. In those situations nothing can replace asm.

I havent seen enough comercial game code to be able to comment on this with any amount of certaincy, however I mentioned earlier that the Quake2 source doesnt contain /any/ asm code in the OpenGL version. Not enough game companies are releasing their source code to be able to effectively comment on this. Hobbyist games are not always a good source, because as you said people can code poorly in any language and produce slow code, which may lead them to believe that they need asm code when a little extra work at a high level would do the trick.

So if you are going to learn assembley, then learn when you do and dont need it, how it relates to other languages and what alternatives exist. Dont take what I said to mean that nobody should ever learn asm, I meant that with the vast amount of libraries and advancments in hardware and software speed, asm is becoming less mandatory for general programming. It is still, and always will be highly necessary for niche programming.


Cobra - relsoft - 05-01-2003

But then again, why are the most widely used of libs in any language made in ASM?

Portability?

Take any Assembler:

mov ax,yval
Xchg Ah,al
Mov di,AX
shr Di,6
Add di,ax
add di,xval

No modifications needed. :*)

"The is a big difference between something that runs on a 486 as opposed to something that *fly's* on a 486"

And why are you assuming the guy who made the DX water demo using delphi should look at his code again. I've seen the code and it's pretty much Delphi-optimized. But then he needed asm to make it better. :*) And believe me, the *guy* *knows* how to code.


Cobra - Blitz - 05-01-2003

Of course, if you're algo suxs it will suck just as much in asm. The things you're saying are pretty obvious. Look at UGL, a combination of good algos and good asm code. However a compiler could never do that. UGL is as fast at it is becuase good innerloops. A compiler could never even come near those loops.

If asm is so useless why was it used so much before computers had hundreds of megabytes of memory and cpus running at several ghz? These reason was obvious back then, there wasn't even a discussion. They needed to take fulladvantage of every cpu tick. But as cpus got faster and memory larger, they could make large and ineffcient programs. And the reason they do it now is becuase they can.

And gcc isn't even such a good compiler, it's a okay compiler. I highly doubt it uses simd instructions. I'd have to see it to belive it.

And to whoever's using asm code, portability isn't an issue for them. Becuase who actually uses asm? Game developers, for consoles you have to use asm, for pc you're probably coding it for win32. A hobbist, i don't give a horses ass about portability. I don't even like *nix.


Cobra - LooseCaboose - 05-02-2003

Quote:But then again, why are the most widely used of libs in any language made in ASM?
Standard C library, possibly the most widely used library of them all is coded in C. Mesa3D OpenGL implementation is written in C, possibly with some asm code for the device drivers (as I mentioned earlier). Wine, which includes an implementation of most of the win32 api is written in C. The Allegro game library is a mixture of C and asm.

Most game libraries only require the drivers to be written in asm (there is no other way here) but the remaining code can be written in a high-level language.

Quote:If asm is so useless why was it used so much before computers had hundreds of megabytes of memory and cpus running at several ghz?

Can you remember where I said:

Quote:IMHO assembler is hardly worth learning these days unless you plan to do low level system or embedded programming.

Note the phrase "these days", of course it was necessary in days of yore. Modern computers on the other hand a blindingly fast and have plenty of memory to burn. Assembler is still very much required for embedded programming where memory and speed constraints are still an issue. Im talking about application development here.

Quote:And gcc isn't even such a good compiler, it's a okay compiler. I highly doubt it uses simd instructions. I'd have to see it to belive it.
It does support simd instructions. In saying that its a not a good compiler, you are taking the one sided approach of speed again. Yes Intel's C can easily produce faster object code, however gcc runs on a vast number of architectures, has a very good support community (last time I had a problem with it, I got a reply from one of the developers within an hour), a well designed extension set, and excellent integration with other tools (automake, xemacs, cvs, indent, etc). Thats why I use it, not because I want highly optomized object code.

Quote:And to whoever's using asm code, portability isn't an issue for them. Becuase who actually uses asm? Game developers, for consoles you have to use asm, for pc you're probably coding it for win32. A hobbist, i don't give a horses ass about portability. I don't even like *nix.
The same game developers who are now releasing their games (often simultaneously) for win32 PC's, the X-Box, PS/2, Dreamcast etc. Are you claiming that any asm code is portable here? For consoles you code in C just like for everything else, most probably cross-compiled from a PC. As a hobbyist you may not care about portability, but for anybody doing serious development these days its a big issue because there is no single target platform for anything now. Applications are faced with the challenge of running on win32 and *nix and games are faced with a vast array of consoles.

Looking to the future the x86 line may soon be dropped being replaced by the IA-64 architecture, which may have backward compatible IA-32 support , but definitely will not run 16 bit x86 code. Also asm goes completely out the window when you shift to Java or .NET unless you really feel compelled to code directly in byte code ;-)


Cobra - Rokkuman - 05-12-2003

Anyways... the only question that comes to my mind is why do the keys get stuck in my game, but they work just fine on that demo... it's the same thing, and it's not like I'm having you hold down 6 keys or anything, the max is 3, and that didn't freeze the demo not once.