Jump to content
IGNORED

M/L to Basic Data Statements?


bob1200xl

Recommended Posts

I have some machine language routines that I want to convert to BASIC DATA statements. Isn't there a BASIC program out there that you can point at some object code and have it generate DATA statements that you can then ENTER into your program?

 

I don't want strings because they are impossible to change easily and I have a ton of memory, anyway.

 

Bob

Link to comment
Share on other sites

I did a handy utility called "HexPoke" decades ago, but I don't know if I've still got it.

It allowed DATA with hex numbers and had a routine around 80 bytes or so that stored it into RAM.

 

As for creating DATA from a file, it's something that's so simple that I don't bother keeping a program on hand. There's 2 ways - either generate a file then ENTER it, or use the "Forced E: input" method to generate the lines as part of the current program.

 

So, all you need for method 1 is something like:

 

10 OPEN #1,4,0,"D:object.OBJ"
20 OPEN #2,8,0,"D:basic.LST"
30 LN=20000:REM Starting line #
40 TRAP 500
100 ? #2;LN;" DATA ";
110 GET #1,D:? #1;D;
120 FOR A=1 TO 19:GET #1,D:? #2;",";D;
130 NEXT A:? #2
190 LN=LN+10:GOTO 100
500 ? #2
510 CLOSE #1:CLOSE #2

 

If dealing with a Binary file, then just put a line after the OPEN that dummy-reads the first 6 bytes.

Edited by Rybags
Link to comment
Share on other sites

Ohhh... well, that looks pretty simple. Heck, I'm a hardware guy, not a programmer. I never would have figured that out.

 

Thanks! - saves me a lot of typing and converting.

 

Bob

 

 

 

I did a handy utility called "HexPoke" decades ago, but I don't know if I've still got it.

It allowed DATA with hex numbers and had a routine around 80 bytes or so that stored it into RAM.

 

As for creating DATA from a file, it's something that's so simple that I don't bother keeping a program on hand. There's 2 ways - either generate a file then ENTER it, or use the "Forced E: input" method to generate the lines as part of the current program.

 

So, all you need for method 1 is something like:

 

10 OPEN #1,4,0,"D:object.OBJ"
20 OPEN #2,8,0,"D:basic.LST"
30 LN=20000:REM Starting line #
40 TRAP 500
100 ? #2;LN;" DATA ";
110 GET #1,D:? #1;D;
120 FOR A=1 TO 19:GET #1,D:? #2;",";D;
130 NEXT A:? #2
190 LN=LN+10:GOTO 100
500 ? #2
510 CLOSE #1:CLOSE #2

 

If dealing with a Binary file, then just put a line after the OPEN that dummy-reads the first 6 bytes.

Link to comment
Share on other sites

I have a program called Convert.bas which will convert any file, ML, Picture, Font, into either DATA statements or string assignments.

 

The thread is here: http://www.atariage.com/forums/topic/147473-basic-program-fonts-wanted-in-string-format/page__p__1813361__fromsearch__1?do=findComment&comment=1813361

 

It will even strip out the first 6 bytes. If you use strings, there is a string offset into the variable name table which will immediately move the data into the location you want (a block POKE).

Link to comment
Share on other sites

I have some machine language routines that I want to convert to BASIC DATA statements. Isn't there a BASIC program out there that you can point at some object code and have it generate DATA statements that you can then ENTER into your program?

 

I don't want strings because they are impossible to change easily and I have a ton of memory, anyway.

 

Bob

Don't forget there are a few things to know about BASIC USR calls. X=USR(1536) BASIC pushes the return address on the stack, it also pushes the number of

paramaters (X=USR(1536,16,32), one byte, then the parameter gets pushed LO first HI second. So there's at least one PLA (104) you put before your ML numbers. The return address shouldn't be PLAed off, it is needed for the RTS you put in your machine code. So the stack looks like this, one parameter passed:

The order you pull off the stack (PLA)

# of parameters (can be 0), one byte

parameter HI byte

parameter LO byte

Return HI I think

Return LO I think (could be LO HI, which is the usual. You PLA off the stack in the reverse of the way it is pushed, Called a first in last out stack (FILO).... no a LIFO stack, same thing.

Edited by russg
Link to comment
Share on other sites

yes,,, whatever you said.

 

I just PLA and RTS back.

 

Bob

 

 

I have some machine language routines that I want to convert to BASIC DATA statements. Isn't there a BASIC program out there that you can point at some object code and have it generate DATA statements that you can then ENTER into your program?

 

I don't want strings because they are impossible to change easily and I have a ton of memory, anyway.

 

Bob

Don't forget there are a few things to know about BASIC USR calls. X=USR(1536) BASIC pushes the return address on the stack, it also pushes the number of

paramaters (X=USR(1536,16,32), one byte, then the parameter gets pushed LO first HI second. So there's at least one PLA (104) you put before your ML numbers. The return address shouldn't be PLAed off, it is needed for the RTS you put in your machine code. So the stack looks like this, one parameter passed:

The order you pull off the stack (PLA)

# of parameters (can be 0), one byte

parameter HI byte

parameter LO byte

Return HI I think

Return LO I think (could be LO HI, which is the usual. You PLA off the stack in the reverse of the way it is pushed, Called a first in last out stack (FILO).... no a LIFO stack, same thing.

Link to comment
Share on other sites

Got it - thanks!

 

Bob

 

I have a program called Convert.bas which will convert any file, ML, Picture, Font, into either DATA statements or string assignments.

 

The thread is here: http://www.atariage.com/forums/topic/147473-basic-program-fonts-wanted-in-string-format/page__p__1813361__fromsearch__1?do=findComment&comment=1813361

 

It will even strip out the first 6 bytes. If you use strings, there is a string offset into the variable name table which will immediately move the data into the location you want (a block POKE).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...