The limitations of Austro compiler

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

The limitations of Austro compiler

Post by eslapion »

Austro compiler is a great tool for somebody like me who has virtually no ability to program in ML.

However, it also has some pretty severe limitations.

For one thing, it only generates code which can be run with a memory expansion of 8k or more.

Also, because of the adress range at which the BASIC program area starts when you use such an expansion, it is virtually impossible to compile a game which uses a special custom character set or graphics other than PETSCII.

The only option left is to make custom characters in the tape buffer which is extremely limiting.

Here is my question and request to you good programmers out there:

Since Austro compiler makes code that always starts at the same address and generally begins the same way, would it be possible to make a software tool that automatically relocates a compiled program to a higher address ?

This software tool would allow the usage and creation of a custom character set of 64, 128 or 256 characters depending on the user's choice. It could come with a set of various "automatic" loaders which loads in the character set from a given file, relocates the start of the BASIC program area and load the compiled program then run it.

For a long time I have hoped to compile games such as "sword of fargoal" which are sometimes dreadfully slow to the point where they become more or less unplayable. The custom character set required for that game to operate makes that more or less impossible.

A few years ago I compiled a simple Othello game for the VIC and it became so much more fun to play with.
Be normal.
User avatar
Ghislain
Realms of Quest
Posts: 1282
Joined: Sun Aug 08, 2004 12:54 am

Post by Ghislain »

I only used Austro Compiler a couple of times and played around with it. I wasn't aware of the custom character limitation.

There are tools that already exist to relocate ML programs. I found this through an internet search:

http://www.atarimagazines.com/compute/i ... ocator.php

While this would normally be good enough to relocate a program and fix the absolute addresses, there could be a problem with indexed addresses that Austro Compiler most likely will generate.

If the indexed addresses cause a problem, I'd have to take a look at a disassembly of Austro Compiler and figure out where it creates the starting address. Once that is figured out, then you make different builds of AC to generate ML code at various starting addresses (4608, 5124, etc).

Perhaps a better programmer than I can chime in and provide their opinion.
"A slave is one who waits for someone to come and free him." -- Ezra Pound
tlr
Vic 20 Nerd
Posts: 568
Joined: Mon Oct 04, 2004 10:53 am

Post by tlr »

The Plus/4 implementation seems to have been reverse engineered here: http://plus4world.powweb.com/software/A ... d_Compiler

Maybe that can serve as a base to decompile the vic-20 one?
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

Are there any Vic programs that are known to be Austro compiled?

I need some examples to work on to make a decompiler.

Lee.
User avatar
GreyGhost
Vic 20 Nerd
Posts: 526
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

I compiled a couple. Autobaun & Diamond Hunt. You can get them both from here:

http://www.freedrive.com/file/1101298

http://www.freedrive.com/file/1101297
Rob
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

Well some success but still a lot to do. Here's the one program, GreyGhost's Autobaun, that decompiles without stopping on something I've not figured out yet. First the original source code.

Code: Select all

