------------------------------------------------ As I see it this effect has natural causes, because all effected commands have to work with the new 80-Number-System. It seems that the programmers of PowerBASIC tried to compensate the additionally needed time by using the CoProcessor. And it seems that it worked quite good for them when a CoProcessor is available. On the other side there is the question why the Compiler doesn't optimize it further when only the normal 16/32-Bit numbers are used. 3.6. PowerBASIC-Benchmark Source -------------------------------- This source shall show you the connection between the previous paragraphs. It is best if you just compile it and then try around a bit. Source: REM ***************************************************************** REM REM PBBENCH.EXE - Performance-Measuringprogram for PowerBASIC REM REM To test the differences in speed of different REM PowerBASIC-Commands in connection with used Floatingpoint- REM libraries when using or not using a CoProcessor REM REM Copyright: Thomas Gohel & Andras Hoeffken Version 2.10 REM All rights reserved REM REM ----------------------------------------------------------------- REM REM Important Notice: REM For reliable Maesures the Porcessor must be in REAL-Mode. REM There may not be any TSRs, no KEYB.COM, SMARTDRV.EXE or REM other. REM Important: REM For reliable Measures the program will have to be started REM more than once and an avergae must be built. REM REM Users of 486/586 or 286/386 Processors with CoProcessor can REM turn the x87 CoPro off in PowerBASIC with the in this Source REM implemented listing. REM REM *************************************************************** REM $COMPILE EXE "PBBENCH.EXE" $CPU 80386 $LIB ALL OFF REM $FLOAT NPX ' for Computers with CoProzessor ' (fastest) REM $FLOAT PROCEDURE ' for Computers without CoProzessor ' (not recommended) REM $FLOAT EMULATE ' Automatic aupport (Extremly slow ' without CoProcessor) REM $DEBUG MAP OFF PRINT PRINT "Performance-Testprogram for PowerBASIC";: PRINT TAB(58); "(c) A.Hoeffken/Th.Gohel";: PRINT TAB(68); "Version 2.10";: PRINT STRING$(80,"-"); PRINT a% = 1 ' some Variables i% = 1234 ' -"- e& = 12345678 ' -"- REM Zc1! fuer 5000000-Schleifen ; To take out the time for the REM Zc2! fuer 2000000-Schleifen ; FOR/NEXT-Loops REM Zc3! fuer 100000-Schleifen REM Zc4! fuer 2000-Schleifen IF pbvnpx > 0 THEN PRINT "CoProcessor " + CHR$(pbvnpx+48) + "87 found!" PRINT PRINT "Shoulod the CoProcessor be turned of for next"; PRINT "measure (Y/N)?" BEEP A$ = UCASE$(INPUT$(1)) IF A$ = "Y" THEN CoPro "AUS" ELSE PRINT "no CoProcessor found!" PRINT PRINT "Should the CoProcessor be turned on for the next"; PRINT "measure (Y/N)?" PRINT PRINT "Note: Turning on a not existing CoProcessor"; PRINT "will cause a crash!" BEEP A$ = UCASE$(INPUT$(1)) IF A$ = "Y" THEN CoPro "EIN" END IF PRINT GOSUB HoleZeitKonstanten GOSUB MesseFORNEXT GOSUB MesseIFTHEN GOSUB MesseSELECTCASE GOSUB MesseMATHEMATIK GOSUB MesseSTRING GOSUB MesseNUMPRINT GOSUB MesseSTRPRINT PRINT END '*********************************************** ' Get the Timeconstants for the different tests '*********************************************** HoleZeitKonstanten: PRINT "Messung der Zeitkonstanten "; t1! = TIMER FOR i& = 1 TO 2000 ' Time for 2000-Loops NEXT i& t2! = TIMER Zc4! = t2! - t1! PRINT "."; t1! = TIMER FOR i& = 1 TO 5000000 ' Time for 5-Mio-Loops NEXT i& t2! = TIMER Zc1! = t2! - t1! PRINT "."; t1! = TIMER FOR i& = 1 TO 100000 ' Time for 100000-Loops NEXT i& t2! = TIMER Zc3! = t2! - t1! PRINT "." t1! = TIMER FOR i& = 1 TO 2000000 ' Time for 2-Mio-Loops NEXT i& t2! = TIMER Zc2! = t2! - t1! RETURN MesseFORNEXT: PRINT "Testing FOR/NEXT : "; t1! = TIMER FOR i& = 1 TO 5000000 'Get 5-Millions-Loop NEXT i& 'i = long integer t2! = TIMER PRINT t2! - t1!; "sec " RETURN MesseIFTHEN: PRINT "Testing IF/THEN : "; t1! = TIMER FOR i& = 1 TO 5000000 IF a% = 0 THEN 'IF THEN Method ELSEIF a% = 2 THEN ELSE END IF NEXT i& t2! = TIMER PRINT t2! - t1! - Zc1!; "sec " RETURN MesseSELECTCASE: PRINT "Testing SELECT CASE: "; t1! = TIMER FOR i& = 1 TO 2000000 SELECT CASE A% 'SELECT CASE Method CASE 0 CASE 1 CASE ELSE END SELECT NEXT i& t2! = TIMER PRINT t2! - t1! - Zc2!; "sec " RETURN MesseMATHEMATIK: PRINT "Testing MATHEMATIC : "; t1! = TIMER FOR i& = 1 TO 2000000 i% = i% + 100 'extremly simple Calculations e& = e& * 2 e& = e& \ 2 i% = i% - 100 NEXT i& t2! = TIMER PRINT t2! - t1! - Zc2!; "sec " RETURN MesseSTRING: PRINT "Testing STRING's : "; t1! = TIMER FOR i& = 1 TO 2000 A$ = STRING$(20000, 32) A$ = RIGHT$(A$, 10000) + "Test" e% = INSTR(A$, "Test") A$ = "" NEXT i& t2! = TIMER PRINT t2! - t1! - Zc4!; "sec " RETURN MesseNUMPRINT: PRINT "Testing NUM-PRINT's "; t1! = TIMER FOR i& = 1 TO 100000 LOCATE , 1 PRINT "Testing NUM-PRINT's: "; i&; NEXT i& t2! = TIMER LOCATE , 20 PRINT t2! - t1! - Zc3!; "sec " RETURN MesseSTRPRINT: PRINT "Testing $$$-PRINT's "; t1! = TIMER FOR i& = 1 TO 100000 LOCATE , 1 PRINT "Testing $$$-PRINT's: "; NEXT i& t2! = TIMER LOCATE , 20 PRINT t2! - t1! - Zc3!; "sec " RETURN '********************************************** ' Here is a routine to turn off the CoProcessor '********************************************** SUB Copro(Switch$) SELECT CASE UCASE$(Switch$) CASE "AUS", "OFF", "-" ! mov ax, &h0040 ! mov es, ax ! mov ax, word ptr es:[&h10] ! and ax, &b1111111111111101 ! mov word ptr es:[&h10], ax CASE "EIN", "ON", "+" ! mov ax, &h0040 ! mov es, ax ! mov ax, word ptr es:[&h10] ! or ax, &b0000000000000010 ! mov word ptr es:[&h10], ax END SELECT END SUB --- CrossPoint v3.11 R * Origin: Magics: PBSOUND, PBFILES (20MB), PBFAQ, PBHIVGA at: (2:2410/330.1) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: DG300006 Date: 12/01/96 From: THOMAS GOHEL Time: 12:00am \/To: ALLE (Read 4 times) Subj: FAQ: PowerBASIC 07/16 (Problems 1) =================== 4. Standardproblems =================== 4.1. Compatability between the PBUs and LIBs of the 3.x Versions 4.2. Not enough memory in the PowerBASIC-IDE 4.3. Finding out the filename and path to the filename 4.4. No free memory with ENVIRON$ 4.5. No Returnerrorlevel with SHELL 4.6. Cutting files 4.7. Error 502/514 when using C-OBJ-Files 4.8. Preventing a Warmboot with CTRL-ALT-DEL 4.9. Opening more than 15 Files with PowerBASIC and/or DOS 4.10. HEX$-DWORD Routine for PowerBASIC 3.1/3.2 4.1. Compatability between the PBUs and LIBs of the 3.x Versions ---------------------------------------------------------------- Other than the PowerBASIC-Update from V2.10 to 3.00, the PBU/LIBs of the 3.x Versions are downwards compatible. That means that you can continue to use an under PowerBASIC 3.0 developed PBU/LIB under the two higher PowerBASIC Versions. But you can't use a PowerBASIC 3.1 PBU/ LIB with any of the older Versions. There are probably some differences between the Versions 3.0-3,1 because of the new Number- System when exchanging sourcecode. In that case please read the Chapter 'Errors ...'. 4.2. Not enough memory in the PowerBASIC-IDE -------------------------------------------- There is a Tool by Bob Zale himself which activates parts of the VGA- Graphic-RAM and the parts of the monochrome Herculescard for PowerBASIC. The Tool 'PBPLUS96' (96kByte more RAM) was written for PowerBASIC Version 2.00, but still works with Version 3.10. 4.3. Finding out the filename and the path to the filename ---------------------------------------------------------- We often stand in front of the problem that we can start our program over a path command, but that it can't find its own data and INI-Files anymore after that. The solution is quite simple: DOS saves this information in the PSP or in its Environmentblock. --- Cut -------------------------------------------------------------- '********************************************************************* ' ' Finding the path and filename of the current program in ' PowerBASIC 3.0/3.2 ' ' von Thomas Gohel ' '********************************************************************* $COMPILE EXE ! mov ax, &h6200 ! int &h21 ! mov es, bx ! mov ax, word ptr es:[&h2C] ! mov pbvDefSeg, ax ; undocumented in PowerBASIC 3.0 FOR i% = 0 TO 1024 IF PEEK$(i%, 4) = CHR$(0,0,1,0) THEN EXIT FOR NEXT i% WHILE PEEK(i% + 4) <> 0 Temp$ = Temp$ + CHR$(PEEK(i% + 4)) i% = i% + 1 WEND DEF SEG FOR i%=LEN(Temp$) TO 1 STEP -1 IF RIGHT$(MID$(Temp$,1,i%),1) = "\" THEN EXIT FOR NEXT i% ExeDir$ = MID$(Temp$,1,i%) ExeName$ = MID$(Temp$,i%+1) PRINT ExeDir$; " "; ExeName$ --- Cut End ---------------------------------------------------------- 4.4. No free memory with ENVIRON$ --------------------------------- This chapter is partly documented in the manuals, but I want to give some advanced tips, because this subject often causes misunderstandig. The structure of the environmentblock in connection with the Program Segment Prefix (PSP) is not documented further, but it is of enourmous meaning gor the better understanding of this error. Shortly said, you can only modify the existing environent, and not add any new entries!! You can use three ways if you want to add entries anyways: a) Delete part of the environment and then add the new entry or first create a Dummy-Environmententry and the delete or modify it using the ENVIRON-Command. b) When you want to start a DOS-SHELL with an information: OldEnv$ = ENVIRON$("PROMPT") SHELL "COMMAND.COM /K SET PROMPT=PowerBASIC " + OldEnv$ The trick with this is that when you call a SHELL a new PSP will be created and the memory will be allocated correctly. c) Get the address of the PSP, get the pointer to the current Environmentblock and then read the environment into a string, where it can be modified. The allocate a DOS-Memoryblock using INT21, save the modified environment therem abd the set the pointer to the Environmentblock within the PSP to the new one. (Also see: Already available PD-Solutions) 4.5. No Returnerrorlevel with SHELL