Wrapping binaries in INTBASIC?

140 views
Skip to first unread message

Steve Nickolas

unread,
Jul 24, 2018, 8:11:59 PM7/24/18
to
I've seen a number of INTBASIC programs that have bits of 6502 code in
them. I've tried to figure out how to do this without luck

Basically - I'm trying to create a one-file program which can load
Applesoft into memory for either a ][, or a /// booted with the
bootloader I've been using (I still have to distinguish these two).

-uso.

fadden

unread,
Jul 25, 2018, 1:36:38 PM7/25/18
to
On Tuesday, July 24, 2018 at 5:11:59 PM UTC-7, Steve Nickolas wrote:
> I've seen a number of INTBASIC programs that have bits of 6502 code in
> them. I've tried to figure out how to do this without luck

I'm not sure any of the answers really explain it, but some info is here:

https://retrocomputing.stackexchange.com/questions/494/how-were-binary-subroutines-embedded-in-integer-basic-programs

dmrog...@yahoo.com

unread,
Jul 26, 2018, 9:28:00 AM7/26/18
to
I've been trying (off and on, mostly off) for some time to convert Wendell Sanders Apple Trek from Integer to Applesoft. He's got a little audio routine in there that when you LIST the program causes it to go nuts. I've worked around the LIST issue, but I still have to extract the audio routine. Mostly I'm still in the BASIC conversion process. It's kind of tedious, but a worthwhile distraction from time to time.

Anyway, from Apple's CONTACT magazine, MAY '78, page 4, there may be some clues. This is written for using TAPE, not disk, so there may be some differences with DOS loaded, I haven't looked into that yet. But here's the procedure (I've typed it in verbatim (minus a couple of typos, may have added a few):

LOADING MACHINE LANGUAGE AS PART OF A BASIC PROGRAM

Often we want to include machine language data inside a BASIC program. A great many Apple tapes are made up this way to simplify the loading process. Here’s a recipe for doing it yourself with programs written in Apple BASIC.

Apple BASIC loads programs into memory with the highest program line at the highest RAM location (HIMEM). Preceding lines are located lower and lower in RAM. The beginning of the program is at PP, an address which is held in memory locations CA and CB (hexadecimal), or 202 and 203, decimal. When you type SAVE, the the computer transfers to tape everything between PP and HIMEM. Thus, to tuck machine language into your program so that it can later be loaded like BASIC, it is merely necessary to move the PP pointer fown below the beginning of the extra code, put in two POKEs to reset the pointer before running the program, and type SAVE. Later, you will be able to LOAD the whole thing just as if it were all BASIC. Just follow these steps:

1. Get the BASIC program into memory, just the way you want it. If you make any changes, you must re-do steps 2 and 6.
2. In the command mode, type: PRINT PEEK (202), PEEK (203) and write down the results. Let’s call them m and n, respectively.
3. Load your machine language code into memory using the monitor load capability (xxxx.yyyyR). This will put the machine language program into memory below the beginning of the BASIC program, starting at hexadecimal address xxxx.
4. Take the starting address of the machine language program and divide it into two parts: xx/xx. Convert each pair of digits from hex to decimal values: a & b; corresponding to the left and right xx pairs, respectively. Write them down.
5. Now enter the BASIC command mode and type: POKE 202,b-1 (value b from step 4, above) Poke 203, a (value a from above step 4 above) POKE 204,00 POKE 205,8
6. You have now moved the pointers down below your machine language program, and must insert code to move them back again when the program is run. To do that, type 0 POKE 202,m: POKE 203,n: GOTO q where m and n are the values from Step 2, and q is the first line number in your BASIC program. That line number can be 0 – it will not be erased by the above entry.
7. Now you’re done! Don’t try to list your program before running it, because all you’ll see is a meaningless set of numbers and symbols. Just type SAVE (before running the program), and it will all go onto tape. Later a LOAD command will bring it all back in.
CAUTION!

Once you have RUN such a program, you cannot SAVE it, for the pointers will have been moved. You can only save or coapy a program like this before it has been RUN.


Good luck!

Dave Rogers

fadden

unread,
Jul 26, 2018, 11:16:17 AM7/26/18
to
On Thursday, July 26, 2018 at 6:28:00 AM UTC-7, dmrog...@yahoo.com wrote:
> Anyway, from Apple's CONTACT magazine, MAY '78, page 4, there may be some clues.

Excellent! Can't speak for anyone else, but that's exactly what I've been looking for.

dmrog...@yahoo.com

unread,
Jul 26, 2018, 1:43:10 PM7/26/18
to
Well, not to confuse things - but I also found this while I was spelunking around my archives. It identifies certain issues that may be more relevant for the OP. I have clipped images that I can't post, but the original source is here: https://archive.org/stream/Best_of_Micro_The_Volume_1_1978_COMPUTERIST_The_US#page/n105

There are probably a few other ways. There usually are.

Dave

Tom Porter

unread,
Jul 26, 2018, 8:20:58 PM7/26/18
to
I have no idea if this will be of any help, but I found a binary that converts Integer to Applesoft... its included on this disk here. BRUN it.

https://www.dropbox.com/s/x2flyemyxjnudq3/Apple%20DOS%203.3%20January%201983.dsk?dl=0

Steve Nickolas

unread,
Jul 26, 2018, 8:32:30 PM7/26/18
to
On Thu, 26 Jul 2018, Tom Porter wrote:

> I have no idea if this will be of any help, but I found a binary that
> converts Integer to Applesoft... its included on this disk here. BRUN
> it.

For what it's worth, the program I'm wrapping actually loads Applesoft on
an Apple ///. ;)

-uso.
Reply all
Reply to author
Forward
0 new messages