1 R$="{GRN}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}":R$=R$+CHR$(145)+CHR$(13)+CHR$(148)+"{^POUND}":S3=36876:S4=S3+1
2 V=S3+2:SB=S3+3:P1=37151:P2=P1+1:W=P1+3:CL=33792:FORA=824TO871:READD:POKEA,D:NEXT
3 P=4106:D=.:C=.:X=.:F=2:POKEV,15:POKEW,127:POKESB,14:POKES3-7,200:POKE36867,44:PRINT"{CLR}
4 PRINTR$;:D=D+1:X=X+RND(1):IFF>7THENF=5
5 Y%=SIN(X/6)*F:IFD>100THENPRINTSPC(Y%+7);"{YEL}{C=N}{C=Q}{C=Q}{C=Q}{C=Q}{C=N}":C=C+1:D=.:F=F+.5:GOTO7
6 PRINTSPC(Y%+7);"{BLK}{C=POUND}{C=POUND}{C=POUND}{C=POUND}{C=POUND}{C=POUND}"
7 POKEP,103:POKEP+CL,4:POKES3,155:POKES3,.
8 J=(PEEK(P1)AND60)OR(PEEK(P2)AND128):J=ABS(J-100):P=P+(J=72)-(J=40)
9 IFPEEK(P)=105THEN12
10 IFPEEK(P+22)=105THENIFJ<>40ORJ<>72THEN12
11 POKES3,155:POKES3,.:GOTO4
12 POKES4,220:FORQ=15TO.STEP-1:POKEV,Q:POKESB,122:FORS=1TO30:NEXT:POKESB,47
13 FORT=1TO30:NEXT:NEXT:POKES4,.:POKESB,14:POKES3-7,192:POKEW,255
14 PRINT"{CLR}{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RED}{RVS ON}YOU CRASHED!":PRINT"{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{BLU}YOU PASSED";C
15 PRINT"{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}CHECK POINTS":PRINT"{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{WHT}TOTAL SCORE:";(C*200)+(D-22)
16 PRINT"{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{RIGHT}{YEL}PLAY AGAIN? (Y/N)
17 GETA$:IFA$=""THEN17
18 IFA$<>"N"THEN3
19 DATA165,255,189,36,24,90,126,90,,,,,,,,,255,255,255,255,255,255,255,255,,24
20 DATA28,24,16,16,16,85,,,,,,,,85,112,248,248,254,127,31,31,14
.. and now the source generated by decompiling the compiled program ..

Code: Select all

12000 CLEAR
12001 R$="{GRN}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}{^POUND}"
12026 R$=R$+CHR$(145)+CHR$(13)+CHR$(148)+"{^POUND}"
12042 S3=36876
12049 S4=S3+1
12053 V=S3+2
12057 SB=S3+3
12061 P1=37151
12068 P2=P1+1
12072 W=P1+3
12076 CL=33792
12083 A=824
12087 FORA=ATO871
12092 READD
12094 POKEA,D
12097 NEXT
12098 P=4106
12102 D=0
12104 C=0
12106 X=0
12108 F=2
12110 POKEV,15
12113 POKEW,127
12117 POKESB,14
12120 POKES3-7,200
12126 POKE36867,44
12135 PRINT"{CLR}"
12138 PRINTR$;
12140 D=D+1
12144 X=X+RND(1)
12149 IFF>7THENF=5
12156 Y%=SIN(X/6)*F
12163 IFD>100THENPRINTSPC(Y%+7);:PRINT"{YEL}{C=N}{C=Q}{C=Q}{C=Q}{C=Q}{C=N}":C=C+1:D=0:F=F+.5:GOTO12213
12200 PRINTSPC(Y%+7);
12204 PRINT"{BLK}{C=POUND}{C=POUND}{C=POUND}{C=POUND}{C=POUND}{C=POUND}"
12213 POKEP,103
12217 POKEP+CL,4
12222 POKES3,155
12226 POKES3,0
12229 J=PEEK(P1)AND60ORPEEK(P2)AND128
12241 J=ABS(J-100)
12247 P=P+J=72-J=40
12259 IFPEEK(P)=105THENGOTO12302
12269 IFPEEK(P+22)=105THENIFJ<>40ORJ<>72THENGOTO12302
12292 POKES3,155
12296 POKES3,0
12299 GOTO12138
12302 POKES4,220
12306 Q=15
12308 FORQ=QTO0STEP-1
12313 POKEV,Q
12316 POKESB,122
12320 S=1
12322 FORS=STO30
12325 NEXT
12326 POKESB,47
12330 T=1
12332 FORT=TTO30
12335 NEXT
12336 NEXT
12337 POKES4,0
12340 POKESB,14
12343 POKES3-7,192
12349 POKEW,255
12353 PRINT"{CLR}{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RED}{RVS ON}YOU CRASHED!"
12378 PRINT"{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{BLU}YOU PASSED";
12399 PRINTC
12401 PRINT"{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}CHECK POINTS"
12423 PRINT"{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}{WHT}TOTAL SCORE:";
12446 PRINTC*200+D-22
12455 PRINT"{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{RIGHT}{YEL}PLAY AGAIN? (Y/N)"
12485 GET#,A$
12487 IFA$=""THENGOTO12485
12495 IFA$<>"N"THENGOTO12098
12504 END
12505 DATA165,255,189,36,24,90,126,90,,,,
12506 DATA,,,,255,255,255,255,255,255,255
12507 DATA255,,24,28,24,16,16,16,85,,,,,,
12508 DATA,85,112,248,248,254,127,31,31,14
As this is just a dumb single pass decompile there is no way to work out where lines start or end, except where multiple statements follow an IF command, so each command has its own line.

