background image

Содержание 2001-8

Страница 1: ... PET PERSO OMPUTER PERSONAL COMPUTER PERSONAL COMPUTER PERSONAL COMPUTER ...

Страница 2: ...be entirely reliable However no responsibility is assumed for inaccuracies The material in this manual is for information purposes only and is subject to change without notice first edition Commodore Business Machines tnc 1978 All rights reserved Commodore Business Machines 901 California Avenue Palo Alto California 94303 ...

Страница 3: ...nditional and conditional looping Data entry Advancedprogrammingtechniques String variables and functions Subroutines FOR NEXT loops Subscrpted variables 1 3 11 19 32 38 I Chapter 7 ChapterS Chapter 9 PETcommunicationwiththeoutsideworld 57 PET interfaces and lines Commands and operations for peripheral devices IEEE 488bus Machinelanguageprogramming 91 Allocation of memory Commands from BASIC Machi...

Страница 4: ...xpressed in terms of built in BASIC functions Principal pointers into PET RAM Simplified view of PET Edge connectors J1 and J2 PET IEEE connector pinout Receptacles for the IEEE interface IEEE standard connectors Parallel user port information 6522 VIA addresses in PET Parallel user port example Connector J3 contact identification Second cassette interface port PET second cassette edge connector J...

Страница 5: ... 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 8 1 8 2 LIST OF FIGURES continued Memory expansion connector Multiple file structure OPEN for write from PET OPEN for read to PET Status word errors Default parameters Examples of default parameters IEEE bus contact identification Transfer bus handshake sequence Byte transfer from talker to listener Signals described by IEEE bus groups 63 69 73 74 80 82 82 ...

Страница 6: ...LIST OF APPENDICES A Detailed PET memory map B BASIC statements c BASIC commands D Expressions and operators E Space and speed hints F Main logic board assembly G Suggested reading v ...

Страница 7: ...our PET 2001 is an MCS 6502 microprocessor This microprocessor totally controls operation of the screen keyboard cassettes and additional peripherals which can be added to the PET The product is so construed that you cannot damage the PET from the keyboard The operating system cannot be destroyed because the computer software or operating instructions are contained in a fixed memory Called Read On...

Страница 8: ...our own any questions which might arise are answered by the machine itself Of course we invite comments on this material and particularly on examples which you as an individual have used to resolve any unclear statement Lastly since this manual cannot presume to provide all technical information of hardware or programming aspects of the MCS 6502 microprocessor we direct you to two other Commodore ...

Страница 9: ... interfacing connectors The power switch is located in the left rear of the PET Closing the switch to the left turns the PET on and closing it to the right turns it off There is a white dot on the power switch to indicate it is in the power on position or an ON OFF label Immediately when the power switch is turned on power is supplied to the internal circuits There is a time out circuit in a speci...

Страница 10: ...igit of Information The SK model should show In theory S192 bytes But a few hundred are used by the PET internally The balance shown 7167 is net available bytes If you fail to get the power up display the first time try turning the power switch slowly off then back on To get the display four different types of memory are used ROM User ReadlWrite 1 0 Input Output and Screen Memory The relationship ...

Страница 11: ...wing where the ROM RAM 110 and Screen Memory are located from a programming standpoint As you can see by the map the first 1024 bytes of memory are reserved for the operating system to use for its various tasks including the buffering of data from the cassettes and other 110 devices The message 7167 BYTES FREE is a result of an analysis of BASIC which starts at locxation 1024 and cycles through th...

Страница 12: ...me it is addressed These dots are serially fed to the screen working from left to right and top to bottom This gives an 8 bit wide 8 bit tall character with no spaces between characters The CRT controller automatically changes the addressing of the character generating ROM depending on whether or not it is scanning the top line of a character the second line of of a character etc There are two cha...

Страница 13: ...llJ W 1e lJ LIlN H X h x il l HI c 1 1 y i 1 1 L bUJ l J 0 z 11 111 VI I K L k 11CSld H L 1 11 t H fj 1 J m 111 0 kti N t n 1111 1 V t 0 Figure 2 ASCII ch8r8ct set 7 bit code Example in the PET A is represented 0100 0001 Shifted A a spade is 11000001 The screen memory is organized with a different representatIon from the main PET memory There are only 64 characters from the standard ASCII set that...

Страница 14: ...11 G W I 0 I 111 H X II I 4 111111 I V Y 1 1 J I J 11111 K L J lUIl J L L 1 11111 M J I 111 N 1 1111 0 I FIgure 2 8 PET graphic charaet Nt 7 bit code Example This gives us the following conversions Character In main memory In screen memory A 01000001 00000001 1100 0001 00000oo1 1 00110001 00110001 10110001 01110001 Note the reduction from seven bit ASCII to six bit gives the effect of changing the...

Страница 15: ...d input is enabled the character being struck on the keyboard is automatically displayed on the screen The third approach is by use of the PRINT command in BASIC When PRINT ABC is typed to BASIC it results in the next line being printed as ABC This is a print of a literal field in which all characters between the quotes are printed The next position at which a character will be displayed if typed ...

Страница 16: ...to cause the upper or shifted characters displayed on the keyboard to be operational Lower characters are always used unless one of the two shift keys is pressed simultaneously Each key has a thin transparent plastic film covering the keytop which should be removed This protection was left in place to protect the keys against scratching dUring shipping To remove the film carefully peel it off by u...

Страница 17: ...M O l a g E 6 l OIIa l Cal E c III I CD 0 III zi O J EJ J to O C J J J a J EJ O J o ID 0 E l on O C J J m B J 1 t O G J Iii JlE O C J J l JlEC J c 0 O B a o C l J apoo9 J pJeoQ a j 1 D II 12 ...

Страница 18: ... time that you are scanning and changing the queue Both the GET and keyboard input routine take care of that automatically by only operating during the interrupt or with the Interrupt masked Whenever the screen editor routine is operational a special two level operating system is in play The first level enables the cursor to flash and writes data from the keyboard to screen memory at the current c...

Страница 19: ...alculator The first thing that we want to do is have the machine type a simple message You should have already done this with your users guide However we hope by now that you understand a little better We type the line HI THERE R E T U R N You will see that BASIC responds by printing HI THERE It should be noted that each time we struck a key on the keyboard the cursor moved automatically one place...

Страница 20: ...ine Cursor left of course just moves the cursor pointer one character less in memory Going to the left it moves one character at a time Obviously by doing this we are able to edit the screen However faster editing can often be achieved by use of the cursor up and down keys CURSOR UP AND DOWN The cursor down moves the pointer 40 columns to the right from its current position This gives it the same ...

Страница 21: ... although the PET screen can display only 40 characters per line the user is given all the flexipility of an 80 eolumn line This is accomplished by allowing the screen to define more than 40 characters as a line If we move our cursor over to the beginning of the line below HI THERE and start typing NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THE PARTY we will see that after typing the E...

Страница 22: ...cter is moved to the first etc and 40 characters are blanked at the bottom of memory The cursor is positioned automatically in the same position at the bottom of the screen as it was when you tried to move the cursor down or in the case of a carriage return and or printing the cursor is moved automatically to the left and side of the bottom line This process is totally automatic and is caused by a...

Страница 23: ...nted in the next available print position on the screen under the control of BASIC and an editor which is keeping track of the screen position Although the physical representation on the screen is 25 fines by 40 characters the printing of up to 80 characters is accomplished by the screen automatically folding over the 41st character onto the next line The computer automatically scrolls the screen ...

