Jump to content



0

Packing *.bas


14 replies to this topic

#1 walter_J64bit ONLINE  

walter_J64bit

    River Patroller

  • 3,441 posts
  • Location:Goldsboro NC

Posted Mon Jan 23, 2012 7:38 AM

Can a *.bas file be packed?

#2 russg OFFLINE  

russg

    Dragonstomper

  • 523 posts
  • Location:Cleveland, Ohio

Posted Mon Jan 23, 2012 8:07 AM

View Postwalter_J64bit, on Mon Jan 23, 2012 7:38 AM, said:

Can a *.bas file be packed?
What's 'packed'? ZIPed, ARCed, GZIPed? I don't think that's what you mean. If you mean there's a way to make it smaller and still run on an A8, I think the answer is no, it would have to be 'unpacked' first.

Edited by russg, Mon Jan 23, 2012 8:07 AM.


#3 walter_J64bit ONLINE  

walter_J64bit

    River Patroller

  • 3,441 posts
  • Location:Goldsboro NC

Posted Mon Jan 23, 2012 8:16 AM

View Postrussg, on Mon Jan 23, 2012 8:07 AM, said:

View Postwalter_J64bit, on Mon Jan 23, 2012 7:38 AM, said:

Can a *.bas file be packed?
What's 'packed'? ZIPed, ARCed, GZIPed? I don't think that's what you mean. If you mean there's a way to make it smaller and still run on an A8, I think the answer is no, it would have to be 'unpacked' first.
Yes, to it smaller and still run, Ok I didn't think so. Thanks!

#4 bbking67 OFFLINE  

bbking67

    Star Raider

  • 98 posts
  • Location:Osgoode, ON, Canada

Posted Mon Jan 23, 2012 8:21 AM

There are some development tools for BASIC that renumber, replace variables, remove comments, etc. That might pack programs somewhat and reduce the memory used.

Another option is to compile using Turbo BASIC.

#5 Sub(Function(:)) OFFLINE  

Sub(Function(:))

    Moonsweeper

  • 357 posts
  • Location:Athens, Greece

Posted Mon Jan 23, 2012 8:21 AM

But, there are compilers for BASIC:

I found the manual for one here:
http://www.bollwerk-...ic_Compiler.pdf

Compilers should shrink the size of the program and make it run faster. It will however no longer be listable or editable.

If this is really what you need I would suggest looking at Turbo Basic. This mainly backward with atari basic and has a compiler.

#6 Rybags ONLINE  

Rybags

    Quadrunner

  • 10,315 posts
  • Location:Australia

Posted Mon Jan 23, 2012 8:30 AM

It could but there's probably nothing out there to do so.

You could probably kludge it by making a compound binary file.

Locations $80 - $D3, plus the program area. Program area should be from MEMLO to APPMHI.
Additionally, segments to set PORTB to $FF and the Basic enable flag.

A short subroutine within the Basic program itself could generate the file. But you'd end up with the program higher in memory if Dos was loaded when you create it.
Easy way would be to use an emulator with H: patch.

Running - should be in the Basic Source Book, the address needed to run the program in memory.

#7 CharlieChaplin OFFLINE  

CharlieChaplin

    Stargunner

  • 1,293 posts
  • Location:Germany

Posted Mon Jan 23, 2012 1:17 PM

Well,

