OBJECT CODE TO STRING
Using Assembly Language in BASIC
by Jerry WhiteThis article and its associated programs will be of interest to those who use (or plan to use) assembler subroutines within ATARI BASIC programs.
It is often a good idea to put assembler (machine language) subroutines into a string. If the subroutine does not have to be stored at a specific address, it may then be called from within a BASIC program using a command such as JW = USR(ADR(ASM$)). Assuming that the assembler subroutine has been stored in a string called ASM$, this command tells BASIC to locate and execute.
The OBJ2STR BASIC program will read an object code file from disk and convert it into a string for you. If you are beginning to learn assembly language, or if you'd like to start now, enter the SOUNDOFF.SRC program using your SYNASSEMBLER or Atari Assembler Cartridge. If you don't have an Assembler yet, I highly recommend SYNASSEMBLER from SYNAPSE SOFTWARE over the Atari Cartridge.
Assuming that you now have an object code file called SOUNDOFF.OBJ, and that you have SAVEd the BASIC OBJ2STR program, we will now RUN OBJ2STR and convert our object code into a string. When entering names for your input and output disk files, OBJ2STR will assume that you intend to use disk drive number one. You do not have to type "D:" before the filename. You may use drive two if you so desire by entering an input filename such as D2:SOUNDOFF.OBJ. I recommend that you use the same filename for both input and output files, but with the extension .OBJ to indicate the input OBJect code, and .LST to indicate the output string file, which will be in the form of untokenized or LISTed ATARI BASIC.
You must then supply OBJ2STR with a starting line number for your BASIC string. You may simply press [RETURN] to use the default of line number 31000, or type over this number with any number from 1 to 32700.
Once this has been done, OBJ2STR will display the message, "I'm working on it!", until the task has been completed. Upon completion, the program will proudly display the message "I DID IT!". and position the cursor over the word "NEW".
Assuming that you have saved the OBJ2STR program, you may now look at the BASIC string you have just created by pressing [RETURN] three times. Since the cursor is over the word "NEW". pressing [RETURN] the first time will delete OBJ2STR from memory. The cursor will then be positioned over an ENTER command. Pressing [RETURN] the second time will ENTER your string from disk into RAM. Finally, the cursor will be positioned over the word "LIST". Guess what pressing [RETURN] will do now.
If you used SOUNDOFF.OBJ as your input, you will now see three lines of BASIC code on your screen. The first will be a DIM statement. The second will be a string equate statement, and the third will be a RETURN. I suggest that you rename ASM$ to something more descriptive such as SOFF$. Depending on your program, you may or may not need the RETURN line.
Notice that the string length is 12. Since we needed only one line to define this tiny subroutine, you could save some RAM by putting both the DIM and the equate code on the same line. You may also delete the string position code "(1)".
After using the OBJ2STR program, did you find it to be useful? Do you have any questions about Atari Basic? Would you like to see more tutorials on Basic and Assembler? The answers to these questions would be helpful in providing subject matter for future issues of ANTIC. If there are specific topics you would like me to write about, send your letter to Jerry White, c/o ANTIC, 600 18th St., S.E, CA 94107.