Страница 24: ... byte binary quantities except in the special case of inlegers which are represented in two bytes As far as prinling is concerned BASIC prinls integers the same as it does floaling point numbers In fact BASIC automatically converts integers to 110ating point and then the floating point print routine converts the floating point numbers inlo printable characters VARIABLES We have already seen thai t...

Страница 25: ...ples on your PET Remember to press RETURN after each command you enter CLR A PET prints D Now type A 2 2 A This time PET prints 4 Now type B PET prints O Now replace the value of B with twice the value in A by typing B 2 A B PET prints 8 Now change the value of A by typing A 2 3 A PET prints 5 If you now type B PET prints 8 the same value as before Until we give a new expression for B or re execut...

Страница 26: ...de is quite useful for debugging of computer programs Variables can be assigned intermediate values and then small sections of the program can be executed with GOTO statements to assess why any particular piece of code is not working correctly Break points can be put in programs and current status of variables checked with print commands again in direct mode without having to modify your main prog...

Страница 27: ...ition the cursor on the space following the I on line 20 and insert a cursor down First by hitting the insert key and then the cursor down key if you don t hit the insert key first the cursor will move down immediately But because you inserted the cursor down it looks like a reverse field Q the cursor will not move until instruction 20 is executed Do not forget to hold down shift before striking i...

Страница 28: ...he program line then executing that keyword under the control of a series of subroutines This is a trade off which results in very memory efficient storage programs but longer execution times than would be true of a machine language program Because PET BASIC uses tokens in memory and stores them on I O devices whenever a program is loaded and saved the actual coding of data on tape or in memory is...

Страница 29: ...cter Cursor right is a right bracket and cursor left is the shift of that character and looks like a vertical line through the 5th column of dots Insert is a shifted T which looks like a second vertical line You cannot enter a character in reverse field into a literal but you can turn on reverse field with the control character before your character is printed The only characters that are allowed ...

Страница 30: ...racter for reverse field on inserted TYPE HI reverse field on THERE reverse field off PET Note that the reverse field on and off characters occupy a space on the screen when programming and that they appear in reverse field but the THERE is not in reverse field yet The effect of the quote is to postpone the action of a control character until the titeral is interpreted Since the reverse field is t...

Страница 31: ... 12P FUNCTIONS There are three functions which are available in BASIC which are at the time of writing unique to the PET The first of these isTT Whenever this character is used in an expression BASIC translates it from the keyboard character ofTI to the value of 3 14159265 etc It can be used anywhere in any expression and will always be evaluated as this number Example ll TI and the value Tl are t...

Страница 32: ...mmand The use is really quite simple If A equals sine of n radians the expression would be written A SIN n In this statement we are actually using two functions n and sine BASIC would evaluate this expression by expanding the value of n evaluating the function sine and finally storing the result in the variable space for A In the expression A 2 SIN n after the sine is computed it is multiplied by ...

Страница 33: ...positive number There is no inherent accuracy loss For example PAINT ASS 145 INT This expression basically rounds the current value of the parameter to the next lowest integer For example INT 23 0 INT 2 5 3 INT 1 79 1 Other than the inherent inaccuracy of dropping significant digits this expression introduces no additional inaccuracy However small inaccuracies in the argument could cause problems ...

Страница 34: ...parameter is passed as a seed to the random number generation sequence This technique can be used in debugging programs in a sense that a predictable repeatable sequence can be obtained by RND minus tor program development Suppose in a game program you want to simulate rolling a six headed die Initially you can see the random number generator with the instruction D RND TI Subsequently you can comp...

Страница 35: ...that they can be efficiently allocated Several functions exist to aid in formatting data when it is printed on the screen or hardcopy printer TAB This format function places the cursor at the column specified in the argument The argument goes through the INT routine The legal range is I X 255 If the cursor is past the location specified the tab is ignored Note TAB uses skip characters not spaces p...

Страница 36: ...e linear program as before 10 PRINT 1 1 1 20 PRINT 2 2 2 SQR 2 30 PRINT 3 3 3 SQR 3 The big disadvantage of this is that we would have to keep typing in lines until the 20th line 200 PRINT 20 20 20 SQR 20 UNCONDITiONAL LOOPING However with our concepts of variables and the addition of a lOOP we can write a program that computes values and prints them out without having to type such a long program ...

Страница 37: ...the case is true the statement after the TH EN is executed A test is specified by putting one of six relational operators between two expressions equal not equal greater than less than greater than or equal to less than or equal to If A B then print A LESS THAN B If the expression is true the instructions on the same line with the IF statement are executed If the expression is false the program ju...

Страница 38: ...ccess a data base of some sort The program could require only simple data such as YES or NO responses to a game or simulation A more complex payroll program might need rates hours and tax information In PET BASIC there are two ways to get information into variables READ AND DATA STATEMENTS Only a short time ago when there were no timeshare systems BASIC could not accept input other than cards incl...

Страница 39: ...him to reuse the stored data RESTORE restart the DATA search back to the beginning of memory The following program would correctly operate continuously re reading DATA 10 DATA 10 20 30 40 50 60 70 20 1 1 30 READ A PRINT A 401 1 1 50 IF 1 8 THEN 30 60 RESTORE 70 GO TO 20 INPUT When interactive response to DATA requirements became possible the concept of INPUT from the keyboard was introduced Since ...

Страница 40: ...r example 10 INPUT BIRTHDAY A it would print BIRTHDAY and wait for you to input your birthday in standard numeric form to value A Here is an example of IN PUT to calculate the third leg of a right triangle 10 INPUT FIRST LEG A 20 INPUT SECOND LEG B 30IFA OORB OTHEN10 40 THIRD IS SOR A A B BI 50 GOTO 10 If you run this program and put in values 3 and 4 respectively you witt get a 5 We can change ou...

Страница 41: ... will contain the character corresponding to the key that was pressed See the next section for a detailed explanation of how strings work GET calls a routine which examines the keyboard interrupt buffer If the buffer is empty the variable contains a value of null or zero If there are characters the first is taken out of the queue and returned Since the length of queue is 10 characters calling GET ...

Страница 42: ...l characters such as cursor down and carriage return This will be illustrated soon BASIC allows string expressions up to 255 characters long These can be output to the screen or to any output device which accepts more than 79 characters Input however is usually restricted to 79 characters because of the size of the input buffer This problem can be handled by breaking strings into substrings before...

Страница 43: ...n is zero VAL Z o READY On the other hand VAL will convert as many digits as it can up to an invalid character VAL 3 14 AB 3 14 VAL is an excellent function to use with INPUT since it can prevent an inexperienced user from causing a REDO from START CHR We have shown that strings may be assigned printable ASCII characters through either literals or direct INPUT but some devices require control char...

Страница 44: ...rightmost I characters of the string expression When I is less than or equal to zero or greater than 255 an ILLEGAL QUANTITY ERROR is printed There are two expressions for MID The first most general one is MID STRING VARIABLE I J This expression gives J characters from the string starting with the r th character If I is greater than the length of the string then this will give a null string If eit...

Страница 45: ... BS will share the same copy of the string New strtng is required only If a concatenation or INPUT is executed A LARGER EXAMPLE OF STRING FUNCTIONS Using the string functions described thus far we can write a routine which will shuffle a deck of cards for us and deal them out one at a time The following routine has applications In many games like poker or bridge Note use of the PET graphics card s...

