Misplaced Pages

Integer BASIC

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

#576423

109-436: The only numeric data type was the integer; floating-point numbers were not supported. Using integers allowed numbers to be stored in a compact 16-bit format that could be more rapidly read and processed than the 32- or 40-bit floating-point formats found in most BASICs of the era. This made it so fast that Bill Gates complained when it outperformed Microsoft BASIC in benchmarks. However, this also limited its applicability as

218-485: A % suffix, string variables (variable length) were indicated with a $ suffix. The list of mathematical and logical operators was typical of most BASICs, with some extensions. For math, + , - , * , / and ^ were supported, along with ** as an alternate form of ^ for computer terminals that might not have that character. Standard logical comparisons were = , < , > , <= , >= , and <> . One interesting addition

327-473: A line feed at the end of a line instead of the normal carriage return character. For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the & character as a line continuation character. Multiple statements could be placed on a single line using : as the statement separator. The system allowed tabs to be used as inline whitespace, and was used to make loops more clear, as in modern languages. Comments used either

436-463: A machine code monitor , "mini- assembler ", and disassembler to create and debug assembly language programs. Wozniak hand-assembled the monitor as the Apple II's first program, then used it to write Integer BASIC. Apple BASIC had the following commands: Integer BASIC added the following: Integer BASIC read the lines typed in by the user from a buffer and ran them through a parser which output

545-514: A negative zero (−0) distinct from ordinary ("positive") zero, and "not a number" values ( NaNs ). BASIC-PLUS BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s. BASIC-PLUS

654-459: A complete floating-point library located in ROM memory between $ F425-$ F4FB and $ F63D-$ F65D . The source code was included in the Apple II manual. BASIC programs requiring floating-point calculations could CALL into these routines. Floating-point arithmetic In computing , floating-point arithmetic ( FP ) is arithmetic on subsets of real numbers formed by a signed string of

763-461: A computer system specially designed to carry out operations on floating-point numbers. A number representation specifies some way of encoding a number, usually as a string of digits. There are several mechanisms by which strings of digits can represent numbers. In standard mathematical notation, the digit string can be of any length, and the location of the radix point is indicated by placing an explicit "point" character (dot or comma) there. If

872-497: A few details. Five of these formats are called basic formats , and others are termed extended precision formats and extendable precision format . Three formats are especially widely used in computer hardware and languages: Increasing the precision of the floating-point representation generally reduces the amount of accumulated round-off error caused by intermediate calculations. Other IEEE formats include: Any integer with absolute value less than 2 can be exactly represented in

981-755: A fixed number of digits in some base , called a significand , scaled by an integer exponent of that base. Numbers of this form are called floating-point numbers . For example, the number 2469/200 is a floating-point number in base ten with five digits: 2469 / 200 = 12.345 = 12345 ⏟ significand × 10 ⏟ base − 3 ⏞ exponent {\displaystyle 2469/200=12.345=\!\underbrace {12345} _{\text{significand}}\!\times \!\underbrace {10} _{\text{base}}\!\!\!\!\!\!\!\overbrace {{}^{-3}} ^{\text{exponent}}} However, unlike 2469/200 = 12.345, 7716/625 = 12.3456

1090-519: A general-purpose language. Another difference with other BASICs of the era is that Integer BASIC treated strings as arrays of characters, similar to the system in C or Fortran 77 . Substrings were accessed using array slicing rather than string functions. This style was introduced in HP Time-Shared BASIC , and could also be found in other contemporary BASICs patterned on HP, like North Star BASIC and Atari BASIC . It contrasted with

1199-426: A given starting number like AUTO 100 , adding 10 to the last number with every new line. AUTO 300,5 would begin numbering at line 300 by fives; 300, 305, etc. Automatic numbering was turned off by entering MAN . One interesting feature of the editor was that a section of the screen could be set aside as the "window", where live updates took place. This was normally the entire screen, but it could be limited to

SECTION 10

#1732771783577

1308-408: A number, the base (10) need not be stored, since it will be the same for the entire range of supported numbers, and can thus be inferred. Symbolically, this final value is: s b p − 1 × b e , {\displaystyle {\frac {s}{b^{\,p-1}}}\times b^{e},} where s is the significand (ignoring any implied decimal point), p

1417-463: A parentheses formula. When variables were encountered, their name was parsed and then looked up in the variable storage area. If it was not found, it was added to the end of the list. The address of the variable's storage, perhaps freshly created, was then placed on the evaluation stack. In addition to Integer BASIC, the Apple ROMs contained a custom assembler language known as SWEET16 . SWEET16

1526-439: A secondary program to indicate that a program should begin execution at a different point from its first line. This feature of chaining to a certain line number allowed programs to signal to each other that they were being called from another program. The use of a shared memory section called core common also allowed programs to pass data to each other as needed. Disk files could also be used but were slower. To conserve memory,

1635-433: A series of tokens . As part of this process, simple syntax errors were detected and listed. If the parsing was successful, the line number (if present) was converted from ASCII decimal format into a 16-bit integer and any keywords into a 7-bit integer token. Some keywords were represented by multiple tokens; for instance, where Microsoft BASIC had one token for the keyword PRINT , Integer BASIC had three tokens: one if

