News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Calculating 250 Digits of Euler's number with PowerBASIC

Started by Gunther, May 02, 2022, 11:42:54 AM

Previous topic - Next topic

Gunther

Caballero,

Quote from: caballero on May 04, 2022, 03:08:46 AM
That's quite nice  :thumbsup:  Just wonder why use DOS instead Windows

thank you for the flowers.

I wanted to show that even sophisticated algorithms can be realized with DOS. PowerBASIC is well suited for this purpose. I also didn't feel like implementing
two nested loops in assembly language.

But it's already right: The program can be written under Windows with appropriate modifications. Maybe I'll do that when I've the time and mood.
You have to know the facts before you can distort them.

daydreamer

Quote from: Gunther on May 04, 2022, 04:43:48 AM
I wanted to show that even sophisticated algorithms can be realized with DOS
I agree
I already done the pixelshader way of make circle per pixel check inside or outside radius with sqrt(x*x+y*y),Rossler attractor
But it also more challenging optimize speed when not spoiled by 4.5ghz but the slower emulating frequency
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Gunther

Daydreamer,

Quote from: daydreamer on May 04, 2022, 04:24:09 PM
But it also more challenging optimize speed when not spoiled by 4.5ghz but the slower emulating frequency

that's a good argument.

But you also have to understand me. Our subforum for PowerBASIC is not used very often. The lion's share there is from Hutch. From me is only a very small part.
I am therefore endeavoring to increase this proportion somewhat. I learned about Hutch decades ago through PowerBASIC. There are good reminiscences that I
associate with this compiler. Maybe I'm too nostalgic, who knows?
You have to know the facts before you can distort them.

jack

does PowerBasic for DOS not have enough functionality so that you must use assembler?
or is the use of assembler to improve performance?
if the latter, then how much improvement was achieved by using assembler?

Gunther

Jack,

Quote from: jack on May 04, 2022, 06:20:27 PM
does PowerBasic for DOS not have enough functionality so that you must use assembler?

not easy to answer. Many things are a matter of taste. It may be enough for a programmer, but not for others. In addition, however, there are hard facts.
The DOS compiler PB 3.5 is from 1997. The new registers and instructions were not known at that time. There is an inline assembler, but it only allows 8086
instructions. The generated code of the compiler is also far from optimal. Even with the metastatement $CPU 80386  the compiler does not use the 32 bit
registers. These points have all been improved by Bob Zale in the Windows compilers. But this is not true for the DOS compiler.

That's why I try to improve certain things with assembly language. Otherwise, the modern processors (Skylake, Buldozzer etc.) only run as a fast clocked 8086.
In my understanding, that's not the point.

Quote from: jack on May 04, 2022, 06:20:27 PM
if the latter, then how much improvement was achieved by using assembler?

Hard to answer. I didn't do a test, but only adjusted the mainframe program accordingly. Even there I had written the inner loops in mainframe assembly language
(System/370). I was still a student at that time. I don't remember if that was required or not. It's just been too long.
You have to know the facts before you can distort them.

Gunther

The actual archive is e250r2.zip. It contains the same files but with very significant changes. This mainly involves the BASIC source.

I wrote the inner calculation loops and some more parts with the inline assembler. As a result, the program now has almost the same
structure as the main frame source. This simplifies a later port to a pure Windows application with the MASM SDK. Furthermore, this
achieves an increase in speed; a whole series of function calls and thus the associated overhead is unnecessary.

But there's a price to pay. The inline assembler of PowerBASIC for DOS supports only the 8086 instructions. Therefore, special measures
were necessary, e.g. to realize the floating point instructions. This has made the source code a bit longer, but it's well commented.
Moreover, the code is pretty self-explanatory.

A major challenge still remains. The loop to output Euler's number is a suggestion from HSE. This still has to be implemented in assembly
language. Then the whole algorithm can be realized without problems under Win64 and Win32.

Tests and improvement ideas are welcome at any time. Thank you for this in advance.
You have to know the facts before you can distort them.