Atari BASIC: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 1:
{{WIP|Leo72}}
{{Linguaggio di programmazione
|nome = Atari BASIC
Line 41 ⟶ 40:
 
Un programmatore poteva sapere la versione dell'interprete in uso esaminando una precisa locazione di memoria. Il comando <code>PRINT PEEK(43234)</code> inserito al READY della macchina resistuiva <code>162</code> per la Revision A, <code>96</code> per la Revision B e <code>234</code> per la Revision C.
<!--
==Description==
===Program editing===
[[Image:AtariBasicError.png|frame|right|What happens when a line containing a syntax error is entered]]
 
==Descrizione del linguaggio==
Atari BASIC uses a [[line editor]], like most BASICs of the era. Unlike many BASICs, however, Atari BASIC immediately checks the line for [[syntax error]]s. If a problem is found it shows the line again, highlighting the text near the error in [[inverse video]]. This can make catching syntax errors on the Atari much easier than on other editors; most BASICs will not display the errors until the program is executed. (The [[Sinclair Research#Home computers|Sinclair ZX]] family of machines also adopts the approach of checking each line as it was entered, although it differs by not even allowing the line to be entered until it is syntactically correct, which can be a hindrance to the programmer when writing a line of code but wanting to look up something elswehere in the program.)
===Editor del programma===
L'Atari BASIC usava un [[editor (informatica)|editor]] a righe, come molti BASIC del tempo. A differenza di altri, però, esso analizzava immediatamente la riga immessa alla ricerca di errori di sintassi. Se veniveva inserito un comando sbagliato, l'editor riproponeva la riga che lo conteneva mostrando il punto in cui aveva individuato l'errore.
 
Quando l'interprete non stava eseguendo un programma, era nella cosiddetta "modalità immediata". Le righe inserite che iniziavano con un numero venivano considerate come righe del sorgente e memorizzate, mentre le righe che iniziavano direttamente con un comando venivano analizzate ed eseguite immediatamente.
When not running a BASIC program, the Atari is in [[direct mode]] or immediate mode. Program lines can be entered by starting with a line number, which will insert a new line or amend an existing one. Lines without a line number are executed straight away, hence the name ''immediate mode''.
 
Quando il programmatore digitava il comando <code>RUN</code> l'interprete eseguiva il programma presente in memoria. Al comando si poteva passare anche un numero di riga, ad esempio <code>RUN 2000</code>, per iniziare l'esecuzione del codice da un determinato punto. Se la riga esisteva, l'esecuzione partiva da quella indicata, altrimenti dalla prima riga presente dopo quella specificata.
When the programmer types <code>RUN</code> the program executes from the first statement. It can also be given a line number, so that <code>RUN 2000</code> will run the program from line 2000, or the first line after that if line 2000 does not exist.
 
A differenza di altri interpreti, l'Atari BASIC permetteva di eseguire tutti i comandi sia durante l'esecuzione del sorgente che in modalità immediata. Ad esempio, <code>LIST</code>, che mostrava il listato sorgente presente in memoria se inserito in modalità immediata, funzionava anche se richiamato dall'interno del programma stesso. Questo modo di interpretare i comandi era utile nel caso si fosse voluto scrivere del codice auto-modificante.
Unlike most other BASICs, Atari BASIC allows ''all'' commands to be executed in both modes. For instance most BASICs only allow <code>LIST</code> to be used in immediate mode, while Atari BASIC also allows it to be used inside a program. This is sometimes used as part of a way to produce [[self modifying code]].
 
Ogni riga del programma (le "righe logiche") potevano occupare fino a 3 righe dello schermo (le "righe fisiche") da 40 caratteri ciascuna, per un totale di 120 caratteri. Il cursore poteva essere mosso liberamente all'interno di queste righe, a differenza degli editor di altri BASIC dove per andare "su" in una riga di programma bisognava per forza scorrere a sinistra finché il cursore non arrivava al bordo e proseguiva dalla fine della riga precedente dello schermo (la stessa cosa per scorrere "giù"). Il cursore poteva essere mosso liberamente all'interno dello schermo, e se usciva da un lato ricompariva dall'altro.
Program lines ("logical lines") can be up to three screen lines ("physical lines") of 40 characters, so 120 characters total. The cursor can be moved freely in these lines, unlike in other BASICs where to get "up" a line one has to continuously scroll leftwards until the cursor is wrapped at the left margin (and similarly to go down when wrapping at the right margin) &ndash; though that works too, except the cursor when wrapping left to right or right to left does not move up or down a line. The OS handles tracking whether a physical line flowed to the next on the same logical line; the three-line limit is fairly arbitrary but keeps lines below 128 characters and so reduces the chances of [[buffer overflow]].
 
====Character set====
The cursor can always be moved freely around the screen, and it will wrap on all sides. Hitting "ENTER" will send the tokenizer the (logical) line on which the cursor sits. So, in the example pictured above (with "<code>PRUNT</code>"), all the author needs to do to fix the error is move the cursor over the "<code>U</code>", type {{keypress|I}} (the editor only has an overwrite mode) and hit {{keypress|ENTER}}.
L'Atari usava una versione modificata della tabella dei caratteri [[ASCII]], denominata [[ATASCII]]. I primi 128 caratteri corrispondevano per la maggior parte a quelli ASCII, con l'eccezione che tutti i caratteri erano stampabili, anche quelli con i codici da 0 a 31, che nella tabella ASCII non lo erano perché corrispondenti a "codici di controllo" che eseguivano operazioni particolari come ad esempio il ritorno a capo. I caratteri dal 128 al 255 erano la visualizzazione inversa dei primi caratteri da 0 a 127.
 
L'interprete accettava per i nomi delle varibili i caratteri maiuscoli (65-90) ed i caratteri numerici (48-57), con il nome che doveva iniziare con una lettera. I nomi delle stringhe di testo dovevano terminare con il simbolo del dollaro, <code>$</code>.
This is quite a frequent editing technique for, say, renumbering lines. Atari BASIC has no built-in renumbering command, but one can quickly learn to overwrite the numbers on a set of lines then just hit "ENTER" repeatedly to put them back into the program. Indeed, a slightly cryptic but essentially simple idiom allows this to be done by the program itself as it is running, producing [[self-modifying code]]. This is not an artifact or cheat around the system but inherent in the combined behavior of the editor and tokenizer.
 
L'insieme di caratteri conteneva anche i caratteri minuscoli ed alcuni caratteri grafici anche se poi la maggior parte dei linguaggio che furono resi disponibili per quei computer, compreso l'Atari BASIC, non riconoscevano i comandi scritti in lettere non maiuscole.
====Character set====
{{Main|ATASCII}}
The Atari variation on [[ASCII]], called [[ATASCII]], has 128 (80<sub>16</sub>) characters mostly corresponding to ASCII but with a few exceptions. All characters have printable forms unlike ASCII where codes 0-31 (0-1F<sub>16</sub>) are "control codes" that perform special functions such as requesting a paper feed or ringing an attention bell. Characters 128-255 (80<sub>16</sub>-FF<sub>16</sub>) are displayed as the [[inverse video]] of characters 0-127 (00<sub>16</sub>-7F<sub>16</sub>). Variable names must be composed of upper-case alphabetic (65-90, 41<sub>16</sub>-5A<sub>16</sub>) and numeric (48-57, 30<sub>16</sub>-39<sub>16</sub>) characters, starting with an alphabetical character, and for strings terminating with a dollar sign (36, 24<sub>16</sub>). <!-- were underscores allowed? They weren't common. -->
<!--
The character set has a full ensemble of lower case characters and some graphics characters, but programming in Atari-supplied languages (BASIC, Assembly, [[PILOT]], [[Atari Pascal]], [[Atari LOGO]]) and third-party languages such as COBOL is done exclusively in upper case. Lower case letters are not recognised by most compilers on the Atari; lower case characters can only be used within string manipulation and display, and in REMarks. This is in line with pre-1990 era programming convention. Most 6502-based machines (including 6502-based [[Apple II series]] and [[Ohio_Scientific]] computers), [[punched card]] systems and earlier versions of the [[EBCDIC]] character space did not have or use lower case. Legibility was also a concern with the font squeezing [[Ascender (typography)|ascenders]] and [[descender]]s into the 8&times;8 fixed grid which define each display [[glyph]] and the 8&times;7 fonts used on many [[dot matrix printer]]s such as Atari's own.
 
Nelle ROM della Revision C dell'interprete fu inserito un insieme di caratteri alternativo che comprendeva anche le lettere accentate, pensato per l'uso in [[Europa]].
On Revision C ROMs there is an alternative font which includes characters with [[diacritic]]s, intended for European users, but this is rarely used. Because the hard-coded font is shawdowed in and called from RAM, adding user-defined fonts is relatively easy and each takes 1 kilobyte (128 characters &times; 8 bits high &times; 8 bits wide).
 
Dato che l'insieme di caratteri era copiato in una determinata zona della memoria RAM da cui l'interprete leggeva i dati per i caratteri da stampare a video, l'utente poteva modificare tale insieme semplicemente copiando la propria mappa di caratteri sopra a quella originale (la modifica valeva solo fino allo spegnimento della macchina).
<!--
The ANTIC chip uses one byte to indicate the start page of a font (the memory consisting of 256 pages of 256 bytes). But only one font can be used at a time without machine code [[raster interrupt|display list interrupts]] to change the font midway down the screen. An infrequently used 8&times;10 font mode exists, where the range of characters for lower case letters are shifted down two lines thus allowing the actual glyphs to be 8&times;8 yet be presented with ascenders or descenders. This mode is only occasionally used, partly because dot matrix printers cannot easily support it.<ref>Some programs such as PrettyPrint exist which do so by sending the output as graphics to the printer, so that seven lines of 8-bit-high text are printed as eight passes of the 7-bit-high print head.</ref> The ease of implementing other fonts means many are freely available, with font editors and so forth.