1744-733: A single digit. With the inclusion of "Extend mode" in later versions, variable names could be up to 29 characters long, and dot (.) was added as a permitted character. Every variable name still had to begin with a letter. As in most versions of BASIC, the LET keyword, for variable assignment, was optional. It could set multiple variables to a single value, like LET A , B , C = 10 . The language supported three data types; floating-point numbers, integers, and strings. Variables with no suffix were floating point (8 bytes, range 0.29 × 10 to 1.7 × 10 , up to 16 digits of precision). Integer variables (16-bit, range −32768 to +32767) were indicated with

1853-535: A slot in a numeric array. For instance, CHANGE 'HELLO' TO X would return an array with the five ASCII codes, 110, 105, 114, 114, 105, in elements 1 through 5, and the number 5, the length of the string, in element 0. One could reverse the operation as well, CHANGE X TO A$ would read the individual numbers in the X array and convert it to a string. BASIC-PLUS added the concept of "statement modifiers", JOSS -like conditions that could be applied to any statement. For instance, PRINT I IF I <> 10

1962-495: A smaller area by POKE ing values into memory locations 32 through 35. This feature could be used to create an editable text area while the rest of the screen was in graphics mode. As in most BASICs, programs were started with the RUN command, and as was common, could be directed at a particular line number like RUN 300 . Execution could be stopped at any time using Ctrl + C and then restarted with CON tinue, as opposed to

2071-404: A smart terminal with cursor control could not be guaranteed, BASIC-PLUS used the common system of prefixing all source code with a line number. The code was edited by typing in the number and then changing the contents of the following code. A line of code could be removed by typing in its line number and nothing else, thereby setting it to an empty line. The virtual address space of an RSTS/E user

2180-1118: A syntax to be used that could be entered through a typewriter , as was the case of his Electromechanical Arithmometer in 1920. In 1938, Konrad Zuse of Berlin completed the Z1 , the first binary, programmable mechanical computer ; it uses a 24-bit binary floating-point number representation with a 7-bit signed exponent, a 17-bit significand (including one implicit bit), and a sign bit. The more reliable relay -based Z3 , completed in 1941, has representations for both positive and negative infinities; in particular, it implements defined operations with infinity, such as 1 / ∞ = 0 {\displaystyle ^{1}/_{\infty }=0} , and it stops on undefined operations, such as 0 × ∞ {\displaystyle 0\times \infty } . Zuse also proposed, but did not complete, carefully rounded floating-point arithmetic that includes ± ∞ {\displaystyle \pm \infty } and NaN representations, anticipating features of

2289-490: A variable's value would be displayed. For instance, DSP X would display the value of X every time it changed, along with the line number where the change occurred. As with TRACE, DSP was turned off with NODSP . Where Dartmouth BASIC and HP-BASIC limited variable names to at most two characters (either a single letter or a letter followed by one digit), and where MS-BASIC allowed a letter followed by an optional letter or digit (ignoring subsequent characters), Integer BASIC

SECTION 20

#1732771783577

2398-500: Is a rational number , because it can be represented as one integer divided by another; for example 1.45 × 10 is (145/100)×1000 or 145,000 /100. The base determines the fractions that can be represented; for instance, 1/5 cannot be represented exactly as a floating-point number using a binary base, but 1/5 can be represented exactly using a decimal base ( 0.2 , or 2 × 10 ). However, 1/3 cannot be represented exactly by either binary (0.010101...) or decimal (0.333...), but in base 3 , it

2507-524: Is a smallest positive normal floating-point number, which has a 1 as the leading digit and 0 for the remaining digits of the significand, and the smallest possible value for the exponent. There is a largest floating-point number, which has B − 1 as the value for each digit of the significand and the largest possible value for the exponent. In addition, there are representable values strictly between −UFL and UFL. Namely, positive and negative zeros , as well as subnormal numbers . The IEEE standardized

2616-431: Is based on bytecodes that run within a simple 16-bit virtual machine . This model was used so memory could be addressed via indirect 16-bit pointers and 16-bit math functions calculated without the need to translate those to the underlying multi-instruction 8-bit 6502 code. The entire virtual machine was written in only 300 bytes. Code can call SWEET16 by issuing a subroutine call, and then return to normal 6502 code when

2725-401: Is false and otherwise always true. The DIM statement could allocate one-dimensional and two-dimensional arrays of any of the three data types. The range of subscripts always began with 0 (but MAT statements did not set elements in row 0 or column 0). The language also included a number of MAT commands to work with the entire array (or MATrix). The MAT READ command would fill

2834-432: Is from 2  ≈ 2 × 10 to approximately 2  ≈ 2 × 10 . The number of normal floating-point numbers in a system ( B , P , L , U ) where is 2 ( B − 1 ) ( B P − 1 ) ( U − L + 1 ) {\displaystyle 2\left(B-1\right)\left(B^{P-1}\right)\left(U-L+1\right)} . There

2943-447: Is not a floating-point number in base ten with five digits—it needs six digits. The nearest floating-point number with only five digits is 12.346. And 1/3 = 0.3333… is not a floating-point number in base ten with any finite number of digits. In practice, most floating-point systems use base two , though base ten ( decimal floating point ) is also common. Floating-point arithmetic operations, such as addition and division, approximate

