Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Assembler in DBPro

Author
Message
Sagan
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 25th Apr 2003 22:16
Is any way of including directly assembler code in a DB Program, like in C/C++:

asm

or

asm {
//
// assembler code
//
}

If not that will be a good thing to include in a new patch, and maybe a easy one, because will be great to program the core of the calculations, like AI and movements.
What the best way to include now assembler in the program, maybe a dll, in C++, or a dll directly in assembler? Anyway I don’t like dll, in other words I don’t know how to make them… Is easy to code assembler that make a dll… :-s
Dazzy
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Apr 2003 22:26
I have to disagree with the fact that this would be a good addition, a nice one yes but considering the amount of people who would be capable of making use of it, DBS are better putting their energy into making DBpro stable.

Theres no way currently that I know off to include ASM directly in a DB program, however I believe it can be done via a dll!

Dazzy
Athlon 2600, 1gb pc2700 ram, 160gb HD, 128mb GeF FX, DVD RW, Audigy 2.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Apr 2003 22:49
yes you'd have to achieve this through a DLL, and it'd preferably need to be precompiled - however if you really ache for ASM coding use the Pixel & Vertex Shaders to achieve what you want.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 25th Apr 2003 22:54
Create a C++ DLL with in-line assembler.

On a modern PC assembler is well over-rated IMHO, there are many C compilers which will compile to almost identical execution speeds. This ain't the 16-bit home computer world any more.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
mhack
23
Years of Service
User Offline
Joined: 24th Apr 2003
Location:
Posted: 25th Apr 2003 23:04
I have to disagree It ain't 16 bit assembler anymore
Assembler is faster because all other languages build of it
But I don't think it's needed in DB, no body wants to spend time on assembler if there is already tons of stuff done in DB!

DB team - Great Job!

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Apr 2003 23:23
ASM for general tasks is a waste of time within C/C++ as it's already setup to do the exact same operations ... however there are still somethings where it is alot faster for execution and use, suchas using the Processor Extension directly and accessing data in a way that bypasses the system.

though i'd have to say there isn't really any call for this in DB/DBpro

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 26th Apr 2003 00:07
"Assembler is faster because all other languages build of it"

I still think this is a bit of an urban myth. Once upon a time I would agree, but there are some very advanced C compilers out there that will compile code to an equal speed as native asm.

Let me put it another way - how many of the games you like playing are written in assembler? Probably none. Do they suffer from speed problems?

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Apr 2003 00:39
There is almost no need to revert to assembly language if you use modern compilers - it takes an expert asm coder to outperform even a reasonable optimiser.

I sometimes switch on assembly language output when I'm compiling, but only to see what it's doing behind the scenes - sometimes you have to be careful with C++ to ensure that unnecessary constructions/copies are not being made.
Sagan
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 26th Apr 2003 20:32
I agree that you must really have a good reason to write assembly language, but part of code that need speed or size smashed can be usefully code in asm.
If you try to do most things in assembler you end up with unfinished projects.

Assembly is fast that any compiler of any language could ever produce, and lot closer to machine level, all commands are mapped 1-1 to machine instructions.
Assembly code is smaller that any compiler of any language could ever produce.

Yap most programs are done in C++, but small parts of it can be done in asm, like the matrix calculations, encrypting…

I have done a small program in asm and DBPro to test speed:
The program just makes 3Billion of cycles with basic arithmetic

In asm it take in my computer ( P4 2400 ) 8 seconds, in DBPro it takes 50 seconds, that is about 6 times slow…

I show here the program in asm, with some other extra stuff, just to show some of you how the asm look like:


A program that do the same thing in DBPro, I fist try with goto, and other cycles but it get to slow, so I have done with for/next.



Sagan
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 26th Apr 2003 21:13
Have done a small change in the ASM core code, now it runs in 4 sec.
12x faster that DBPro code


MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 26th Apr 2003 21:49
Its not that surprising really - DBPro is still using the debug libraries, which means there are all sorts of checks everywhere - parameter checks, stack checks etc...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Apr 2003 22:38 Edited at: 26th Apr 2003 22:40
But you already have a way to add additional assembly language routines to DBPro if you choose to use it - you can create a DLL.

In addition, adding native assembly language to DBPro would:
1) Break existing code (eg I might have a variable called 'add')
2) Break the existing language (END and LOOP are already keywords)
3) Be of minimal use in speeding up games programs - because most of the time the program is using the DBPro libraries, and is not running your code, and the compilers *can* do it better.

I put the equivalent of your code through VisualC++7



The result I got was fairly interesting :



Basically, it detected that everything could be precalculated, and did so.

When I removed the 'return Result;' command, the function was optimised to the single machine instruction 'ret 0' - it worked out that there were no side effects in the code and optimised the whole thing away.
Sagan
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 26th Apr 2003 22:56
Quite smart that VisualC++

Sagan
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 26th Apr 2003 23:09
By the way anyone know how to build a dll, to use with DBPro in C++Builder 5, Enterprise Suite, Borland.
Or any good site with that information?

Login to post a reply

Server time is: 2026-07-10 23:13:48
Your offset time is: 2026-07-10 23:13:48