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
Integer BASIC
(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!
==Implementation== Integer BASIC read the lines typed in by the user from a buffer and ran them through a [[Parsing|parser]] which output a series of [[Lexical analysis|tokens]]. As part of this process, simple [[syntax error]]s 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.{{sfn|Wozniak|1977|p=42}} Some keywords were represented by multiple tokens; for instance, where Microsoft BASIC had one token for the keyword {{code|PRINT}}, Integer BASIC had three tokens: one if the keyword was followed by no arguments, one if followed by an arithmetic expression, and one if followed by a string literal.<ref>{{cite web |url=https://www.callapple.org/docs/ap2/special/integerbasic.pdf |title=Apple II Integer Basic Disassembly |author=Paul R. Santa-Maria |access-date=2020-09-14 }}{{Dead link|date=March 2022 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> Numeric literals, like the value 500, were converted into their 16-bit (two-byte) binary representation, in this case, {{mono|$01F4}} [[hexadecimal]]. To indicate this was a value and not a keyword, a single byte between {{mono|$B0}} and {{mono|$B9}} was inserted in front of the two-byte value.{{efn|The first digit of the original value was used to select a value from 0 to 9, so in this example, the token would be {{mono|$B5}} for the first digit of 500.}} String literals, like "HELLO WORLD" were instead converted by setting the high bit of each character so that {{code|A}} was stored as {{mono|$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 {{mono|$B0}} through {{mono|$B9}}, so that the variable {{code|A5}} would be tokenized as {{mono|$C1B5}}.{{sfn|Wozniak|1977|p=42}} If the line was entered without a line number, the code was then executed directly from the buffer. If it had a line number, it was copied from the buffer into the program storage area.{{sfn|Wozniak|1977|p=42}} 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 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.{{sfn|Wozniak|1977|p=42}}
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)