3052-496: Is often used to allow very small and very large real numbers that require fast processing times. The result of this dynamic range is that the numbers that can be represented are not uniformly spaced; the difference between two consecutive representable numbers varies with their exponent. Over the years, a variety of floating-point representations have been used in computers. In 1985, the IEEE 754 Standard for Floating-Point Arithmetic

3161-399: Is similar in concept to scientific notation. Logically, a floating-point number consists of: To derive the value of the floating-point number, the significand is multiplied by the base raised to the power of the exponent , equivalent to shifting the radix point from its implied position by a number of places equal to the value of the exponent—to the right if the exponent is positive or to

3270-1358: Is stored in memory using the IEEE 754 encoding, this becomes the significand s . The significand is assumed to have a binary point to the right of the leftmost bit. So, the binary representation of π is calculated from left-to-right as follows: ( ∑ n = 0 p − 1 bit n × 2 − n ) × 2 e = ( 1 × 2 − 0 + 1 × 2 − 1 + 0 × 2 − 2 + 0 × 2 − 3 + 1 × 2 − 4 + ⋯ + 1 × 2 − 23 ) × 2 1 ≈ 1.57079637 × 2 ≈ 3.1415927 {\displaystyle {\begin{aligned}&\left(\sum _{n=0}^{p-1}{\text{bit}}_{n}\times 2^{-n}\right)\times 2^{e}\\={}&\left(1\times 2^{-0}+1\times 2^{-1}+0\times 2^{-2}+0\times 2^{-3}+1\times 2^{-4}+\cdots +1\times 2^{-23}\right)\times 2^{1}\\\approx {}&1.57079637\times 2\\\approx {}&3.1415927\end{aligned}}} where p

3379-585: Is the equivalent of IF I <> 10 THEN PRINT I The opposite was also provided, PRINT I UNLESS I = 10 was the equivalent of IF I <> 10 THEN PRINT I . FOR loops worked as in other versions of BASIC, and the NEXT command could not be used in an expression to exit early. Instead, the UNTIL and WHILE keywords could be used to control early exits. For instance, FOR I = 1 UNTIL I = 10 continue looping until I=10, with

Integer BASIC - Misplaced Pages Continue