Страница 46: ...lowed by a letter or digit Thus the following are valid function names FNX FNJ7 FNKO FNR2 The most severe imitation of user defined functions is that they must be contained in their entirely on one line BD characters String functions cannot be defined The variable in parentheses follOWing the variable name is called a dummy variable A function may be defined to be any expression but it may have on...

Страница 47: ...SQR X X l rr 2 FOR ABS X 1 INVERSE SECANT ARCSEC X DEF FNF X A1N SQR X X 1 SGN X 1 rr 2 FOR ABS X 1 INVERSE COSECANT ARCCSC X DEF FNG X A1N I SQR X X 1 SGN X 1 rr 2 FOR ABS X 1 INVERSE COTANGENT ARCCOT X DEF FNH X A1N X rr 2 FOR ANY X HYPERBOLIC SINE SINH X DEF FNI X EXP X EXfl X 2 FOR ANY X HTPERBOLIC COSINE COSH X DEF FNJ X EXP X EXP X 2 FOR ANY X HYPERBOLIC TANGENT TANH X DEF FN H X EXP X EXP X...

Страница 48: ...ariable function which can be used like any intrinsic function The major limitation of DEF FN is that it can consist of only a single algebraic expression and it must fit on one line Often several lines of code will be repeated through a program These program lines can be collected in one place and executed by a GOSUB command GOSUB 5000 The lines of code are called a subroutine GQSUB means go to t...

Страница 49: ...he physical limitation on the number of GOSUB s in effect at one time Is 23 After this many there is very little stack space left Example of SUbroutines Consider the factorial function n1 1 x 2 x 3 x xn You cannot define this function with the DEF FN command On the other hand you can use the following simple routine to find n for any given n up to 34 NF denotes n factorial 10 INPUT N 100 l l NF l ...

Страница 50: ...lculates the binomial coefficient Merely change line 70 to 70 RETURN The subroutine denoted SUB 10 beginning on line 10 and ending on line 70 has the following structure M G SUB10 R N t NF B BC BC Subroutines that are used by other subroutines are called nested subroutines In this case SUB100 is nested in SUB20 Many programs have subroutines nested in subroutines in nested subroutines The only lim...

Страница 51: ...limit to the variable then exit the loop through a NEXT We have seen how repeated operations can be performed using a counting variable such as I in the routine 10 1 1 20 1 1 1 30IFI 10THENGOT020 In this case any routine appearing in lines 21 29 will be repeated 10 times In addjtion the variable I will have values which range from 1 to 10 in increments of 1 This looping process can be genralized i...

Страница 52: ...hich a FOR loop Is entered but never existed the RETURN will still be able to find the most recent GOSUB entry RETURN eliminates the GOSUB stack entry and all FOR entries made after the GOSUB entry NESTED FOR NEXT LOOPS FOR NEXT loops like subroutines can be nested That is a FOR NEXT lOop may be contained in another and so on When doing so it is important not to use the same counting variable as t...

Страница 53: ...multiplying the number of elements in each dimension 1 by the other subscripts Thus A 9 8 contains 9 1 8 1 elements SUbscripts start at 0 and go up to the maximum value A 0 0 A 0 8 A 9 0 A 9 8 Limits on the number of dimensions and size of a dimenslon are determined by size of memory available and space available on a line following a DIM PET BASIC restrict the total number of array elements to 25...

Страница 54: ...0 1 8 21 1 9 21 1 Our table has 9 rows and 2 columns To access a certain entry position you must specify the row index and column index of where it is contained For example the quantity denoted by a is in row 3 column 1 In order to use such a table in a BASIC program you must provide a statement to describe the number of rows and columns contained in the array variable Such a description is a DIMe...

Страница 55: ... is stored in that variable or return a zero or null if the value has not been previously specified Like vectors subscripted variables have the power to execute a large number of operations using a single notation They are especially useful when combined with FOR NEXT loops as the next example shows Example Dot Product The dot product of two vectors v w is a vector denoted by v w whose ith compone...

Страница 56: ...om 1966 through 1974 GROSS NATIONAL PRODUCTS IN S BILLIONS 66 753 67 796 68 869 69 936 10 982 11 1063 12 1111 13 1307 14 1413 The program listing is READY 10 SPACE 20 FOR 1 1 TO 7 READ A I NEXT 30 FOR i 0 TO 8 R AD V I NEXT 40 PRINT O SPE 8 GROSS NATIONAL PRODUCTQ 50 PRINTSPC 12 IN BILLlONSjQ 100FORI OTOB 110 X V 1 145 Y INT X 120 PRINT R LEFT SPACE Y A S X Y 130Q PRINT C R STR 66 I STR V I Q 140 ...

Страница 57: ... X Y Here B X Y will range over the decimal values 0 through 7 99 9 but A automatically truncates the decimal part DIMENSION STATEMENTS When using more than 10 subscripts for any variable a dimension statement must be given It takes the form DIM A K where K is the largest subscript of A used in the program When variables are redimensioned without a CLR statement or when a dimension statement appea...

Страница 58: ...bles brfore assigning arrays This will optimize execution speed Functions of new and CLR on data pointer CLR String pointer equated to top of memory Data pointer to start of text 1 End of array table to start of variables End of simple variables to start of variables NEW String pointer equated to top of memory Data pointer to start of text 1 End of array table to start of text 3 End of simple vari...

Страница 59: ... 129 131 133 122 144 124 126 128 130 132 g o m x at initialization 000 1024 1025 1028 typical program BASIC statements 1025 c m 3 m o m variables 1092 m c o m arrays 1113 m c o m 1175 8 C strings 8184 o 0 o 3 m 3 o 8192 Figure 6 2 Principal pointers Into PET RAM ...

Страница 60: ...ORY EXPANSION 14 CONNECTOR Figure 7 1 Simplified view of PET showing switch fuse line cord and interfacing connectors FROM PET MAIN LOGIC ASSEMBLY BOARD rrrr_ _nov _IJ upper Insulation C t t 1 2 3 4 5 6 7 8 9 1011 12 onac lac P o lk Lower ABC 0 E F H J K L M N Contact Rear or Edge on View through slots in PET or Pin Figure 7 2 Simplified views of edge connectors J1 and J2 to illustrate contact Ide...

Страница 61: ...r Pins A 13 0105 Data input output line 5 9 0106 Data input output line 6 e 15 0107 Data input output line 7 0 16 0108 Data input output line 8 E 17 REN Remote enable F 18 GNO DAV ground Lower Pins H 19 GNO NAFD ground J 20 GNO NDAC ground K 21 GNO IFC ground L 22 GNO SAO ground M 23 GNO ATN ground N 2 GNO Data ground 0101 8 Table 7 3 PET contact Identification characters IEEE 488 Identification c...

Страница 62: ...ls and their descriptions Note that the connections 1 12 the top line of contacts see Figure 7 6 are primarily intended for use by the PET service department or qualified dealers When using the incorporated ROM diagnostic a special connector is used this jumpers some of the top contacts to the bottom contacts It is strongly advised that the top connectors 1 12 be used only with extreme caution Pin...

Страница 63: ...F PA3 ently of each other for input or output H PA4 J PA5 K PA6 L PA7 M CS2 SpeciallfO pin of VIA N GND Digital ground VERSATILE INTERFACE ADAPTER The lines on the bottom side of the user port connector originate from a Versatile Interface Adapter VIA MOS Technology part 6522 The signals CA1 PAO 7 and CB2 are directly connected to a standard 6522 VIA located at hexadecimal address E840 Decimal add...

