Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Turbo-BASIC XL
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Performance== {{original research|section|date=May 2021}} The most notable feature of Turbo-Basic was its dramatically improved speed; an unmodified Atari BASIC program loaded into Turbo-Basic would normally run three to five times faster, and the speed advantage improved as the program size grew. This was due largely to a series of improvements on well-known problems in the original Atari BASIC code. In most BASICs, [[GOTO]] was handled by reading the associated line number and then searching through the program for that line of code. In MS-derived BASICs the line numbers were stored as 16-bit [[integer]]s and numeric constants in the code in their original [[ASCII]] format. When a line like {{code|GOTO 1000}} was encountered, the interpreter would use special code to convert the "1000" into 16-bit format and then search for it. Atari BASIC worked differently, converting all numeric constants to a 6-byte [[floating-point]] format when the line was entered. This meant the "1000" was no longer in ASCII format and had to be converted from floating-point to integer format. The code for doing so was not well optimized and could take over 2 ms (average 1-1.5 ms). [[for next loop|FOR...NEXT loops]] are another common construct in BASIC programs. In most BASICs, when the FOR portion was encountered at runtime, its memory location in the [[source code]] was pushed onto a [[call stack]] so it could easily return to that location when the associated NEXT was encountered. For unknown reasons, Atari BASIC pushed the line number of the FOR onto the stack and then looked through the entire code for that line when it encountered the NEXT. For programs that did significant looping, which is often the case in BASIC, this could cause a dramatic performance hit. Turbo-Basic implemented its [[for loop|FOR loops]] using the address, as was the case in MS BASIC, and thus ran loops with roughly the same performance as MS. It then went further and greatly improved GOTO performance as well. Line numbers were sent into a [[hash function]] that broke them into 256-line chunks. As the program was entered, the address of the first of each of these chunks was stored in a 128-value table. At runtime, when a line number lookup was needed, it would first pick the nearest-but-lower value in the table, retrieve the address, and then begin scanning for the line from that point on. The improvement was most notable in larger programs where the scanning time was increasingly expensive, which is why Turbo-Basic could hit a 5-times increase in larger programs. The other major source of poor performance in Atari BASIC was its very slow [[binary-coded decimal]] (BCD) [[floating point]] code. The [[Library (computing)|library]], contained in a separate 2K ROM and considered part of the [[operating system]] as opposed to BASIC itself, had been written in a hurry and never optimized. Some of the routines, notably the multiply and exponents functions, were far slower than they could be. Turbo-Basic fixed this by including its own complete floating-point library, which not only fixed many of these issues but also further optimized the code by unrolling small loops. For programs that used math extensively, the new library resulted in dramatic performance improvements, sending the Atari from near the bottom of the [[Creative Computing Benchmark]] lists to near the top, beating a number of machines that were much faster in hardware.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)