3488-458: Is the precision ( 24 in this example), n is the position of the bit of the significand from the left (starting at 0 and finishing at 23 here) and e is the exponent ( 1 in this example). It can be required that the most significant digit of the significand of a non-zero number be non-zero (except when the corresponding exponent would be smaller than the minimum one). This process is called normalization . For binary formats (which uses only

3597-621: Is the precision (the number of digits in the significand), b is the base (in our example, this is the number ten ), and e is the exponent. Historically, several number bases have been used for representing floating-point numbers, with base two ( binary ) being the most common, followed by base ten ( decimal floating point ), and other less common varieties, such as base sixteen ( hexadecimal floating point ), base eight (octal floating point ), base four (quaternary floating point ), base three ( balanced ternary floating point ) and even base 256 and base 65,536 . A floating-point number

3706-420: Is to provide software for our machines free or at minimal cost" and "yes folks, Apple BASIC is Free". This was printed shortly after Bill Gates 's infamous Open Letter to Hobbyists that suggested that people were robbing him by copying versions of Altair BASIC . Wozniak had helped Steve Jobs , who worked for Atari , with a redesign of Breakout . At some later point, he decided to see whether one could write

3815-404: Is today known as VSI BASIC for OpenVMS . Users would sit at a terminal and type in programming language statements. The statements could either be entered into the system's command interpreter directly, or entered into a text editor , saved to a file, and loaded into the command interpreter from the file. Errors in source code were reported to the user immediately after the line was typed. As

3924-469: Is trivial (0.1 or 1×3 ) . The occasions on which infinite expansions occur depend on the base and its prime factors . The way in which the significand (including its sign) and exponent are stored in a computer is implementation-dependent. The common IEEE formats are described in detail later and elsewhere, but as an example, in the binary single-precision (32-bit) floating-point representation, p = 24 {\displaystyle p=24} , and so

4033-476: The REM keyword or the ! character, as opposed to MS BASICs, which used REM and ' . The PRINT command divided the screen into regions 14 spaces wide, and the comma was used to move between these locations; PRINT 1,2,3 would output 1, 2 and 3 in a spaced-out fashion, while PRINT 1;2;3 would leave a single space and produce "1 2 3". INPUT allowed a prompt string to be specified, but used

4142-520: The VTAB command worked similar to TAB but added vertical spaces instead of horizontal. For unexplained reasons, in this case the coordinates were from 1 to 24 rather than 0 to 23. Integer BASIC included a POP command to exit from loops. This popped the topmost item off the FOR stack. Atari BASIC also supported the same command, while North Star BASIC used EXIT . The Integer BASIC ROMs also included

4251-565: The ^ character. Binary operators included AND , OR and NOT . Binary comparisons included the standard set of = , > , < , >= , <= , <> and the HP-inspired # , which was equivalent to <>. Only single-dimension arrays were allowed, limited in size only by the available memory. Mathematical functions were sparse; only ABS (absolute value), SGN (sign) and RND (random number) were supported. In contrast to MS-derived versions, where

4360-688: The English Electric DEUCE . The arithmetic is actually implemented in software, but with a one megahertz clock rate, the speed of floating-point and fixed-point operations in this machine were initially faster than those of many competing computers. The mass-produced IBM 704 followed in 1954; it introduced the use of a biased exponent . For many decades after that, floating-point hardware was typically an optional feature, and computers that had it were said to be "scientific computers", or to have " scientific computation " (SC) capability (see also Extensions for Scientific Computation (XSC)). It

4469-530: The HP 9830 , a desktop-sized machine for US$ 10,000 (equivalent to $ 78,000 in 2023) that also ran BASIC, which Wozniak had access to. I sniffed the wind and knew that the key to making my computer good (popular) was to include a high-level language and that it had to be BASIC. Steve Wozniak In January 1975 the Altair 8800 was announced and sparked off the microcomputer revolution. In March, Wozniak attended

Integer BASIC - Misplaced Pages Continue

4578-567: The de facto standard, this style was not uncommon; North Star BASIC and Atari BASIC used the same concept, as did others. Strings in Integer Basic used a fixed amount of memory regardless of the number of characters used within them, up to a maximum of 255 characters. This had the advantage of avoiding the need for the garbage collection of the heap that was notoriously slow in MS BASIC but meant that strings that were shorter than

4687-418: The minicomputer market with their HP 2000 series machines running a custom timesharing version of BASIC . For approximately $ 100,000 , one could build up a reasonably equipped machine that could support between 16 and 32 users running BASIC programs. While expensive, it was still a fraction of the cost of the mainframe machines and, for heavy users, less than the timesharing services. HP followed this with

4796-408: The "wrong" order could multiply the number of disk accesses. Additional rules were imposed on virtual arrays, such that one datum could never span a record boundary: Each data type was aligned to a multiple of its size. Virtual strings were stored as fixed-length ASCIIZ data, with sizes restricted to 2, 4, 8, 16, 32, 64, 128, 256, or 512 bytes, and were accessed using LSET and RSET . BASIC-PLUS

4905-538: The 16-bit operations are complete. SWEET16 was not used by the core BASIC code, but was later used to implement several utilities. Notable among these was the line renumbering routine, which was included in the Programmer's Aid #1 ROM, added to later Apple II models and available for user installation on earlier examples. Although Integer BASIC contained its own math routines, the Apple II ROMs also included

5014-516: The Apple was the paddle controller , which had two controllers on a single connector. The position of the controller could be read using the PDL function, passing in the controller number, 0 or 1, like A = PDL ( 0 ) : PRINT A , returning a value between 0 and 255. The Apple machines did not include dedicated sound hardware, only a simple "beeper". Producing sounds was accomplished by PEEK ing

5123-535: The Homebrew club, he demonstrated a few more features added in the last month. It was the most satisfying day of my life... I demonstrated Breakout [at Homebrew]-totally written in BASIC... After designing hardware arcade games, I knew that being able to program them in BASIC was going to change the world. Steve Wozniak In early 1976 ads for its Apple I computer, Apple Inc made the claims that "our philosophy

5232-703: The IEEE Standard by four decades. In contrast, von Neumann recommended against floating-point numbers for the 1951 IAS machine , arguing that fixed-point arithmetic is preferable. The first commercial computer with floating-point hardware was Zuse's Z4 computer, designed in 1942–1945. In 1946, Bell Laboratories introduced the Model ;V , which implemented decimal floating-point numbers . The Pilot ACE has binary floating-point arithmetic, and it became operational in 1950 at National Physical Laboratory, UK . Thirty-three were later sold commercially as

5341-477: The RSX Run Time System; this RTS only occupied 8KB of the user's virtual address space, leaving 56KB for the user's program. (RSTS/E version 9 introduced separate Instruction and Data space, and the "disappearing" RSX Run Time System, permitting up to 64KB of each of instruction code and data.) These two factors allowed individual BP2 programs to be much larger than BASIC-PLUS programs, often reducing

5450-608: The Spanish engineer Leonardo Torres Quevedo published Essays on Automatics , where he designed a special-purpose electromechanical calculator based on Charles Babbage 's analytical engine and described a way to store floating-point numbers in a consistent manner. He stated that numbers will be stored in exponential format as n x 10 m {\displaystyle ^{m}} , and offered three rules by which consistent manipulation of floating-point numbers by machines could be implemented. For Torres, " n will always be

5559-423: The associated matrix operation. The DIM# "virtual DIM" statement could map "virtual data array(s)" or "virtual array(s)" to a disk file, which allowed arrays larger than the computer's available memory (or even its address space), and allowed use of array elements to read, write, and extend disk files (persistent storage). They called this arrangement "virtual data storage" and "virtual core", but it did not use

SECTION 50

#1732771783577

5668-399: The assumption that following code would set the value of I, meaning it might not exit after 10 iterations but as soon as the code set I to 10. Modifiers could also be used to build compact one-line loops, for instance, X = X + 1 WHILE X < 100 would loop until X was 100. Variable names in the early versions of BASIC-PLUS could be a single letter or a single letter followed by

5777-512: The basis for its math package. These were stored internally as a 16-bit number, little-endian (as is the 6502). This allowed a maximum value for any calculation between -32767 and 32767; although the format could also store the value -32768, BASIC could not display that number. Calculations that resulted in values outside that range produced a >32767 ERR . Infix operators included + (addition), - (subtraction), * (multiplication), / (division), MOD (remainder) and exponent using

5886-509: The buffer. If it had a line number, it was copied from the buffer into the program storage area. The runtime interpreter used two stacks for execution: one for statement keywords and the other for evaluating the parameters. Each statement was given two priorities: one that stated where it should occur in a multi-step operation, like a string of mathematical operations to provide order of operations , and another that suggested when evaluation should occur, for instance, calculating internal values of

5995-586: The card using conventional PRINT commands and read from it using INPUT . Integer BASIC included a TAB feature, which positioned the cursor on a given column from 0 to 39. It differed from the versions found in most BASICs in that it was a command with a following number, as opposed to a function with the value in parentheses; one would move the cursor to column 10 using TAB 10 in Integer BASIC whereas in MS this would be PRINT TAB(10) . Additionally,

6104-430: The code by hand, translating the assembler code instructions into their machine code equivalents and then uploading the result to his computer. Without any training on how to write a computer language, he used his HP calculator experience to implement a stack machine to interpret expressions. Once the basic routines were up and running, he worked on the other commands one-by-one in a modular fashion. With every visit to

6213-501: The color of the screen at X,Y. Integer BASIC lacked any custom input/output commands, and also lacked the DATA statement and the associated READ . To get data into and out of a program, the input/output functionality was redirected to a selected card slot with the PR#x and IN#x , which redirected output or input (respectively) to the numbered slot. From then on, data could be sent to

6322-572: The company had already arranged a license with Microsoft to receive their recently completed 6502 version of the Altair code. Examining the MS code, Wozniak decided that it was easier to add graphics support to their code than add floating-point his own BASIC, as the latter required hand-patching of the original machine code while MS's was written in assembler and more easily modified. The development of Apple's BASIC ended in favor of what became Applesoft BASIC . Wozniak later noted, "My biggest disappointment

6431-568: The computer representation for binary floating-point numbers in IEEE 754 (a.k.a. IEC 60559) in 1985. This first standard is followed by almost all modern machines. It was revised in 2008 . IBM mainframes support IBM's own hexadecimal floating point format and IEEE 754-2008 decimal floating point in addition to the IEEE 754 binary format. The Cray T90 series had an IEEE version, but the SV1 still uses Cray floating-point format. The standard provides for many closely related formats, differing in only

6540-420: The corresponding real number arithmetic operations by rounding any result that is not a floating-point number itself to a nearby floating-point number. For example, in a floating-point arithmetic with five base-ten digits, the sum 12.345 + 1.0001 = 13.3451 might be rounded to 13.345. The term floating point refers to the fact that the number's radix point can "float" anywhere to the left, right, or between

6649-483: The creation of the IEEE 754 standard once the 32-bit (or 64-bit) word had become commonplace. This standard was significantly based on a proposal from Intel, which was designing the i8087 numerical coprocessor; Motorola, which was designing the 68000 around the same time, gave significant input as well. In 1989, mathematician and computer scientist William Kahan was honored with the Turing Award for being

SECTION 60

#1732771783577

6758-583: The declared length was wasted. Substring access was provided through array slicing syntax. For instance, PRINT A$ ( 0 , 5 ) printed the first six characters of A$ , characters 0 through 5. Concatenation was provided using the same system, A$ ( 5 ) = "ABC" replaced any characters starting at position 5 with the string "ABC". This contrasts with the DEC/MS-style string handling which uses string functions like MID$ to access substrings and + for concatenation. As many of

6867-503: The digits 0 and 1 ), this non-zero digit is necessarily 1 . Therefore, it does not need to be represented in memory, allowing the format to have one more bit of precision. This rule is variously called the leading bit convention , the implicit bit convention , the hidden bit convention , or the assumed bit convention . The floating-point representation is by far the most common way of representing in computers an approximation to real numbers. However, there are alternatives: In 1914,

