7 nov 1983 basic ode 2

Upload: prabhjot-singh1

Post on 06-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 7 Nov 1983 Basic Ode 2

    1/3

    Basicode-2

    a code tomake BASICprogrammesexchangeable

    2400 Hz. A logic '0' corresponds to onewhole period of 1200 Hz while a logic'I' is two full periods of 2400 Hz.Each byte is transmitted serially at a rateof 1200 baud, and every byte is built upas follows (see also figure I):- 1 start bit (logic zero)- 8 data bits, least significant bit first- 2 stop bits (logic one)The BASIC programme is coded characterby character in the form seen when a LISTcommand is given. No internal computer no-tation is used. 'All letters and figures aresimply represented in ASCII code. EveryBASIC instruction must be followed by aspace, and each BASIC line must be finishedwith CR (carriage return, 8Dhex). Themost significant bit of every ASCII sign ismade'l'.A complete programme on tape consistsof the following sections:

    a leader consisting of a 5 second toneof 2400 Hzthe ASCII sign 'start text' (82hex)the BASIC programme in ASCII codethe ASCII sign 'end of text' (83hex)a 'checksum'a trailer, consisting of-a 5 second toneof 2400 H2;.The checksum, which is used for errordetection, consists of a bit-by-bit exclusiveOR function of all previous bytes (includingthe 'start text' sign). This checksum is 8 bitslong (1 byte).

    The majority of modern hobby computers use the programming languageBASIC. However, that does not mean that a BASIC program can be exchangedbetween two different types of computers, either directly or via a cassette. TheBASIC commands may well be the same but the way in which the computerdeals with them and how they are put on cassette are often completelydifferent. Basicode was developed to solve this problem. It is a sort of universalcommunication standard to allow BASIC programmes to be interchangeablebetween different types of computers.

    The Basicode-2 protocolGeneral agreements

    The only BASIC statements allowed arethose which are known by all computers.These statements are listed in table I, andwe will return to this later. A number of linenumbers are reserved for special definedsubroutines .: This ensures .that certainoperations are possible that cannot easilybe achieved in standard BASIC. These

    basicode-2.It is about two years since NOS, the Dutchbroadcasting company, came up with theidea of developing a standardised code tomake it possible to exchange BASIC pro-grams between two different types ofcomputers. As with most things that Murphygets a hand in, this is not entirely straight-forward. First of all there is the problem ofstorage on cassette. Most hobby computersuse cassette recorders as a means of storingprogrammes. The method of registeringdata on tape and the frequencies used aredifferent for each type of computer. Asecond difficulty is the BASIC languageused. Even though a standard BASIC exists,each computer uses a different 'dialect'with its own peculiarities. There is also aproblem as regards how programs are storedand processed within a computer, as thereis no international agreement on this.Because of these factors BASIC, eventhough it is widespread, is not at all inter-changeable between two computers that'think'differently.The Basicode standard is a fixed audio codeby means of which BASIC programs can bestored on cassette. Through this standard-isation, programs can be written ontocassette from any type of computer andread back to any type of computer. Thatis not to say that Basicode is simply atranslation programme to store BASICprograms on tape in a specific manner.Just as important are the argeement on theBASIC commands used, the arrangement ofline numbers, the names of variables and thescreen format.At present there is already a second versionof Basicode available that uses a series ofstandard subroutines. At the same time afew other points have been changed fromthe original version with the aim of makingBasicode even more universal. This Basi-code-2 is the subject of this article.Basicode on tape'

  • 8/3/2019 7 Nov 1983 Basic Ode 2

    2/3

    basicode-2

    Figure 1_This is how thetransfer format is builtup in Basicode. Note thattransfer begins with theleast significant bvte.

    It is recommended that the line numbers areincreased in steps of 10_As regards the sub-routines at lines 20000-24999, these shouldbe avoided as much as possible, If this is notpossible, it should be made perfectly clearwhat each subrou tine does,Standard subroutines in Basicode-2

    gram, so they must either be a part ofthe Basicode transla tion programme orthey must be written in separately beforeRUNning a BASIC proqramme.The screen dimensions are fixed at 24 linesof 40 characters. Because some computershave less than 24 lines on the screen orless than 40 characters per line, it is rec-ommended that no more than 16 screenlines be used and that the lines should bekept as short as possible.A program line, including line number,spaces and carriage return, can have amaximum of 60 signs.

    How a program is built up

    The following groups of line numbers arereserved in Basicode-2:0-999: standard routines. These are speciallydeveloped for the computer in ques-tion and are supplied through the translation

    programme or are read in separately.1000: the first line of the program. It musthave this form:1000A= (value): GOTO 20: REM programname (value) is the maximum num-ber of characters that are used together in allstrings. By jumping to line 20, the computersthat .need it reserve some memory spacefor the strings.1010: the first line that can be used for

    the program.1010-32767: space for the pogram.There is no compulsory system within theprogramme, but the developers of Basicoderecommend the following groupings:1000-19999: main program20000-24999: subroutines for the pro-gramme, in which statementsexist that are not permitted in Basicode-225000-29999: data statements30000-32767: REM statements. These canbe a description of theprogram, references or the name and addressof the programmer.

    0: ~ L-fI f = 1200 Hz

    1: 1J1J 0 ' t . 1 1 . r f =2400 Hz

    Byte build up:Example: OShax (ASCII 58 with "1" as the eighth bit)

    1 byte

    1: 1 1 1 1

    These subroutines are very much dependentupon each particular computer so this isjust a general description of the functionof the subroutines with no examples given.GOSUB 100: This clears the screen andplaces the cursor at position 0.0 (upper leftcorner of the screen).

    GOSUB 1lO: Set the cursor at a specificplace on the screen. The desired locationmust be stored in variables HO and VE.HO is the position in a line (0 is completelyleft) and VE givesa line number (uppermostline is number O ). As the screen format inBasicode-2 is 40 characters on 24 lines, HOcannot be greater than 39 and VE no biggerthan 23. The values of HO and VE do notchange by calling this subrou tine.

    o 100 0,,

    , ,, ,

    I I 0 Q a.~ :~ .-"--- -I. oJ.: .-- " '-- _ .. ~ ~

    GOSUB 120: The position of the cursor onthe screen is set in the variables HO and VE.With this system HO = 0 is the first positionin a line and VE = 0 is the top line. Thisroutine can be used with the previous oneto, for example, move the cursor one ormore lines higher or lower.

    GOSUB 200: See if a button is pressedand store the value of this key in IN$. Ifno key is pressed at that moment, IN$ isempty. In principle, control characterscould also be stored but this requires cautionas these have different meanings for differ-ent computers. One exception is RETURN,which is ASCII code 13 in all computers.GOSUB 2lO: This routine waits until a keyis pressed and stores the vlaue in IN$.This routine actually waits for a key tobe pressed, whereas in the previous one avalue was only stored if a key was pressedat the actual instant when the routine wasrunning.

    GOSUB 250: This subroutine gives a bleepin computers that have this facility. Thefrequency and duration of the bleep arenot specified here.

    GOSUB 260: An arbitrary number betweeno and 1 is generated and stored in variableRV.

    83101-1-1

    GOSUB 270: The whole variable space iscleared up and the routine finds out howmuch memory space remains (the variablesare not cleared!). The number of free bytes

  • 8/3/2019 7 Nov 1983 Basic Ode 2

    3/3

    Basicode-2

    II/

    GOSUB 300: The value of variable SR isstored as a string in SR$. The string cannotcontain a space at the beginning or end ofa number. This is in contrast to STR$ whichdoes this sometimes. STR$ is not permittedas a Basicode-2 statement in any case.GOSUB 310: This routine supplies a stringSR$ built up as follows. The value of SR$ isequal to the contents of variable SR and isalways in fixed-point notation. The totallength of SR$ contains CT charactersand the number of characters after thedecimal point is defined by CN. If thenumber does not fit in the stated formatSR$ consists of CT asterisks. CT, CN and SRare not changed by calling this rou tine. Anexample of this rou tine is: CT = 7, CN = 3and SR = 0.6666, then SR$ =' 0.667'.GOSUB 350: Prints SR$ on the printerbut does not finish the line yet. This makesit possible to print different strings one afteranother on the same line.GOSUB 360: Closes a print line with acarriage return and new line command.Variables

    To ensure that the interchangeability ofprograms is maintained, there are somelimitations as reqards the variables used inany program:Numeric variables are always real andwith single precision.The name of a variable can only have amaximum of two characters, and thefirst must be a letter. The second may,depending on use, be a letter or number.String variables have a $ after the name.Lower case letters are not permitted ina variable.- Logic variables can only be either trueor not true. Any value that could beconfused with something else by the com-puter may not be used, for example +l fortrue and 0 for not true.- It must not be assumed that all variablesare reset to zero at the start of a pro-gramme.String variables can be no longer than255 characters.Variables may not begin with the letterQ, as this is reserved for the standardsubroutines.

    Table 1. These are the permitted BASIC commands andoperations.ABS DIM INPUT NOT RETURN STOPAND END LEFT$ ON RIGHT$ TABASC FOR LEN OR RUN TANATN GOSUB LET PRINT SGN THENCHR$ GOTO LOG READ SIN TOCOS INT MID$ REM SQR VALDATA IF NEXT RESTORE STEP+ t =>

    Variables AS, AT, FN, GR, IF, PI, ST,TI, TI$, and TO may not be used.The variables HO, VE, FR, SR, CN,CT, RV, IN$ and SR$ are used forcommunication between the BASIC pro-gramme and the standard subroutines.

    BASIC limitations

    Table 1 gives a summary of all the per-mitted BASIC commands and operators.Here some basic agreements are necessary.There are some variants in the BASIClanguage but usually the meanings of com-mands are much the same as in the officialBASIC, so we will not discuss the variationshere.There are, however, a few points aboutBASIC commands that do require clari-fication. A variable name may not be useddirectly after a GOSUB or GOTO; so A =1000 : GOTO A is not permitted. Thecommand IF must always be followed byTHEN. For example: IF ... THEN A =5, IF ... THEN 1000 and IF THENGOSUB 20000. The form IF THEN .... ELSE is not allowed. Comments ormultiple variables are not permitted afteran INPUT; so INPUT 'The value is'; A$is forbidden. A line number may not begiven after RUN. If using the TAB state-"ment, remember that some computersstart counting at zero and others beginat one.

    In practice

    Those are the most important points aboutBasicode-2. Apart from these, a translationprogram and the 'permitted' subroutines areneeded bu t we will not give them herebecause they are different for each com-puter. The translation program is in machinecode and sometimes has a BASIC part,depending on the type of computer. Thereare already programs available for variousdifferent types of computer, and generallya specialized computer club can help here.If everything went according to plan, the '_Basicode-2 book is already available, givingthe complete Basicode-2 protocol andseveral different translation programmes forcommon types of computer. Further infor-mationcan be obtained from Hans G.Janssen, Hobbyscoop, Postbus 1200, 1200BE Hilversum, The Netherlands. The Basi-code-2 book itself, which is printed withEnglish and Dutch in the same book, isalso available from Hobbyscoop. Basi-code programs are also broadcast duringthe Hobbyscoop programme on Sundaysfrom 17.10 ... 17.45 GMT (summer) or18.10 ... 18.45 (winter) on 747 kHz.Finally, to return to our own Junior Com-puter. Elsewhere in this issue we have anarticle giving the translation programmeand various subroutines for the BASICJunior Compu ter. Translation programmesfor both the expanded Junior and theDOS junior are available and this articlehas both of them! III

    11-1~