Страница 64: ...o low order byte of Timer 2 but do not reset interrupt 59465 E849 1001 Access high order byte of Timer 2 reset Counter interrupt on write 59466 E84A 1010 Serial I O Shift register 59467 E84B 1011 Auxiliary Control register 59468 E84C 1100 Peripheral Control register 59469 E84D 1101 Interrupt Flag register lFRl 59470 E84E 1110 Interrupt Enable register 59471 E84F 1111 Output register for I O Port A...

Страница 65: ...ation characters labels and descriptions Table 7 11 shows some typical receptacles that are suitable for the second cassette connector FROM PET MAIN LOGIC ASSEMBLY BOARD Top View Upper Contact Insulation 6 or Pin 12345 F I 5 Lower ABC D E F Contact or Pin Rear or Edge on View th ugh slot in PET Figure 7 9 Simplified view 01 edge connector J3 with contact Identlllcation Note A 1 B 2 etc imply a pin...

Страница 66: ...m InsulatiO SIDE B Upper o f 1 2 3 4 5 6 33 34 35 36 37 38 39 40 SIDE A Rear or Edge on View through slot in PET Figure 7 12 Simplified view of edge connector J4 with contact Identification All side B contacts grounded Table 7 13 shows the PET pin numbers line labels and fine descriptions Side A Line Line Description Pin Numbers Labels Al BA0 Address bit rJ used for memory expansioll Buffered A2 B...

Страница 67: ...FF A20 I SEL 5 4K byte page address select for memory locations 5GIJ0 5FFF A21 SEL 6 4K byte page address select for memory locations 6IJIJ0 6FFF A22 SEL 7 4K byte page address select for memory locations 7000 7FFF A23 I SEL 9 4K byte page address select for memory locations 90IJ0 9FFF A24 I SEL A 4K byte page address select for memory I locations A000 AFFF A25 SEL B 4K byte page address select fo...

Страница 68: ...le when using the OPEN command in the form of the statement OPEN LF D S FN LOGICAL FILES Files are used to store and retrieve data as for example in the case of a magnetic tape or disc file A convenient extension of this idea is to regard any device which can receive and or generate data as a logical file To the PET operating system data might just as well have come from or be going to a storage s...

Страница 69: ...PET and a particular device to communicate using the parallel IEEE 488 bus On many IEEE devices the allocation of the device number is made by means of a switCh or in the case of less expensive products by the connection of jumpers Operation Normal printing Printing under format statement control Transfer data from PET to format statement Set variable lines per page Use expanded diagnostic message...

Страница 70: ...e all three buttons if any of the three is pushed the PET will think that you pushed the PLAY button and will respond accordingly Because of the type of mechanism used in the tape unit the user must rewind fast forward stop load and eject tapes He must also put the unit into the write mode by pushing the record button either simultaneously with or before the PLAY button is pressed The PET has tota...

Страница 71: ...26 for cassette 2 The tape file header is written into the buffer first and then written on tape Data files are accumulated in the tape buffer until 192 characters are exceeded then the contents are either written on tape for write or if the program is reading tape the next block of data is read into the buffer Tape file headers and all data blocks are therefore 192 characters long Tape buffers ar...

Страница 72: ... to know about the file b Read data from or write data to the logical files c Close the file allow the PET to clear up the device and terminate the active file These steps are discussed in detail on the following pages OPENING FILES In order to tell BASIC about the file you want to operate on it is first necessary to open the file This is done by the following statement OPEN logical file device se...

Страница 73: ...then OPEN 12 4 1 is interpreted as Parameter LF Logical file 12 has been opened D Logical file 12 has been assigned to device 4 SA Printer has been instructed to print under format statement control FN File name not applicable Note The PET has a special system with OPEN for tape files The opening of the tape is automatic but the tape header may not always be written at the beginning of the tape bu...

Страница 74: ...a does not get loaded into memory but instead gets compared with memory If either first or second pass errors occur the PET will type out VERIFY ERROR which means that the program should be saved again before it is lost On VERIFY the status word has the following meanings Code Meaning 4 Short block 8 Long block 16 Checksum error on tape 32 Checksum ERROR on tape SAVE SAVE also performs an automati...

Страница 75: ... write on tape The initial block shows that there are two ways of opening the file a OPEN for write data tape b SAVE write a program tape Note that if the tape file is opened directly from the keyboard then the message WRITING NAME is displayed If the file is opened under program control and the PLAY and RECORD buttons are depressed previously then no message appears on the screen In this manner a...

Страница 76: ... lIge No PLAY y and RECORD PRESS PLAY Buttons Down AND RECORD Wait for Switch Closure Program Direct or Program Operation Direct Message WRITING NAME Header Goes to Tape 0 Figure 7 15 OPEN for write from PET PRINT CMD or SAVE OP operating system takes over 73 ...

Страница 77: ...ration Program Read in Full Program to Memory Message LOADING NAME No Fill Header Found Direct or Program Operation Direct or Program Operation Program Direct Message FOUND NAME Direct Initialize BASIC Variables y No End of Tape File Not Found Error No Correct Name LOAD Figure 7 16 OPEN lor read to PET INPUT or LOAD OP Operating system takes over B BASIC takes over 74 ...

Страница 78: ...on a tape file named VECTOR and we assume that the PLAY button has just been depressed on the tape unit 1 Then the following program will read the 50 numbers one at a time and display them on the video screen 10 OPEN 1 1 0 VECTOA Open logical file 1 Assign file to cassette 1 Open tape for read Look for physical fite named VECTOR Read 50 numbers at one time from cassette 1 GET CHARACTER TRANSFERS N...

Страница 79: ...word and will continue to return carriage returns until the command it has been currently operating under has been terminated At the end of the command BASIC calls a termination subroutine which reinitializes the device to the keyboard and sends an untalk to the IEEE 488 bus thereby freeing the bus for the next command INPUT BUFFER LIMITATIONS Although data is transferred from the operating system...

Страница 80: ...ssed Note Although both the INPUT AND PRINT commands operate in virtually the same way as their equivalent INPUT and PRINT statements do in BAS C the abbreviated command which can be used in place of PRINT does not apply to PRINT and PRINT are recognized and reduced to two different token characters when processed by BAS C will oak like PRINT when listed but gives SYNTAX ERROR when an attempt is m...

Страница 81: ...ne which initializes an IEEE 488device for output The first step in the command is that the PET reassigns its normal output from the screen device to the physical device that was chosen forthe logical file in the open routine A listen command is sent on the IEEE bus to the physical device and a secondary addressd specified for that logical file in the OPEN BASIC then hands one character at a time ...

Страница 82: ...sc files must be closed before the program ends The following should be kept in mind a If the total number of logical files currently exceeds ten then loss of PET operation will result b If a logical file assigned to a tape unit is not closed no end of file mark will be recorded at the end of the physical tape file If this tape is then loaded into memory the PET will have no way of knowing the fil...

Страница 83: ...ecific meaning for the individual I O device Table 7 17 shows the errors as a function of the ST word value for the tape cassette units IEEE read write operations tape verify and load operations ST ST Cassette Tape Bit Numeric R IEEE AM Verify Position Value Load 0 1 Time out on write 1 2 Time out on read 2 4 Short block Short block 3 8 long block long block 1 4 16 Unrecoverable Aoy read error mis...

Страница 84: ...red in the same place in both blocks 4 CHECKSUM ERROR 32 After a LOAD or reading of data a checksum is computed over the bytes in RAM and compared to a byte received from the input device If they do not match this bit is set 5 END OF FILE 64 This bit is set when the end of data file mark is encountered in a tape record 6 END OF TAPE 128 An EOT record was read EXAMPLES OF ST USE As you can see ther...