6976-507: The features that would be provided by string functions were instead provided by array slicing, the selection of string functions was reduced. LEN returned the length of a string and ASC returned the ASCII numeric code for the first letter in a string. It lacked an equivalent of the CHR$ that returned the ASCII character with a given numeric code. When launched, the only game controller for

7085-552: The first meeting of the Homebrew Computer Club and began formulating the design of his own computer. One of the most important pieces of software for the Altair, and one of the most heavily pirated , was Altair BASIC from the recently formed Microsoft . Wozniak concluded that his machine would have to have a BASIC of its own, which would, hopefully, be the first for the MOS Technology 6502 processor. As

7194-425: The game in BASIC. He added commands to read paddle controllers and over a series of quick edits had a version of the game up and running. To improve its playability, he added a speaker to make clicks when the ball hit things. While showing it to Jobs, Wozniak demonstrated that he could quickly change the colors that his game used, just by altering the source code . Wozniak later wrote that he had proved that "software

7303-492: The given number is scaled by a power of 10 , so that it lies within a specific range—typically between 1 and 10, with the radix point appearing immediately after the first digit. As a power of ten, the scaling factor is then indicated separately at the end of the number. For example, the orbital period of Jupiter 's moon Io is 152,853.5047 seconds, a value that would be represented in standard-form scientific notation as 1.528535047 × 10 seconds. Floating-point representation

