+----------------------------------------------------------------+ | | | | | | | | | | | | | | | | | | | | | | | MCODER | | | | | | | | | | | | | | | | SPECTRUM | | | | (C) P.S.S. 1983 | | | | | | | | | | | | 452, Stoney Station Road, | | Coventry | | CV6 5DG | | | | | | | | | | | | | | Telephone: (0203)667556 | +----------------------------------------------------------------+ Why use MCODER ? The simple answer to this question is that machine code programs run much faster than those written in BASIC. In general an improvement of about 50 times can be expected although in some instances the improvement may be up to 900 times faster than in BASIC. Will MCODER work with both 16 & 48K SPECTRUMS ? Yes - you will notice that your cassette contains two versions of MCODER - one for the 16k SPECTRUM and another for the 48K machine They both operate in exactly the same manner although some call addresses do differ. To avoid repeating large chunks of the instruction booklet the call addresses for 48K machine will be found in brackets following the revelant 16K addresses. How is MCODER loaded ? Although MCODER loads in several parts, all the user needs to do is use LOAD "", press enter and the follow the screen prompts as they appear. How do I use MCODER ? MCODER can be used in two ways after it has been loaded: 1) a You can simply write a program in BASIC as you normally would. It is important to remember that a STOP command must be present in the BASIC programm as MCODER will stop compiling at this point. When the program is complete you should run it to make sure that there are no errors. b When you are satisfied with the program in BASIC use the command RAND USR 29000 (60000) to activate the MCODER. Each line will be displayed as it is checked and if any BASIC is found which cannot be compiled then a flashing cursor will show where the problem lies and the program will return to BASIC. If all is well then the first pass of the compiler will be made. after this the program will pause untill a key is pressed (any key will do except SHIFT or BREAK). When the second pass is complete the program will return to BASIC with the message OK. Your program has now successfully compiled. 2) If you already have BASIC programs on tape these too can be compiled. To do this first load MCODER, and then load the program you wish to compile. You can now use MCODER as normal but be aware that you will probably have to make some changes to your original program before it compile properly. How do I run compiled programs ? The compiled code is always stored immediately above RAMTOP which is initially set to 26500 (40000). Consequently the code can be run by a call address ie LET L = RAND USR 26400 (40000). ยท Is it possible to compile more than one program ? Yes. It is possible to 'stack' several programs on top of each other using MCODER. This is done by moving RAMTOP using CLEAR n where n is between 24000 & 29000 (24000 & 59000). If RAMTOP is initially set high then a routine may be entered, compiled, and stored above RAMTOP. If RAMTOP is then lowered using CLEAR n another routine can be inserted between RAMTOP and the bottom of the first routine. Care must be taken to lower RAMTOP sufficiently otherwise the first routine will be partly overwritten. These routines can then be called individually as requested. What error can occur ? It is possible to run out of space at several points in the compiler. The normal area reserved for variable names is about 200 bytes long and too many variables will cause this to be exceeded. If this occurs then the error report will occur at the left hand side out of a LET statement, in a READ statement, or in an INPUT statement. MCODER GALLEYZ If RAMTOP is too high then out of memory report will be given. It is possible to run out of space for the code between STOP and returning to BASIC. The cure is to either move RAMTOP down or to decrease the number of variables. An error will also occur if a STOP command is not included in the BASIC program. Trace facilities Three levels of trace and protection are available: 0) Break disabled except at 'scroll ?' and INPUT. The result is the fastest and smallest code. 1) Break enabled. This result in longer code than does 0) and execution may be up to twise as long. 2) Break enabled plus the line presently being executed displayed in the top right hand corner of the screen. This is clearly a very powerful feature in debugging a program, Its disadvantage is that the code runs at about the same speed as BASIC! The program as supplied is set to operate in option 0) but you may change this as many times as you like during a program by a REM statement which starts REM # 0, REM #1 and REM # 2 corresponding to the three modes above. What commands can MCODER handle ? In the description that follows this is the notation that is used. a represents a single letter. v represents a variable. x,y,z represents numerical expression m,n represents numerical expression that are rounded to the nearest integer. e represents an expression. t represents a string valued expression. s represents a sequence of statements separated by colons : c represents a sequence of colour items, each terminated by commas of semi-colons ;. A colour item has the form of a PAPER, INK, FLASH, BRIGHT, INVERSE or OVER statement. Variable names may consist of upper and lower case letters and numbers. Arbitrary expressions may be used anywhere except in LET statements where they must be enclosed in brackets. Statements. BEEP x,y BORDER m BRIGHT sets brightness of characters sequently printed. n=0 for normal, 1 for bright, 8 for transparrent. Error K if not 0, 1 or 8. CIRCLE x,y,z CLS COPY DATA list Part of the DATA list. Must be in a program. List = (?) list of integers. DIM Z(x) Deletes any array with the name Z and sets up an array Z of numbers. Initialises all the values to 0. Only one array will be accepted by MCODER and this must be called Z. DRAW x,y DRAW x,y,z Draws a line from the current plot position moving x horizontally and y vertically relative to it while turning trough an angle z. x, y, & z may consist of Error B if it runns off the screen. FLASH FOR a=x TO y GOSUB n GO TO n Jumps to line n (or if there is none the first line after that). n must be an integer number. IF x THEN s INK n INPUT The '...' is a sequence of INPUT items, separates as in a PRINT statement by commas, semicolons or apostrophes. An INPUT item can be: (i) Any PRINT item not beginning with a letter. (ii) A variable name or (iii) LINE then a string type variable name The PRINT items and separators in (i) are treated exactly as in PRINT, except that everything is printed in the lower part of the screen. The number input must be an integer. If any character is not -, +, 0-9 is input, a question mark is displayed. The delete key will remove that character input. INVERSE n LET v e LPRINT NEXT a OUT m,n Outputs byte n at port m at the processor level. (Loads the bc register pair with m, the a register with n and does the assembly language instruction: out (c),a). OVER n PAPER n PAUSE n Stops computing and diplays the display tile for n frames (at 50 frames per second or 60 frames per second in North America) or until a key is pressed. 0 <= n <= 65535, else Error B. If n = 0 then pause is not timed but lasts until a key is pressed. PLOT c,m,n Prints an ink spot (subject to OVER and INVERSE at the pixel (m,n); moves the PLOT position. Unless the colour items c specify otherwise, the ink colour at the character position containing the pixel is changed to the current permanent ink colour, and the other (paper colour, flashing and brightness) are left unchanged 0<= n <= 175, else error B. POKE m,n Writes the value n to the byte in store with address m. PRINT The '...' is a sequence of PRINT item separated by commas, , semicolons; or apostrophes ' and they are writen to the display file for output to the television. A semicolon ; between two items has no effect - it is used purely to separate the items. A comma, outputs the command control character, and an apostrophe ' outputs the ENTER character. At the end of the PRINT statement, if it does not end in a semicolon, or comma or apostrophe, an ENTER character is output. A PRINT item can be: (i) empty, i.e. nothing. (ii) numerical expression. First a minus sign is printed if a number is negative. Now let x be modulus of value. If x >= 10^(-5) or x <= 10^13 then it is printed using scientific notation. The mantissa part has up to eight digit (with no trailing zeroes), and the decimal point (absent if only one digit) is after the first. The exponenta part is E , followed by + or -, followed by one or two digits. Otherwise x is printed in ordinary decimal notation with up to eight significant digits, and no trailing zeroes after the decimal point. A decimal point right at the beginning is always followed by a zero, so for instance 03 and 0.3 are printed as such. 0 is printed as a single digit 0. (iii) CHR number. Prints the character whose code is the number given. (iv) AT m,n (v) TAB n (vi) A colour item which takes the form of a PAPER, INK, FLASH, BRIGHT or OVER statement. RANDOMIZE READ v1,v2...vk REM STORE n RETURN STOP The last line which is compiled. Causes a return to BASIC. FUNCTIONS ABS ATTR BIN CODE "char" The ASCII value of the character. CODE INKEY$ Reads the keyboard and returns the characted code of the key pressed. IN number INT number PEEK POINT RND SGN SQR USR How do I save comiled code ? This is done by using the normal save routine of the SPECTRUM ie SAVE "name" CODE n where n is the start address of the compiled code. Notice, however, that MCODER must also be saved as it contains several run time routines which the compiled code needs to run properly. The compiler stretches from 28990 to 32590 (59990 to 63500), thus the full save commands should be SAVE "name" CODE 26500,6000 (SAVE "name" 40000,23500). As an example of MCODERS speed 1 Load MCODER 2 Type in the following program: 10 FOR A = 1 TO 50 20 FOR B = 1 TO 50 25 PLOT A,B 30 NEXT B 40 NEXT A 50 STOP 3 Compile the program usign RAND USR 29000 (60000) 4 Run the compiled code using LET L = 26500 (40000)