FOR .. NEXT loops look a little strange because the initial value of the loop variable is set before the FOR command.

Some obvious things that need fixing are every program seems to start with a CLEAR command and no account is taken of precedence, so lines like 12247 may not work as originally intended.

Some things still to work out are how arrays work, INPUT and INPUT#, the finer points of PRINT, PRINT# and how commas and semicolons change the p code generated and the forty or so p codes that I yet have no clue about.

Thanks to all for the example programs, especially those with the original, uncompiled source.

Lee.
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Post by eslapion »

Ghislain wrote:I only used Austro Compiler a couple of times and played around with it. I wasn't aware of the custom character limitation.
The limitation does not stem directly for Austro Compiler per se. It comes from the fact that the compiled code is designed to start at the same address as any program that requires 8k or more RAM expansion with the screen area moved to $1000.

If it was possible to tell AC to generated code to start at a higher address then this would leave room to create a custom character set which, AFAIK, is the only way on the VIC to make pixel oriented graphics.

Thank you all guys for investigating this.
Be normal.
tlr
Vic 20 Nerd
Posts: 568
Joined: Mon Oct 04, 2004 10:53 am

Post by tlr »

Aren't there any compilers that produce at least partially native 6502 code instead of interpreted code?
Some pieces should be possible to optimize quite much such as variables only used as integers and simple pokes and peeks.
User avatar
Mike
Herr VC
Posts: 4871
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Well there's always cc65, but that's a cross-compiler and different language of course.

Most of the speed enhancements of Austro-Comp stem from:

- pre-evaluating constants (so it's not 'necessary' anymore to put often used values into variables),
- calling the arithmetic routines in the BASIC interpreter directly instead of rebuilding the semantic tree everytime an expression is encountered, and
- working out all GOTO/GOSUB targets in advance, instead of traversing through the link pointers.

This easily gives a speed up of factor 3 for calculation-heavy parts, which I also saw in my Mandelbrot program, where I just replaced the inner loop by ML.

Another possible speed enhancement could be speeding up variable look-up by storing addresses of non-array and non-string variables, but as Austro-Comp still builds up a variable list like BASIC after the main program, I'm not sure whether that method is also used. Eventually, string garbage collection might also have been accelerated like in BASIC 3.5, 4 and 7.0.

Still not enough bang for the buck for me.
groepaz
Vic 20 Scientist
Posts: 1192
Joined: Wed Aug 25, 2010 5:30 pm

Post by groepaz »

Aren't there any compilers that produce at least partially native 6502 code instead of interpreted code?
"basic boss" does that. no idea if there exists a version targetted to vic20 though.
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

Austro builds a variable list but it codes variables as an index into that list so the list does not need to be searched every time a variable is used, as it does in BASIC.

Lee.
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

There's a few things I still can't tease from the Austro code and having the instructions would probably help a great deal. Does anyone know where I may find them?

Also, I think I've found where the dongle code has been patched out but I can't find an unpatched version to see what was actually changed. Does anyone know where I may find an unpatched version?

Lee.
wimoos
Vic 20 Afficionado
Posts: 350
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

Leeeeee wrote:Austro builds a variable list but it codes variables as an index into that list so the list does not need to be searched every time a variable is used, as it does in BASIC.

Lee.
Sounds like SuperNumbers that does exactly that. Speeds up float processing by approx. 20% compared to Basic 2.0. Max. 26 variables though.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Post Reply