7412-415: The high bit of each character so that A was stored as $ C1 . Variable names were converted in the same fashion, with the letters converted to have their high-bit turned on, and any digits in the name represented by the corresponding $ B0 through $ B9 , so that the variable A5 would be tokenized as $ C1B5 . If the line was entered without a line number, the code was then executed directly from

7521-477: The keyword was followed by no arguments, one if followed by an arithmetic expression, and one if followed by a string literal. Numeric literals, like the value 500, were converted into their 16-bit (two-byte) binary representation, in this case, $ 01F4 hexadecimal . To indicate this was a value and not a keyword, a single byte between $ B0 and $ B9 was inserted in front of the two-byte value. String literals, like "HELLO WORLD" were instead converted by setting

7630-401: The keywords as strings: once converted to PPCODE the keywords were numbers that pointed to routines to run that function. BASIC-PLUS included a COMPILE command, but this was not a true compiler; this simply saved the program's PPCODE representation so that it did not have to be recompiled when the BASIC program was next loaded into memory. The system stored a user's program in two formats. One

7739-441: The language interpreter as well as the line editing environment. When BASIC was running, a > command prompt was displayed where the user could enter statements. Unlike later home computer platforms, BASIC was not the default environment when the Apple II started, it normally started in the monitor . BASIC was started by pressing Ctrl + B Return . Statements that were entered with leading numbers are entered into

7848-473: The language needed 4 KB RAM, he made that the minimum memory for the design. Wozniak's references for BASIC were a copy of 101 BASIC Computer Games and an HP BASIC manual. He did not know that HP's BASIC was very different from the DEC BASIC variety used in 101 Games , which was also the basis of Microsoft BASIC for the Altair. Based on these sources, Wozniak began sketching out a syntax chart for

7957-464: The language, notably Microsoft's, CHANGE was removed and BASIC-PLUS's string functions became the only ways to perform these sorts of operations. Most BASICs to this day follow this convention. The language was later rewritten as a true compiler as BASIC-Plus-2 , and was ported to the VAX-11 platform as that machine's native BASIC implementation. This version survived several platform changes, and

8066-437: The language. The design initially included floating-point support, but still hoping he might publish the first BASIC on the 6502 and become "a star", he decided to abandon floating-point and write a separate integer math system to save a few weeks programming time. Wozniak would later describe his language as "intended primarily for games and educational uses". Referring to it throughout development as "GAME BASIC", Wozniak wrote

8175-453: The left if the exponent is negative. Using base-10 (the familiar decimal notation) as an example, the number 152,853.5047 , which has ten decimal digits of precision, is represented as the significand 1,528,535,047 together with 5 as the exponent. To determine the actual value, a decimal point is placed after the first digit of the significand and the result is multiplied by 10 to give 1.528535047 × 10 , or 152,853.5047 . In storing such

8284-499: The machine code object files produced by the assembler and other language systems. These object files could be kept in libraries. A linker (the TKB, also known as the taskbuilder) then created executable files from object files and the libraries. TKB also supported overlays; this allowed individual routines to be swapped into the virtual address space as needed, overlaying routines not currently being used. Additionally, BP2 programs ran under

8393-411: The mainframe level was an ongoing problem by the early 1970s for those writing and maintaining higher-level source code; these manufacturer floating-point standards differed in the word sizes, the representations, and the rounding behavior and general accuracy of operations. Floating-point compatibility across multiple computing systems was in desperate need of standardization by the early 1980s, leading to

8502-477: The matrix with values in a DATA statement, MAT INPUT would fill the array with user-typed values, and MAT PRINT would print out the elements in a 1D or 2D format. MAT could also be used to set default values in a matrix using associated keywords, for instance, MAT A=ZER would fill the A array with zeros. TRN would transpose an entire matrix, and INV would invert it. Additionally, + , - , and * could be used on matrixes, performing

8611-465: The memory-mapped location of the speaker, -16336. Repeatedly PEEKing that value produced tones, and the manual suggested using a mathematical expression to do this, like S = PEEK ( -16336 ) - PEEK ( -16336 ) - PEEK ( -16336 ) - PEEK ( -16336 ) - PEEK ( -16336 ) . Support for graphics was more detailed. Graphics mode was turned on with the GR statement and off with TEXT . Drawing

8720-427: The modern approach of allocating the arrays and a memory-mapped file . Instead, a single buffer was used to store 512 bytes of data at a time, and when an entry in the virtual array was accessed, the corresponding data was read, and old data written, as required. The CLOSE statement caused the buffer to be written back (if necessary) before closing the file. Because no additional sectors were cached, accessing data in

8829-531: The more typical CONT . For step-by-step execution, the TRACE instruction could be used at the command prompt or placed within the program itself. When it was turned on, line numbers were printed out for each line the program visited. The feature could be turned off again with NOTRACE . A somewhat unusual feature was the DSP (for "display") command. When encountered in a program, from that point on any changes to

8938-458: The need for CHAINing among multiple programs. Unlike BASIC-PLUS (which was only available on RSTS/E), BP2 was also available for the RSX-11 operating system. BP2 programs were also more compatible with the later VAX BASIC . Microsoft BASIC was patterned very closely on BASIC-PLUS. Earlier versions of MS BASIC, the 1.x series, lacked integer variables, but these were added in the 2.x series that

