MLASS V1.0 INTRODUCTION When I first started writing in machine language I bought The Second Book of Machine Language which included the assembler program LADS. I was very impressed with the program and used it for all of my ML projects. However, there was several things about LADS that I did not like, especially the lack of user friendliness. So I set out to write my own assembler that would also compile the source files I had all ready written for LADS. Not only will MLASS compile source files written for LADS but I have added as many features as possible to make this one of the best assembler programs available in the public domain. The features include... * Menu driven * Disk or RAM based assembly * Allows chaining of files when compiling from disk * Option to create BASIC link programs WRITING SOURCE FILES Writing source files for MLASS is very easy since you use the 64's built in BASIC editor, a seperate editor program is not needed. To write a source file simply turn on the computer and pretend you are writing a BASIC program. The following is a sample program that prints a message to the screen. 100 *= 49152 110 .O 120 PRINT = $FFD2 ;KERNAL ROUTINE THAT PRINTS A CHARACTER 130 : LDY #0 ;INITIALIZE THE INDEX 140 LOOP LDA MESSAGE,Y ;GET A CHARACTER 150 : BEQ END ;IF ZERO THEN END OF MESSAGE 160 : JSR PRINT ;PRINT THE CHARACTER 170 : INY ;INCREMENT THE INDEX 180 : JMP LOOP ;GO BACK FOR THE NEXT CHARACTER 190 END RTS 200 MESSAGE .BYTE "This is the message":.BYTE 0 210 .END The first line tells the assembler that the program will begin at memory location 49152. If you want to move the program to a different place in memory just change the address and re-compile it. The characters in lines 110, 200, and 210 which are preceded with a . (period) are not part part of the program but commands for MLASS. A full list of the commands is given below. Line 120 is an EQUATE. Equates specify memory locations outside the program. There is a major advantage to this instead of JSR $FFD2 and that is the ability to transport the program to another computer. If you were to modify a program to run on the 128 you would not have to go through the program and change every machine specific address. Instead you only have to change the equate and re-compile the program. I would like to point out here that all though equates are excepted anywhere in the source code, equates that specify locations on zero page MUST be defined before they are referenced. It is a good idea, and a good programming practice, to put ALL equates at the beginning of the source file. Program type lables such as LOOP (line 140), END (line 190) and MESSAGE (line 200) are used as targets inside the program. NEVER use a line number as a target, only lables. The lable in line 200 is used the same way you would use a variable in a BASIC program. Example, you define a variable with a lable and the .BYTE statement like... VARIABLE .BYTE 0 When you want to change the value just STA VARIABLE. To get the value simply LDA VARIABLE. You can also define strings like the one above using quotation marks. Cursor controls, color codes, and any other printable characters can be entered in quotation marks just like the BASIC print command. The ; (semi-colon) is used to add remarks to the file the same way you would use the REM statement in a BASIC program. Anything following a semi-colon is ignored by the assembler. The : (colon) is used two ways with MLASS. It can seperate intructions just like in BASIC such as LDA #25:STA 828. This allows you to put multiple instructions on a line of sorce code. You can also use the colon as the first character in a line so you can add spaces between the line number and the instruction. This makes the files much easier to read and edit. *NOTE* The added spaces between the line numbers and the instructions and between the instructions and the remarks are not compatible with LADS. I have added this ability to MLASS so source files can be written in a more ledgible manner. COMMANDS The following is a list of the commands available and intructions on how to use them. Numbers can be in decimal or hex. All hex numbers MUST be preceded with a $ (dollar sign). *= ADDRESS - This indicates where in memory the program is to begin. It MUST be the first line in a source file. There cannot be a space between the * and the = signs and there must be a space between the = and the address. .O - This tells the MLASS that the object code is to be poked into memory during assembly. .NO - Turns off pokes to memory. Pokes may be turned on or off at any time. .S - This tells MLASS to output the source code to the screen during assembly. .NS - Turns off screen output. Screen output may be turned on or off at any time. .P - This tells MLASS to output the source code to the printer during assembly. .NP - Turns off output to the printer. Printer output may be turned on or off at any time. *NOTE* MLASS is a two pass assembler. Output to all devices, including the screen, will occur on the second pass. .BYTE - This allows you to add tables of numbers and strings to your program. When using numbers like, .BYTE 1 23 187, there must be a space between each of the numbers and the values must be in the range of 0-255. Numbers may be decimal or hexidecimal (hex numbers must be preceded with a $ sign). When using the .BYTE statement for strings, as in the sample program, be sure to add the closing quotation mark. If the second quote mark is left out MLASS will think the entire line is a string, including the second .BYTE command. .D FILENAME - This tells MLASS to output the object code to a disk file with the name FILENAME. DO NOT use quotation marks around the file name. Disk output cannot be turned off. .FILE FILENAME - This command is used to link source files when compiling from disk. This command may not be used when using the RAM based assembly. .END FILENAME - This tells MLASS that this is the end of the source code. When using the RAM based assembly the file name is not needed. To chain files together during disk assembly each file uses the .FILE command to link the next file in the chain. The last file uses the .END command and must point to the first file in the chain. Example: Your program contains three different source files and they are called ONE, TWO, and THREE. The first file, ONE, will end with .FILE TWO. File TWO will end with .FILE THREE. The last file, THREE, will end with .END ONE. This creates a loop in the chain. You cannot chain files when using the RAM based assembly. The source code must be one file and end with the .END command. When compiling a single file on disk the .END command must have the files own name. (i.e. a file called TEST must end with .END TEST) There are two other commands used by LADS that are not available with MLASS. They are the .H and .NH commands. They switch between decimal and hex numbers for the screen and printer outputs. All output with MLASS is in hex. These commands are recognized but not implemented by MLASS. The last two commands work with arguments. The first one is the Addition command and it works like this, LDA LABLE+1. This adds 1 to the value of the lable. Example, 200 LABLE .BYTE 0 10 280 19 If you LDA LABLE you get the first number, 0. To get the third number, 280, you would LDA LABEL+2. Do not use any spaces before of after the + sign. You can also get the LSB and MSB of a lable with the #< and #> commands. If you wanted to put the address of the above label into a vector you would do it like this, 100 VECTOR = 251 110 LDA #LABLE ; Get the most significant byte of the lable 140 STA VECTOR+1 ; Store the number at 252 Again, do not use any spaces between the symbols and the argument. In fact NEVER use any spaces in an argument of any kind. If you type LDA 251 ,Y the space between the number and the comma will result in a syntax error. USING MLASS MLASS is a pure machine language program with a BASIC link. If you are not familiar with BASIC links they are ML programs that start with a single line of BASIC code. The BASIC line contains an SYS command that starts the program. This eliminates the need for a boot program or to remember the start address. The only drawback is that the program must reside in the BASIC text area starting at 2048. To run MLASS reset the computer by turning it off then on again. This is to make sure that the beginning of BASIC text pointer is set to 2048. Enter, LOAD "MLASS V1.0",8 and return. When the program is loaded, Enter, RUN and return There are four options at the menu. The first one is DISK ASSEMBLY. To compile a program on disk press the F1 key. You will be asked to enter the name of the source file you wish to compile. If you are chaining files you must enter the FIRST file in the chain. You can see the disk directory by entering the $ (dollar sign) or abort by pressing the return key alone and you will return to BASIC. The second option is RAM ASSEMBLY. To compile a source file in memory press the F3 key. No file name is needed to compile from RAM. The third option is RETURN TO BASIC. By pressing F5 you will return to the BASIC editor where you can load, enter, or edit a source file. You can return to MLASS at any time by pressing the RUN/STOP and RESTORE keys. You can switch back and forth between MLASS and BASIC as often as needed and the file in memory will remain unaffected. The last option is RESET COMPUTER. By pressing the F7 key the computer will be reset to the power on configuration. If you press this key by mistake you can re-enter MLASS with SYS 2073. However, any source file in memory will be lost. When you choose to compile a program, disk or ram, you will be asked if want to create a BASIC link (see the explination of BASIC links above). If you choose this option there are a couple of things to remember. 1) The .O command is ignored and the object code will not be poked into memory during assembly. 2) The start address is automaticly set to 2073 and the start address specified by the *= command is ignored. 3) Even though the *= command is ignored it MUST be used. MLASS was designed to work with METABASIC active in memory. If you are using a different editor enhancement program it should not cause any conflicts with MLASS but I cannnot make any promises since I only tested it with METABASIC. Whatever enhancement you are using just make sure it is activated before you run MLASS. Most editor enhancements change the NMI vector that would prevent you from re-entering MLASS with the RUN/STOP- RESTORE combination. If you are using METABASIC follow these steps, 1) Reset the computer 2) Load and activate METABASIC 3) If you want to use the DEFAULT command you must use it before you run MLASS. 4) Load and run MLASS One last thing, at this time MLASS does not support two drives. All work is done on device 8 for the drive and device 4 for the printer. ERROR MESSAGES MLASS will attempt to catch as many errors as possible during assembly. If it finds an error the message will look something like this, SYNTAX ERROR FILENAME LINE# STRING The filename is the source file being read when the error occured. If using the RAM based assembly no filename will be given. The line number is the line which contains the error and the string is the lable, instruction, or argument that caused the error. In addition to these MLASS will read the disk error channel whenever it accesses the device. If an error occurs the error will be printed to the screen and the program will stop. NO START ADDRESS - The first line of a source file (the first line of the first file when chaining) MUST be the *= command. If MLASS does not find the command this message will be printed and the program will stop. END OF FILE - Every source file must end with a .FILE or .END command. If the program reaches the end of a file without finding one of these commands the program will stop. *NOTE* When this error occurs only the filename is important. The line number and string should be ignored. OUT OF MEMORY - MLASS puts all lables in an array that begins at the top of BASIC storage and builds down. If the array reaches the bottom of BASIC storage or the end of a file in memory this error will occur. Since there is about 32k of free ram the only time this should occur is if there is a large program in memory. If you are using the RAM based assembly and this happens you will have to save the file to disk and use the disk assembly option. OVERFLOW - This means MLASS has found a number that is too large. There are three things that will cause this error. 1) A number larger than 65535. 2) An indirect instruction like LDA (200),Y and the value is more than 255. 3) If a .BYTE statement contains a number larger than 255. BRANCH OUT OF RANGE - This will occur if a branch instruction exceeds the 128 bytes backward or 127 bytes forward limit. NAKED LABEL - Lables are used in one of three ways. A) as an equate which means it is followed by an equal sign and a value, B) placed before an instruction which means it's a target, and C) in an argument following an instruction. A naked label is one that is on a line by itself (not followed by an equal sign or an instruction). UNDEFINED LABLE - A lable used in an argument that was not defined as an equate or a target (A and B above). DUPLICATE LABLE - A lable that was defined more than once. A lable may be used as many times as needed in arguments but can only be defined as an equate or target once. SYNTAX - Any string of characters that MLASS cannot understand will result in a syntax error. Can also mean that you forgot something like a value after an equate, or an argument after an instruction. If you have any questions, comments, or any suggestions for future versions you can contact me on Q-LINK: handle, TBIRD4 or you can write me at.... 11970 Grevillea Ave. APT. N Hawthorne Calif. 90250