Sigh.
Quote:Now, don't preach me about Asm portability in linux,
Oh, how come the calling conventions, available interupts and even the syntax differ. Do you recognize the following code, its valid x86 assembley code:
Code:
.data # section declaration
msg:
.ascii "Hello, world!\n" # our dear string
len = . - msg # length of our dear string
.text # section declaration
# we must export the entry point to the ELF linker or
.global _start # loader. They conventionally recognize _start as their
# entry point. Use ld -e foo to override the default.
_start:
# write our string to stdout
movl $len,%edx # third argument: message length
movl $msg,%ecx # second argument: pointer to message to write
movl $1,%ebx # first argument: file handle (stdout)
movl $4,%eax # system call number (sys_write)
int $0x80 # call kernel
# and exit
movl $0,%ebx # first argument: exit code
movl $1,%eax # system call number (sys_exit)
int $0x80 # call kernel
You will find that if programs using assembler that have been ported to other architectures/operating systems will have different versions of the assembler code for each.
Portability is the art of writting code that can work without modification on any system, the above wont but this will (given a C compiler):
Code:
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
Completely portable, no recoding necessary /ever/.
Quote:And where did I lambast somebody here?
No you didn't, I was talking about Blitz having a short temper with Megaman. Discussion forums are okay for opiniated arguments, but not for absuing people directly.
Quote:He used ASM because Delphi could only go as fast.
Quote:As you may already have known, it's not the language but the logic behind the algo itself.
Very true. It also depends how well you know your language and compiler. For example both of these copy a string source to string dest in C:
Code:
int strcpy(const char *source, char *dest) {
int i, len;
len = strlen(source) + 1;
for(i = 0; i < len; i++) {
dest[i] = source[i];
}
return 0;
}
But the following one is much faster in most implementations:
Code:
int strlen(const char *source, char *dest) {
while(*source) {
*dest++ = *source++;
}
}
Like you said, give an idiot DX and he code a dumb DX game, give a good programmer any language and they will program a damn cool game.
Quote:wait, is this guy saying asm isnt good for coding? bah. trust me, buddy, you want asm code. it's your friend.
Okay, for starters I can code assembler for the following architectures: Mips, sparc (32bit), x86 and the M68HC12. I know when its useful and when its not, and I know its a pain to learn each new architecture, its calling conventions, register sets, etc etc.
Quote:and no matter how good your compiler is, it's not better than the brain at optimizing.
Maybe not, but writting high level C code and then translating to asm would be a much better start than coding asm from scratch. Also, compilers are getting pretty damn smart these days, gcc optomizations flags include such things as: making all functions inline, bulk stack popping, forcing register arithmetic, omitting the frame pointer, loop unrolling, reordering delayed branches, etc etc.
A good read on the pros and cons of using assembley is here:
http://linuxassembly.org/howto/doyouneed.html