9047-546: The parameter was ignored and RND always returned a value 0..<1, Integer BASIC used the parameter; RND(6) returned an integer from 0 to 5. Integer BASIC's string handling was based on the system in HP BASIC. This treated string variables as arrays of characters which had to be DIM ed prior to use. This is similar to the model in C or Fortran 77 . This is in contrast to MS-like BASICs where strings are an intrinsic variable-length type. Before MS-derived BASICs became

9156-420: The primary architect behind this proposal; he was aided by his student Jerome Coonen and a visiting professor, Harold Stone . Among the x86 innovations are these: A floating-point number consists of two fixed-point components, whose range depends exclusively on the number of bits or digits in their representation. Whereas components linearly depend on their range, the floating-point range linearly depends on

9265-455: The program storage for "deferred execution", either as new lines or replacing any that might have had the same number previously. Statements that were entered without a line number were referred to as commands, and ran immediately. Line numbers could be from 0 to 32767, and lines could contain up to 128 characters. Integer BASIC also included the AUTO command to automatically enter line numbers at

9374-457: The radix point is not specified, then the string implicitly represents an integer and the unstated radix point would be off the right-hand end of the string, next to the least significant digit. In fixed-point systems, a position in the string is specified for the radix point. So a fixed-point scheme might use a string of 8 decimal digits with the decimal point in the middle, whereby "00012345" would represent 0001.2345. In scientific notation ,

9483-437: The same number of digits (e.g. six), the first digit of n will be of order of tenths, the second of hundredths, etc, and one will write each quantity in the form: n ; m ." The format he proposed shows the need for a fixed-sized significand as is presently used for floating-point data, fixing the location of the decimal point in the significand so that each representation was unique, and how to format such numbers by specifying

9592-452: The semicolon to separate it rather than the comma; INPUT "WHAT IS THE VALUE" ; A . Strings could be delimited by single or double quotes. In addition to the CHR and ASCII functions that converted single characters to and from string format, BASIC-PLUS also supported Dartmouth's CHANGE command. CHANGE iterated the string and returned each character's ASCII value as

9701-496: The significand is a string of 24 bits . For instance, the number π 's first 33 bits are: 11001001   00001111   1101101 0 _   10100010   0. {\displaystyle 11001001\ 00001111\ 1101101{\underline {0}}\ 10100010\ 0.} In this binary expansion, let us denote the positions from 0 (leftmost bit, or most significant bit) to 32 (rightmost bit). The 24-bit significand will stop at position 23, shown as

9810-417: The significand range and exponentially on the range of exponent component, which attaches outstandingly wider range to the number. On a typical computer system, a double-precision (64-bit) binary floating-point number has a coefficient of 53 bits (including 1 implied bit), an exponent of 11 bits, and 1 sign bit. Since 2 = 1024, the complete range of the positive normal floating-point numbers in this format

9919-408: The significant digits of the number. This position is indicated by the exponent, so floating point can be considered a form of scientific notation . A floating-point system can be used to represent, with a fixed number of digits, numbers of very different orders of magnitude — such as the number of meters between galaxies or between protons in an atom . For this reason, floating-point arithmetic

10028-500: The single-precision format, and any integer with absolute value less than 2 can be exactly represented in the double-precision format. Furthermore, a wide range of powers of 2 times such a number can be represented. These properties are sometimes used for purely integer data, to get 53-bit integers on platforms that have double-precision floats but only 32-bit integers. The standard specifies some special values, and their representation: positive infinity ( +∞ ), negative infinity ( −∞ ),

10137-454: The style found in BASICs derived from DEC , including Microsoft BASIC . The language was initially developed under the name GAME BASIC and referred to simply as Apple BASIC when it was introduced on the Apple I. It became Integer BASIC when it was ported to the Apple II and shipped alongside Applesoft BASIC , a port of Microsoft BASIC which included floating-point support. Integer BASIC

10246-516: The system included a garbage collecting memory manager, used for both string data and byte-code. A running program could be interrupted, have variables examined and modified, and then be resumed. BASIC-PLUS is patterned closely on later versions of Dartmouth BASIC , including its powerful MAT commands. On top of this, DEC added a number of unique flow-control structures. Line numbers were positive integers from 1 to 32767. Logical lines of code could be continued on multiple physical lines by using

10355-608: The task of designing a floppy disk controller for what became the Disk II . Mike Markkula said the company would go to the Consumer Electronics Show in Las Vegas if the disk system was ready in time, so Wozniak and Randy Wigginton worked on it non-stop through the 1977 holidays. When he returned to the topic of floating-point in BASIC, Jobs complained it was taking too long. Without Wozniak being aware,

10464-547: The underlined bit 0 above. The next bit, at position 24, is called the round bit or rounding bit . It is used to round the 33-bit approximation to the nearest 24-bit number (there are specific rules for halfway values , which is not the case here). This bit, which is 1 in this example, is added to the integer formed by the leftmost 24 bits, yielding: 11001001   00001111   1101101 1 _ . {\displaystyle 11001001\ 00001111\ 1101101{\underline {1}}.} When this