one upon a long ago... there was a tool named "Basic Masher" it was written to make Basic programs shorter in one way or another, alas, I have not really found out how it works. At first the program asks for the number of variables in your program (and since I am no programmer and much too lazy to count variables in other peoples programs, this is where I always stopped) and I have no clue what happens then. I found three different versions of the program, two versions written in Atari Basic and one version compiled with ABC or MMG compiler. I used the longer/newer? Basic version to create version number four in compiled Turbo Basic and the CTB-linker to make it a standalone *.COM/*.XEX file... you can find these four versions on the attached disk image BASMASH.ATR, maybe you can find out how this program works and if its really usefull or not...

Second, you can use an easy trick by using programs that add a ML-header to your Basic File (but which do not compile the program). At the moment I have four programs in my collection which do this:

1) a PC program from Fandal, named BAS2XEX.EXE which I will not upload here (since it creates files that do not run on the real A8, it creates pseudo-ML files that use memory $0700-xxxx, RUN $0700)...

2) an A8 program named BAS2BIN that was once published in Antic or Analog magazine, it creates ML-files which I never got to work on my A8... (maybe I was too stupid to use it correctly)...

3) another A8 program named BAS2COM by Raster, it can convert tokenized *.BAS or listed *.LST Atari Basic files into pseudo-ML (the Basic file must not be longer than 28kbytes); however not all created ML files will run, so always keep a backup of your Basic file somewhere; if the created ML file works fine, you can load it with "binary load" from DOS or simply from a gamedos, then hit Break, Reset or Control-3 to get the file listed again...

4) another A8 program named Automatic Basic program Loader by Juergen Meyer, which will convert any *.BAS file into *.COM (length up to 32kbytes, always add a CLR and Gr.0 at the start of the Basic program); alas Break or Reset or Control-3 will not always list the program (sometimes it happens that the A8 crashes then), so again keep a backup of your Basic file...

Now, with these programs you can convert a Basic file into a pseudo-ML file, usually these ML files are some bytes/sectors longer then - how do you get them shorter ?!? Easy, since the Basic files now have an ML header you can use any kind of COM/XEX packer program on the A8 (e.g. Superpacker by Bewesoft, Fastpacker, Flash Packer, Code 3 Cruncher, Magnus Cruncher, etc.) or on the PC (Superpacker by TeBe) to pack this pseudo-ML file. I already did this with some programs, I can load them from DOS or Gamedos, see the program unpack and run and then one press of Reset or Break and they can be listed and edited again... see attached disk BAS2COM.ATR here...

Of course there is also option three, compile the Basic program with ABC or MMG or some other Basic compiler, then pack the *.COM/*.XEX file...

Greetings, Andreas Koch.

Attached Files



#8 bf2k+ OFFLINE  

bf2k+

    Stargunner

  • 1,461 posts
  • Location:Boot Factory BBS 2k+

Posted Mon Jan 23, 2012 8:30 PM

I use the MMG compiler a lot myself... I formerly used ABC compiler also back in the 80's.

While MMG does not make the program smaller (it makes it bigger), it definitely executes faster. Here's a size example:

cds.jpg

#9 russg OFFLINE  

russg

    Dragonstomper

  • 523 posts
  • Location:Cleveland, Ohio

Posted Mon Jan 23, 2012 9:57 PM

Andreas doesn't use BASMASH because it asks the number of variables in a BAS file. OK, here's a little BAS program that lists all variables in a .BAS file.
It just lists all variables at top of screen. It should be easy then to count them. You LOAD or ENTER your BASIC program to analyze. Then you ENTER "D:VNT.LST"
(it starts at line 32000). Then you type GOTO 32000 and walla your variables are listed. It comes from ANALOG #25, BASIC Tutorial article. Page 68.
It is called TUTOR2.BAS on the #25 disk.

Attached Files

  • Attached File  VNT.zip   342bytes   11 downloads

Edited by russg, Mon Jan 23, 2012 10:02 PM.


#10 russg OFFLINE  

russg

    Dragonstomper

  • 523 posts
  • Location:Cleveland, Ohio

Posted Tue Jan 24, 2012 10:46 AM

View Postrussg, on Mon Jan 23, 2012 9:57 PM, said:

Andreas doesn't use BASMASH because it asks the number of variables in a BAS file. OK, here's a little BAS program that lists all variables in a .BAS file. It just lists all variables at top of screen. It should be easy then to count them. You LOAD or ENTER your BASIC program to analyze. Then you ENTER "D:VNT.LST" (it starts at line 32000). Then you type GOTO 32000 and walla your variables are listed. It comes from ANALOG #25, BASIC Tutorial article. Page 68. It is called TUTOR2.BAS on the #25 disk.
A note. There will be three more variables displayed than in your .BAS program because VNT.LST includes it's own variables. Aw shucks. These variables are at the end, so it is easy. VNTD, VNTB and ADRS
to see which ones they are.

Edited by russg, Tue Jan 24, 2012 10:55 AM.


#11 atarixle OFFLINE  

atarixle

    Chopper Commander

  • 169 posts
  • Location:Germany

Posted Tue Jan 24, 2012 6:22 PM

There are some ways to "compress" BASIC files:

-make every variable as small as possible (one or two letters)
-in Turbo-BASIC, make every PROCedure-name as small as possible
-LIST, NEW and ENTER a program, to remove no-longer used variables from the internal variable table

-use your programming skills:
--use Turbo-BASIC, to benifit from commands that abstract multiple commands in Atari-BASIC (e.g. copying memory-blocks)
--instead of numbered bytes in DATA-Lines, use strings with ATASCIIs representing those bytes
--re-use variables as often as possible - which is very hard in BASIC, where every var is a global one

and much much more ...

#12 David_P ONLINE  

David_P

    Moonsweeper

  • 296 posts
  • Location:Canada

Posted Tue Jan 24, 2012 9:59 PM

In Atari BASIC, a variable's name doesn't occupy much memory. The first time it's used it's added to the Variable Name Table; after that, all references are reduced to a two byte token. Thus, a variable named REALLYBIGVARIABLENAME only used 2 bytes for any reference beyond the first time. I find the readability of longer names outweighs the minor memory savings.

#13 atarixle OFFLINE  

atarixle

    Chopper Commander

  • 169 posts
  • Location:Germany

Posted Wed Jan 25, 2012 5:53 AM

I know ... I'm programming in Atari BASIC/Turbo BASIC for like 21 years now. And reducing var-names saved up to two sectors on disk on my projects.

but many variables with long names are wasting much memory for the long names ... and on Atari 8 Bit Machines, EVERY single byte matters.

Edited by atarixle, Wed Jan 25, 2012 5:53 AM.


#14 russg OFFLINE  

russg

    Dragonstomper

  • 523 posts
  • Location:Cleveland, Ohio

Posted Wed Jan 25, 2012 11:40 AM

View Postrussg, on Mon Jan 23, 2012 9:57 PM, said:

Andreas doesn't use BASMASH because it asks the number of variables in a BAS file. OK, here's a little BAS program that lists all variables in a .BAS file.
It just lists all variables at top of screen. It should be easy then to count them. You LOAD or ENTER your BASIC program to analyze. Then you ENTER "D:VNT.LST"
(it starts at line 32000). Then you type GOTO 32000 and walla your variables are listed. It comes from ANALOG #25, BASIC Tutorial article. Page 68.
It is called TUTOR2.BAS on the #25 disk.

Here's a VNT2.LST that counts the variables for you, including four in VNT2.LST. The four willl be at the end of the list of variables and be VNTD, VNTB, ADRS and CNT (count). So just subract four.

Attached Files

  • Attached File  VNT2.zip   373bytes   6 downloads


#15 russg OFFLINE  

russg

    Dragonstomper

  • 523 posts
  • Location:Cleveland, Ohio

Posted Wed Jan 25, 2012 8:16 PM

I have seen the 'packing' phenominon in a HP 41CV calculator. When you program it, the program remains in memory, you hit GTO .. and it will 'pack' the memory, conserving some memory.
The calc holds several programs in its memory. I'm thinking the OP was thinking you could 'LOAD' a program in memory then do a 'packing' process to reserve more memory.
The Atari doesn't work like that. There are techniques to set aside memory in the Atari when you write a program, say for a custom font or for screen graphics. The Atari
has a RAMTOP, location 106 decimal. You can reserve memory for your own purpose by POKEing 106, PEEK(106)-X where X is how many 256 pages you want to
reserve. Then you have to do a GRAPHICS to move screen memory and the display list down before you use this memory.

Edited by russg, Wed Jan 25, 2012 8:30 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users