Страница 85: ...ed Secondary SA jI On tape files open for read address On IEEE 488 devices no secondary address is sent Table 7 18 Default values Equivalent Statement Default Operation Parameter Values OPEN 1 OPEN 1 1 0 Open logical file 1 for cassette 1 read no file name OPEN 1 2 OPENit l 2 0 Open logical file 1 for cassette 2 read no file name OPEN 1 2 1 OPEN 1 2 1 Open logical file 1 for cassette 2 write no fi...

Страница 86: ... 5 B 0106 14 Data INPUT OUTPUT L1NE tffi C 0107 15 Data INPUT OUTPUT LINE 7 D 0108 16 Data INPUT OUTPUT L1NE t8 E MANAGER REN 17 Remote enable REN always ground in the PET F GROUNDS GNOG 18 OAV ground H GN07 19 NFRO ground J GN08 20 NOAC ground K GN09 21 IFC ground L GN010 22 SRO ground M GN011 23 A N ground N LOGIC GNO 24 Data ground 0101 81 Table 7 20 IEEE bus group label and contact Identificat...

Страница 87: ...is valid data on the data bus c That the data has been accepted by all listeners The transfer of data occurs at a rate determined by the slowest active device on the bus this allows the interconnection of devices which handle data at different speeds The sequence of events that occur during the transfer of a data byte from the talker to the listeners is shown in the flow diagram of figure 7 21 Not...

Страница 88: ...Ready V for Data Is the Data is Data Valid Valid DAV_Low No Data Byte Accepted NRFD _ Low Not ready for Data NDAC NDAC_ High Data Accepted High Data Not Valid V Further 6 Data Not D Accepted V Figure 7 22 Sequence of events during a data byte transfer from the talker to the listners Broken lines indicate the testing 01 transfer bus signal logic levels 85 ...

Страница 89: ...a they release NFRD This terminates the sequence for the first data transfer The sequence will repeat again beginning at a until all required data transfers have been completed PET IEEE Bus Timing Constraints The following limitations should be noted in order to avoid a loss of data a When PET is a listener it expects DAV to go low within 64 milliseconds after it has set NFRD high b When PET is a ...

Страница 90: ...te of data is Identify being transferred the talker has the option of setting EOI low The PET always sets EOI low while the last data byte is being transferred from the PET Manager Fe Interface The PET sends its internal reo Clear set signal aslFC low true to initialize all devices to the idle state When PET is switched on or reset IFC goes low for about 100 milliseconds Transfer NDAC Data Not Thi...

Страница 91: ...ve data out on valid signal DAV low within the 65 millisecond talker time out interval 64 End or EOI has gone low truel on the last byte of data identify being transferred on IEEE bus Note that all devices EOI do not generate an EOI signal Consult relevant instrument manual 128 Device Device did not respond when addressed this gen 001 erates an error message and the operating system present returF...

Страница 92: ...8 UJ H w X UJ h z z z z 5 u x u J J J 1 0 0 1 9 HT TCT EM SPD U 9 iii I iii iii I W Y UJ 0 0_ 1 0 1 0 10 LF SUB U f U Z f J J J z J 0 VT ESC i z I z 1 1 1 11 K f k z 1 1 0 0 12 FF FS 2 2 L 2 f I w 1 1 0 1 13 CR GS I M I I J m I 1 1 1 0 14 SO RS N n J J 1 1 1 15 SI US _0 _ 0 DEL 1 1 0 1 f I I I I ADDRESSED UNIVERSAL LISTEN TALK COMMAND COMMAND ADDRESS ADDRESS GROUP GROUP GROUP GROUP IACG UCG LAG TA...

Страница 93: ... the program is to do and how to implement it is left to the programmer and the programming manual 6502 To locate the code you must decide whether you have a small program that is to be used only temporaril or whether it is a program you want to have operational throughput the entire time the BASIC program is operating in the machine To understand how best to keep the program in memory we should r...

Страница 94: ...ction BASIC will then start interpreting the next statement after the SYS command In order to pass the variables of data back and forth between the user program and BASIC using the SYS command data has to be POKEd into temporarily undisturbed memory locations during the execution of the BASIC routine The results of the SYS operation would have to be PEEKed back into the program that follows the ca...

Страница 95: ...igned 8 bit binary 80 Negative exponents are not stored 2 s complement Maximum exponent is 1038 Minimum exponent is 10 39 which is stored as 00 A zero exponent is used to flag the number as zero Exponent Approximate Value FF 10 A2 1010 7F 10 1 02 10 38 00 10 39 Since the exponent is really a power of 2 it should best be described as the number of left shifts EXP 80 or right shifts EXP 80 to be per...

Страница 96: ...sure the number will be In this format we can use that bit to indicate the sign of the mantissa thus freeing the byte used for sign The sixth byte is used in the floating accumulator to simplify operations when shifting the mantissa The contents of the floating accumulator may be converted to a double byte integer by calling a subroutine FLPINT which is located at DOA7 The most significant byte of...

Страница 97: ...tines In all cases the use of the machine language program is only for the more sophisticated BASIC user The protection of the ROM fail safe coding is lost Machine language programs should only be used when BASIC is neither fast enough nor the function which is desired is implemented MACHINE LANGUAGE MONITOR TIM is the Terminal Interface Monitor program for MOS Technology s 65XX microprocessors It...

Страница 98: ...y example above The semicolon tells the monitor you are modifying registers G BEGIN EXECUTION G C38B The GO command may have an optional address for the target If none is specified the PC from the R command is taken as the target X EXIT TO BASIC X READY Causes a warm start of BASIC In a warm start memory is not altered in any way and BASIC resumes operation the way it was before a monitor was made...

Страница 99: ...d for in the PET The processor line corresponding to this interrupt is permanently pulled UP REST vectors to a cold start of BASIC Memory is cleared Reload and re enter TIM via SYS command TIM MONITORS CALLS AND SPECIAL LOCATIONS JSR WRT FF02 type a character JSR ROT FFCF input a character JSR GET FFE4 Get a character JSR CRLF 04F2 type a CR JSR SPACE 063A type a space JSR WROB 0613 type a byte JS...

Страница 100: ...gram called CHSET because it prints the ASCII 64 character set on the terminal The M command is used to display memory locations on the PET screen and it is then possible to use the screen edit on each line and type RETURN to alter memory 33A CRLF 4F2 WRT FFD2 33A 20 F2 04 CHSET JSR CRLF 33D A2 20 LDX 20 33F 8A LOOP TXA 340 20 D2 FF JSR WRT 343 E8 INX 344 EO 60 CPX 60 346 DO F7 BNE LOOP 348 00 BRK...

Страница 101: ... 0000 4C 3A 03 10 Exit from the monitor and re enter BASIC x READY 11 Prove that the linkage is established by using both SYS and USR A USR OI SYS 3 256 3 16 10 Enter these as direct commands 99 ...

Страница 102: ...88 888A 8888 8888 88eE 888F 88 I I 8813 8815 88 I 7 8819 881 A 8810 881C 881D 88 I E 881F 8828 8821 8822 8823 8823 8823 8833 8488 8488 8481 8482 8483 8484 8485 8486 848C 848D 848E 88 80 84 8A 88 9E 28 31 88 88 88 YARTA8 7C TXTPT CA NC DS B UPL1 191 RDT FFCF WRT FFD2 CBINY 102IB WARA IC3BB FA SF I FNLEN fEE FNADR SF9 STAL F STA HO EAI E5 EAH fE6 ZERO PAGE AONTTOR RESERYE AREA eA WRAP 1 ADDRESS WRAP...