10573-577: Was based on BASIC-8 for the TSS/8 , itself based very closely on the original Dartmouth BASIC . BASIC-PLUS added a number of new structures, as well as features from JOSS concerning conditional statements and formatting. In turn, BASIC-PLUS was the version on which the original Microsoft BASIC was patterned. Notable among the additions made to BASIC-PLUS was the introduction of string functions like MID$ and LEFT$ , in addition to Dartmouth's original all-purpose CHANGE command. In future versions of

10682-478: Was connected to one of their mainframes running their time-sharing BASIC service, which they were heavily promoting at the time. After being given three days of access, the students were asked to write letters on why the school should receive a terminal permanently, but their efforts were ultimately unsuccessful. Some years later, Wozniak was working at Hewlett-Packard (HP) running simulations of chip designs and logic layout for calculators. HP made major inroads in

10791-408: Was established, and since the 1990s, the most commonly encountered representations are those defined by the IEEE. The speed of floating-point operations, commonly measured in terms of FLOPS , is an important characteristic of a computer system , especially for applications that involve intensive mathematical calculations. A floating-point unit (FPU, colloquially a math coprocessor ) is a part of

10900-497: Was going to the awful string functions like LEFT$ ( VAR , 5 ) and MID$ ( VAR2 , 5 , 3 ) instead of my own". When the Apple II shipped in the summer of 1977, Integer BASIC was supplied in ROM, while Applesoft BASIC shipped on cassette. This changed with the introduction of the Apple II Plus in 1979, when Applesoft was put in the ROM. Like most BASIC implementations of the era, Integer BASIC acted as both

11009-533: Was limited to a little less than 64KB of space. Using BASIC-PLUS, about half of this virtual address space was used by the combined command interpreter and run-time library (named the Run Time System on RSTS/E). This limited user programs to about 32 kB of memory. Large programs were broken into separate executable pieces by use of the CHAIN statement, and programs could chain to specific line numbers in

11118-430: Was modal and normally started by issuing a command to change the color, which was accomplished by setting a pseudo-variable; COLOR=12 would set the drawing color to 12, light green. One could then PLOT 10,10 to produce a single spot of that color, HLIN 0,39 AT 20 to draw a horizontal line at row 20 that spanned the screen, or VLIN 5,15 AT 7 to draw a shorter vertical line down column 7. A=SCRN X,Y returned

11227-610: Was much more flexible than hardware", and that he and Jobs realized that "now, anyone could create arcade games without having to design it in hardware." Wozniak did complete a floating-point library for the 6502 and published it in the August 1976 edition of Dr. Dobb's Journal . This library was later made part of the ROMs for the Apple II . Wozniak began work on back-porting the floating-point code into Apple BASIC, but got sidetracked in

11336-402: Was not an interpreter but a compile and go system : each line of BASIC was translated into "PPCODE" (Push-Pop Code) as it was entered, for subsequent fast execution on its virtual machine. These translations did not tokenize the BASIC lines but rewrote them for use on a stack machine; you could not translate these representations back to BASIC statements. This avoided the need to repeatedly decode

11445-1010: Was not until the launch of the Intel i486 in 1989 that general-purpose personal computers had floating-point capability in hardware as a standard feature. The UNIVAC 1100/2200 series , introduced in 1962, supported two floating-point representations: The IBM 7094 , also introduced in 1962, supported single-precision and double-precision representations, but with no relation to the UNIVAC's representations. Indeed, in 1964, IBM introduced hexadecimal floating-point representations in its System/360 mainframes; these same representations are still available for use in modern z/Architecture systems. In 1998, IBM implemented IEEE-compatible binary floating-point arithmetic in its mainframes; in 2005, IBM also added IEEE-compatible decimal floating-point arithmetic. Initially, computers used many different representations for floating-point numbers. The lack of standardization at

11554-466: Was phased out in favor of Applesoft BASIC starting with the Apple II Plus in 1979. As a senior in high school , Steve Wozniak 's electronics teacher arranged for the leading students in the class to have placements at local electronics companies. Wozniak was sent to Sylvania where he programmed in FORTRAN on an IBM 1130 . That same year, General Electric placed a terminal in the high school that

11663-405: Was the == operator, for "approximately equal". This would return true if the two numbers would be printed the same, that is, their six most significant digits were the same. Logical operators included the typical NOT A , A AND B and A OR B , along with A XOR B , A EQV B which return true if both A and B are true or both are false, and A IMP B which is false if A is true and B

11772-705: Was the editable source code in text format, created using the SAVE command and normally placed in a .BAS file. The other was the PPCODE version of the program created by the COMPILE command and saved to a .BAC file; .BAC files were smaller and loaded and ran faster, but could not be edited. A related product called Basic Plus 2 ("BP2" or BASIC-Plus-2 ), was later developed by DEC to add additional features and increased performance. It used true compilation into threaded code and wrote its output to object files compatible with

11881-441: Was unusual in supporting any length variable name (e.g., SUM, GAMEPOINTS, PLAYER2). The only caveat was that variable names could not contain reserved words; for example, THISCOLOR and COLORFUL were invalid variable names because they contained the keyword COLOR , a system command. Additionally, lines were limited to 128 characters, so variable names could not exceed that length. Integer BASIC, as its name implies, uses integers as

#576423