Relocating Machine Code Programs in the TS-2068

Authors

Publication

Pub Details

Date

Pages

Why would one want to relocate machine code? Many M/C programs written for the 2068 are located in the same area of RAM. Sometimes one might want to use both if they can be used that way. If you relocate one, you may be able to use both. I had previously purchased the ZEAL disassembler and found that I couldn’t use my printer driver with it because they both used the same area of RAM to store their M/C. Although the printer interface I used (TASMAN) had a driver program to store in the computers printer buffer, I found that I couldn’t use that either because something in ZEAL would wipe that out. I found that, even after transferring the printer to an address below the ZEAL machine code, 1 still could net use it directly through ZEAL. I had to use the Tasman screen copy routine to get a printout of the screen. Tasman has 2 screen copy routines. One is for text only and is stored with the regular printer driver. The other is stored in the computer’s printer buffer and will copy anything on the screen. The computer’s printer buffer location is reverted to normal with NEW.

Machine code programs that have been saved on tape or disk are loaded back into the computer memory with LOAD “”CODE (or a name can be specified [must be for some disk systems]). With that simple way of entering, the code is placed at the same address it was saved from. If you want to relocate it, then you enter LOAD “”CODE (address) and it will load in at the address specified. If the code contains only relative jumps and ROM calls, it can be run with no changes. If it contains absolute jumps and calls within its own addresses, these will have to be changed for the program to work. I have successfully done this to a few programs and got them to work.

A disassembler program comes in quite handily for accomplishing the changes. I use ZEAL since it prints out the addresses in decimal. ZEAL has a set up to print to a printer, but, as far as I can tell, it only supports the 2040 printer. ZEAL did give me an option to have the program disassembled in its present location and in its original location, or at any address I choose. If you want, you can get printouts at both locations. In order to get a printout of the ZEAL disassembly, it was necessary to break out of the ZEAL program with CAPS SHIFT/BREAK and then copy the screen. This was a little tough to do on the first break out, but, after that it was no trouble.

If you have made the printouts at both locations, take the two printouts and compare them. One of the things you will notice is that the relative jump addresses are different. This is correct and they do not have to be changed. You will then notice that the absolute jumps and calls are the same in both listings. You will also notice that paired registers are loaded with numbers. The numbers are equivalent to address in the code. Generally, these are the HL register. All absolute jumps will have to be changed. If the calls and HL numbers are to ROM or (in most cases) to addresses below 26719, they do not need to be changed. If the calls and HL numbers are to addresses in the program, they will have to be changed. What I do, in this case, is look for the address shown in the original program. Then I find the comparable address in the relocated program and break it down into High Byte and Low Byte (i.e. High Byte = INT(address/256) and Low Byte = address – High Byte * 256). Once you have this information you go back to the relocated address that originally listed that address in the mnemonics and POKE the following two addresses with the Low Byte and High Byte in that order.

It is a lot of work, but, once you have everything changed, you have a relocated program that works like the original. You must re-save the changed program and it will load back in at the new address without specifying the new address. Remember, you must set RAMTOP at one address below the start of the code. Since I now have the Tasman printer driver located at 60000 and ZEAL loaded in, I initialize ths printer driver with RANDOMIZE USR 60003, and then use RANDOMIZE USR 60000 to make a text only screen copy.

Although I do not understand enough to write my own M/C, I understand enough to figure out how to do things like relocating it. If you understand enough, you can too.

Products

 

Downloadable Media

 
Scroll to Top