Страница 103: ... 8431 os 1D STA KR AHD K 8874 0433 68 PLA 8875 8434 OS 1C SIA ACC iAH I ACCUMULATOR 8976 8436 60 PLA 8877 0437 85 18 SIA FLGS AND FLAGS 8878 8439 60 93 PL A 8979 843A 69 H ADC I FF CY SE I 10 PC l FOR BREAK 8980 843C OS 19 SIA PCL 8881 843E 68 PL A 8982 843F 69 FF ADC UH 08B 3 8441 85 lA STA PCH 8884 8443 OA TSK 0885 8444 86 1F STX SP SAVE ORI GI NAL SP 88B6 0446 58 Cll CLE AR IHTS 0087 8447 20 F2...

Страница 104: ...R 10 ALTER POSITION VR N BYTES TKP i ADR READ COHHAND CHARACIER I S RETURNED IH A IGNORE PRONPIING SIA I PC lD Y 10 JSR SPACE LDA HIP8 JSR WROB 102 OH DNI A6 20 EB 82 F8 84 E8 B3 08 B6 28 3A 86 20 37 06 20 98 86 85 21 A8 80 28 3A 86 BI 1 1 2B 13 86 C9 2E F 0 F9 C9 20 F0 F5 A2 07 00 82 05 00 0F AS 28 85 8E 86 20 BD 8A 85 48 BD 12 85 48 60 CA 18 E9 A9 3F 20 02 FF 4C 57 04 38 AS 13 E5 I 1 85 8B AS 14...

Страница 105: ...PLA ERROR CLEAR JSR ADR IN STA 8174 84DD 68 PLA 8175 84DE 4C 98 84 JMP ERROPR 8176 84E I 28 F7 04 8Y3 JSR INcap GO IHC T P9 ADR 0177 04E4 C6 21 DEC RCHT 8178 84E6 60 RTS 8179 84 7 A9 18 SETR LDA IFLGS SET TO ACCESS REGS 0180 84 9 85 11 STA THP0 8181 84 E8 A9 80 LDA 10 8182 04 D 85 12 STA THP0 1 0183 04EF A9 05 LOA 15 8184 84F I 60 RTS 8185 04F2 A9 0D CRlF LOA UO 0186 04F4 4C D2 FF JHP WRT 8187 84F...

Страница 106: ... 4C 8YTE L 828S 8589 S3 8YTE S 8286 858A 85 ADRH S tT 221 8287 8588 8S 8n 222 8288 858C 8S 8n 223 8289 8S8D 8S 8YT 224 8218 8S8E 8S 8YT 22S 8211 8S8F 85 8YT 226 8212 8518 86 8n 227 8213 8511 86 8n 228 8214 8S12 Cl ADRL 8YT 221 8215 8S13 81 8YT 222 8216 8S14 2C 8YT 223 8217 8S1S SE 8YT 224 8218 8S16 D7 8YT 22S 8219 8S17 FIl 8YT 226 8228 8S18 9E 8YT 227 8221 8519 9E 8YT 228 104 ...

Страница 107: ...248 8567 20 3F 06 JSR T2T2 SA TO T P2 8249 856A 20 90 06 JSR RDOC SKIP DELI ITER 0250 856D 28 4F 06 JSR RDOA READ EHD ADR 8251 8570 90 3D 8CC ERRS 1 ERR IF HO E A 8252 8572 20 3F 06 JSR T2T2 SA TO T PO EO TO T P2 8253 8575 AO eo LOV 10 8254 8577 B9 4A 07 COLH LOA HDR V 8255 857A 3B 06 8 1 COL H2 8256 857C 20 02 FF JSR WRY 0257 057F C8 IHV 025B 8588 08 F5 BHE COL H 0259 8582 29 7F COLH2 AHD H7F 826...

Страница 108: ...SI 8299 85D8 28 CF FF GO JSR ROT 8388 85D8 C9 8D CHP 1 8D IF CR EXIT 83BI 85H FB 8C BEQ GI 8382 8SDF C9 28 C P 1 28 I F HOT SPACE ERR 8383 85EI D8 CC BHE ERRSI 8384 85 1 28 4F 86 JSR RDOA 8385 85E6 98 83 8CC GI 8386 85E8 28 B2 84 JSR PII TP 8387 85 8 A6 IF GI LDX SP 8388 85 D 9A as ORIG DR HEW SP VALUE TO SP 8389 85E AS IA LDA PCH 8318 85F8 48 PHA 83 II 85FI A5 19 LDA peL 8312 85F 3 48 PHA 8313 85...

Страница 109: ...86 ADC 6 8358 862E 69 F8 ADC tH8 8359 86H 98 82 BCC ASC 8368 8632 69 86 ADC 86 8361 8634 69 3A ASCI ADC 3A 8362 8636 68 RIS 8363 8637 28 3A 86 SPAC2 JSR SPACE 8364 863A A9 28 SPACE LDA 28 8365 863C 4C D2 FF JMP URT TYPE SP 8366 863F A2 82 T2T2 LDX 12 8367 8641 85 18 T2T21 LDA TMP8 1 X 8368 8643 48 PHA 8369 8644 85 12 LDA TMP2 1 X 8378 9546 95 18 STA T P0 1 X 8371 8648 68 PL A 8372 8649 95 12 STA T...

Страница 110: ...I 8412 8684 68 RTS 8413 8685 C9 3A HE IT CNP 1S3A 8414 8687 88 PHP S YE FLAGS 8415 8688 29 8F AHD 1S8F 8416 868A 28 PLP 8417 8688 98 82 8CC HE 89 8 9 8418 8680 69 88 ADC 8 ALPHA ADD 8 CY 9 8419 86eF 68 HH89 RTS 8428 8698 28 CF FF RDOC JSR ROT READ CHAR 8421 8693 C9 80 CHP 1S8D i 1S IT A CR 8422 8695 08 F8 8NE NE 89 i NO RTS 8423 8697 68 PLA 8424 8698 68 PLA i YES CLEAN STACK E IT 8425 8699 4C 57 8...

Страница 111: ...5 LDI58 JSR FAH 846B 8CFC F8 Fe BED LDl28 8469 86FE 28 4D F6 LD 178 JSR LDAD2 8478 8781 28 22 F4 JSR LD4e8 8471 8784 28 BA Fe JSR TRD 8472 ere 28 13 F9 JSR TWAIT 8473 8 8R AD 8C 82 LDA SATUS 8474 870D 29 18 AND ISPERR 8475 878F D8 E5 BHE LD128 8476 87 11 4C 57 84 JMP START 8477 8714 28 4F 86 L4 JSR HIOti RD STORE BEGIN G ADR 8478 8717 AS 11 LDA THP 8 8479 8719 85 F7 STA STAL 8488 871B A5 12 LDA TM...

Страница 112: ...76B SV lD 8S8S 876B ZZZ H667 8S06 876B CSTE I F838 8SB7 876B lO3BB F3FF BSBB 876B SPERR 16 8S89 8 69 SATUS 20C 8SI0 076B TWAI T F913 8SII 876B TRD F88A 8S12 876B L0408 F422 8S13 876B lOA02 F64D 8S14 876B FAH HSAE 8SIS 876B SAH H681 8S16 876B VERCK 28B 8S17 876B FAF H4 9S 8S1 S 876B ZZI ALTH I 8S19 876B Z22 ALTR l 8S28 876B Z23 OSPlYR I 8S21 876B 2Z4 OSPlY 876B Z25 GO I 876B 226 EXIT l 8S24 876B Z2...

Страница 113: ... 869F LOll 860D LDIl8 86F6 lDlS8 86F9 lO178 86FE LOl 8604 LD388 F3FF lD488 F422 lDAD2 F64D HCMDS 8888 PCH ee 1A PCl 8819 PREYC 888E PUTP 84B2 RCHT B821 RD2 86B8 ROEXIT 865D RDOA 864F RDOA2 8656 RDOB 86SE ROO8l 8665 RDOBl 86 2 RDOB3 867E RDOC 869B ROT FF CF REGK 851 A S8 848l SI 8484 S2 8498 SATUS 8l8C SAH F6BI SAY X BBlB SETR B4 E7 SETWR 8S8 I SP BBIF SPACl 8637 SPACE 863A SPERR 8811 Sre 8471 STI ...

Страница 114: ...o continue to complain about an error until you give it a problem it understands Sometimes the error is not as easy to undestand although in almost all cases while executing a problem if an error is encountered the line number will be indicated Sometimes a problem is the result of a programming mistake that you have made in a previous computation For instance if you get a divide by zero in line 75...

Страница 115: ...m by zero Zero as a divisor would result in numeric overflow thus it is not allowed When this message appears it is most expedient to list the statement and look for division operators DIVISION BY ZERO ERROR IN 10 LIST 10 lOA BIC C o Formula too complex This message concerns only string expressions when BASIC runS out of string temporary pointers to keep track of substrings in evaluating a string ...

Страница 116: ... but all of the data statements in the program have been read The program tried to read too much data or insufficient OUT OF DATA A READ statement was executed but all of the data statements in the program have been nt data was included in the program Carriage OUT OF DATA A READ statement was executed but all of the data statements in the program have been read The program tried to read too much d...

Страница 117: ...ic printed when data in response to INPUT is alpha when a numeric quantity is required 10 INPUT A RUN ABC REDO FROM START INPUT continues to function until acceptable data has been received The complement to this diagnostic on files is BAD DATA ERROR which is fatal When not enough data has been typed in response to INPUT a double is printed until enough data is received 10 INPUT A B C RUN 1 2 3 RE...

Страница 118: ...time out May happen on OPEN CLOSE CMD INPUT GET PRINT OPEN 5 4 3 FILE DEVICE NOT PRESENT ERROR READY FILE NOT FOUND The named files specified in OPEN or LOAD was not found on the device specified In the case of tape 1 0 an end of tape mark was encountered In disk 110 the disk timed out when attempting to open the file thus producing this message LOAD FILE 15 FILE NOT FOUND ERROR READY FILE NOT OPE...

Страница 119: ...rs when an attempt is made to read on output file 10 OPEN 1 1 1 20 INPUT 1 A NOT INPUT FILE ERROR READY NOT OUTPUT FILE Tape files cannot be read and updated in place Device 0 is the keyboard and it cannot be written to 10 OPEN 1 0 20 PRINT 1 NOT OUTPUT FILE ERROR READY VEAIFY The contents of memory and a specified file do not compare NOTES 118 ...

Страница 120: ...mory 1 K 9000 Expansion ROM SAOCO Expansion ROM 8000 Expansion ROM SCOOO BASIC principally statement interpreter 0000 BASIC principally math package SEOOO Screen editor SE800 All internal PET I O FOOO as diagnostics see expanded description Block 0 By 256 Byte Pages START PAGE TYPE ADDRESS FUNCTION 0 RAM 0000 BASIC OS working storage 1 RAM 0100 Stack 2 RAM 0200 o S working storage 3 RAM 0300 Casse...

Страница 121: ...buffer 80 bytes General counter for BASIC 00 used as delimater General counter for BASIC Flag to remember dimensioned variables Flag for variable type O numeric 1 string Flag for integer tape Flag to crunch reserved words protects remark Flag which allows subscripts in syntax Flags INPUT or READ Flag sign of TAN Flag to suppress OUTPUT normal suppressed Index to next available descriptor Pointer t...

Страница 122: ...of FAC 1 Counter for of bits fo shift to normalize FAC 1 Floating accumulator 2 Overflow byte for floating argument Duplicate copy of sign of mantissa Pointer to ASCII rep of FAC in conversion routine 10 hi CHRGOT RAM code Gets next character from BASIC text CHRGOT AAM code regets current characters Pointer to source text 10 hi Next random number in storage Pointer to start of line of cursor loc 1...

Страница 123: ...to flip cursor Flag for cursor on off Table of LSB of start addresses of video dislay lines 25 Table of logic addresses Table of primary addresses Table of secondary addresses Index into LA FA SA tables Default input device Default output device Computation of parity on cassette write Count of redundant tape blocks Count down synchronization or cassette write Index next character in out tape buffe...

Страница 124: ...he name of the variable byte 1 byte2 INTEGER FLOATING STRING first chr Second chr 128 128 or 128 first chr second chr orO first chr second chr 128 or128 actual value The last five bytes give the value of a variable or a descriptor to the rest of the data INTEGER 256 HI LO o o o FLOATING actual value in binary floating point STRING chr count LO pointer HI o o L E The simple string variable points t...

Страница 125: ... array descriptors arethe same as simple variables but the next five bytes are special as follows byte 3 byte 4 byte 5 byte 6 byte 7 VECTOR ARRAYS 7 size 1 dim A 0 1 0 size 1 where A 2 for integer 3 for string or 5 for floating By incrementing the search address by the current byte 30f the descriptor each Urne the next array variable is reached Locations 128 and 129contaln the ending address of th...

Страница 126: ...s are assigned much execution time can be lost moving the arrays each time a simple variable is defined The best strategy to followin this case is to assign a value to all known simple variables before assigning arrays This will optimize execution speed Functions of NEWand CLR on data pointer CLR String pointer equated to top of memory data pointerto start of text 1end of array table to start of v...

Страница 127: ...AL POINTERS INTO PET RAM 123 145 125 127 129 131 133 122 144 124 126 126 130 132 at initialization 000 1024 1025 1028 typical program BASIC statements 1025 variables 1092 A a C o arrays 1113 C o 1175 strings 8184 o 0 o 8192 ...

Страница 128: ...STATEMENTS ARE STORED IUne ft I Icompressed BASIC text I 1 1 G EJ end of text is stored as zero link bytes 1024 G 1025 1027 ILine I 1 1029 Icompressed BASIC text I 0 end of statement is flagged 0 by zero byte A 9 ...

Страница 129: ... e g 3 9 becomes 3 4 01 becomes 4 DEF 100 DEF FNA V VIB C B 1 The user can define functions like the built in functions SOR SGN ASS etc through the use of the DEF statement The name of the function is FN followed by any legal variable name for example FNX FNJ7 FNKO FNR2 User furnished functions are restructed to one line A function may be defined to be any expression but may only have one argument...

Страница 130: ...ent was encountered before a DIM statement for A was found in the program it would be as if a DIM A 10 had been executed previous to the execution of line 117 All subscripts start at zero 0 which means that DIM x 100 really allocates 101 matrix elements Terminates program execution without printing a BREAK message See STOP CaNT after an END statement causes execution to resume at the statement aft...

Страница 131: ...ould be executed 9 times Marks the end of a FOR loop If no variable is given matches the most recent FOR loop A single NEXT may be used to match multiple FOR statements Equivalent to NEXT V NEXT W Specification the former way saves 1 byte of BASIC text storage Works like INPUT or INPUT on a single character basis Unlike INPUT though this function scans the keyboard and does not wait for carriage r...

Страница 132: ... be executed and then the GOTO statement will branch to line 350 If the X was 0 or positive BASIC will proceed to execute the lines after line 26 Binary floating point representations of decimal fractions may not alwys be exact sometimes a comparison will fail because of this In this case compare the number to INPUT 3 INPUT V W W2 B 4 a range Request information character by character until carria...

Страница 133: ...numeric or string must be the same as the evaluated expression Branches to the line indicated by the I th number after the GOTO That is If 1 1 THEN GOTO LINE 10 If 1 2 THEN GOTO LINE 20 If I 3 THEN GOTO LINE 30 If I 4 THEN GOTO LINE 40 1f I 0 or I attempts to select a nonexistent line in this case the statement after the ON statement is executed However if I is 255 or 0 an ILLEGAL QUANTITY error m...

Страница 134: ...erminaL If the list of values to be printed out does not end with a comma or a semicolon then a carriage returnlline feed is executed after all the values have been printed Strings enclosed in quotes may also be printed If a semicolon separates two expressions in the list their values are printed nest to each other If a comma appears after an expression in the list then spaces are printed until th...

Страница 135: ...ading blanks you must enclose the string in double quotes It is impossible to have a double quote within string data or a string literaL ANYTHING is illegal Allows the rereading of DATA statements After a RESTORE the next piece of data read will be the first piece listed in the first DATA statement and so on as in a normal READ operation Allows the programmer to put comments in his program REM sta...

Страница 136: ... Execution of the program continues at the statement following the WAIT If the WAIT statement only has two arguments K is assumed to be zero If you are waiting for a bit to become zero there should be a one in the corresponding position of K 0 1 65536 J K must be 0 and 255 The STOP key cannot interrupt a WAIT ...

Страница 137: ... all of the lines in a program with a line number less than or equal to X Lists all of the lines within a program with line numbers equal to or greater than Y and less than or equal to X If LIST is used as a program statement the program will terminate after it is executed Load first program found on cassette 1 into memory Search for named file on cassette 1 and then load it into memory Same as pr...

Страница 138: ...diately after text in memory Deletes current program and all variables Starts execution of the program currently in memory at the lowest numbered statementment RUN deletes all variables like CLR and restores DATA If you have stopped your program and wish to continue execution at some point in the program use a direct GOTO statement to start execution of your program at the desired line Optionally ...

Страница 139: ... AND OPERATORS RELATIONAL OPERATORS equal less than greater than L E G E not equal BOOLEAN OPERATORS AND OR NOT ARITHMETIC OPERATORS I t add subtract multiply divide exponentiation negation STRING OPERATOR 0 1 concatenation ...

Страница 140: ...ay IF X THEN is equivalent to IF X 0 THEN SYMBOL SAMPLE STATEMENT 10 IF A 15 THEN 40 70 IF A 0 THEN 5 30 IF B 100 THEN 8 160 IF B 2 THEN 10 180 IF 100 B CTHEN 10 190 IF Q R TH N 50 PURPOSE USE Expression Equals Expression Expression Does Not Equal Expression Expression Greater Than Expression Expression Less Than Expression Expression Less Than Or Equal To Expression Expression Greater Than Or Equ...

Страница 141: ...d 16 equals binary 10000 the result of the AND is binary 10000 or 16 15 equals binary 1111 and 14 equals binary 1110 so 15 and 14 equals binary 1110 or 14 1 equals binary 1111111111111111 and 8 equals binary 1000 so the result is binary 1000 or 8 decimal 4 equals binary 100 and 2 equals binary 10 so the result is binary 0 because none of the bits in either argument match to give a 1 bit in the res...

Страница 142: ...divide that by 4 we would use 5 3 4 which eqals 2 If instead we had used 5 3 4 we would get 5 75 as a result 5 plus 314 The precedence of operators used in evaluating expressions is as follows in order beginning with the highest precedence Note Operators listed on the same line have the same precedence 1 FORMULAS ENCLOSED IN PARENTHESIS ARE ALWAYS EVALUATED FIRST 2 I EXPONENTATION 3 NEGATION X WHE...

Страница 143: ...ult in a speed improvement 5 A program need not end with an END so an END statement at the end of a program may be deleted 6 Re use the same variables If you have a variable T which is used to hold a temporary result in one part of the program and you need a temporary variable later in your program use it again Or if you are asking the terminal user to give a YESor NO answer to two different quest...

Страница 144: ... symbol table assuming line 5is the first statement executed in the program Later in the program when BASiC finds a reference to the variable A it will search only one entry in the symbol table to find A two entries to find B and three entries to find C etc 4 Use NEXT statements without the index variable NEXT is somewhat faster than NEXT I because no check is made to see if the variable specified...

Страница 145: ...er Molex 7 Pin Header Molex 5 Pin Header Molex TIP 29 2N 4401 2N 3904 1 5K 1 4W 5 10K 1I4W 5 10K 1 4W 5 1K 1 4W 5 470 1 4W 5 2 4K 1 4W 5 5 1K 1 4W 5 1M 1 4W 5 3 3K 1I4W 5 74LS93 Counter 6540 010 MOS Char Gen 2316B 08 Char Gen 6522 VIA Me 3446 Interface Bus 74LS20 Nand Gate 74LS165 Shift Reg 74LS244 Buffer 74LS107 Flip Flop 6520 PIA 74LS74 Flip Flop 74LSOO Nand Gate 6550 RAM F 1 PART NO 9OO01 38 9O...

Страница 146: ...ate 74LS145 6540 011 ROM 2316B 01 ROM 6540 013 ROM 2316B 03 ROM 6540 015 ROM 2316 B 05 ROM 6540 016 ROM 2316B 06 ROM 6540 012 ROM 2316B 02 ROM 6540 014 ROM 2316B 04 ROM 6540 018 ROM 2316B 07 ROM Socket28 PIN Socket 24PI N Socket 40PIN Socket 22PIN F 2 901453 01 901521 03 901521 11 901522 03 901521 02 901523 01 901522 01 901522 02 901435 01 901521 10 901521 05 901521 09 901439 01 901447 01 901439 0...

Страница 147: ... Park Ca 94025 1973 A Guided Tour of Computer Programming In BASIC T Dwyer Houghton Mifflin Co 1973 Programming Time Shared Computer in BASIC Eugene H Barnett Wlley Interscience UC 72 175789 12 00 Programming Language 2 Digital Equipment Corp Maynard MA 01754 101 BASIC Computer Games Software Distribution Center Digital Equipment Corp Maynard MA01754 7 50 What to Do After You Hit Return Peoples Co...

Страница 148: ...hines Limited 3370 Pharmacy Avenue Agincourt Ontario Canada M1W2K4 Commodore Business Machines UK limited 360 Euston Road London NW1 3BL England Commodore Buromaschinen GmbH Frankfurter Strasse 171 175 6078 Neu Isenburg West Germany Cow modore Japan Limited Taisei Denshi Building 8 141kue ChomeAsahi Ku Osaka 535 Japan Commodore Bactronics Hong Kong ltd Watsons Estates Block C 11th floor Hong Kong ...

Отзывы: