BAS File Format Description |
Conventions
BYTE - 8 bit unsigned char
WORD - 16bit unsigned short (little endian)
Header
WORD LOMEM
WORD VNT
WORD VNTE
WORD VVT
WORD STMTAB
WORD STMCUR
WORD STARP
LOMEM should be always zero - points to page with immediate buffer
VNT - start of variable name table - usually offset $100 from LOMEM
VNTE - end of variable name table
VVT - start of variable values table
STMTAB - start of token area
STMCUR - current line (line 32768)
STARP - end of token area, start of stacks
Variable name table
Variable names are stored in char per char, last is ORed with $80.
Sometimes the name area is overwritten with $9B chars (so called unlistable
programs).
Variable values table
8 bytes per value:
BYTE btType
BYTE btNumber - offset to variable name table
BYTE[6] data - depends on btType
btType could be one of:
$00 SCALAR - data is interpreted as Atari BCD
$40 ARRAY undimed - data is interpreted as follows:
WORD STARP offset
WORD dim1
WORD dim2
$41 ARRAY - same as above
$80 STRING undimed - data is interpreted as follows:
WORD STARP offset
WORD length
WORD dim
$81 STRING - same as above
Token area
Line begins with
WORD line number
BYTE line length in bytes
Then there is one command:
BYTE token len
BYTE token byte
additional data
00 REM
01 DATA
02 INPUT
03 COLOR
04 LIST
05 ENTER
06 LET
07 IF
08 FOR
09 NEXT
0A GOTO
0B GO TO
0C GOSUB
0D TRAP
0E BYE
0F CONT
10 COM
11 CLOSE
12 CLR
13 DEG
14 DIM
15 END
16 NEW
17 OPEN
18 LOAD
19 SAVE
1A STATUS
1B NOTE
1C POINT
1D XIO
1E ON
1F POKE
20 PRINT
21 RAD
22 READ
23 RESTORE
24 RETURN
25 RUN
26 STOP
27 POP
28 ?
29 GET
2A PUT
2B GRAPHICS
2C PLOT
2D POSITION
2E DOS
2F DRAWTO
30 SETCOLOR
31 LOCATE
32 SOUND
33 LPRINT
34 CSAVE
35 CLOAD
36 silent let
37 ERROR -
Tokens 0 & 1 are followed by string ending by $9B.
Then there may be some operands:
0E NCONST
0F SCONST
10 NOUSE
11 NOUSE
12 ,
13 $
14 :
15 ;
16 EOL
17 GOTO
18 GOSUB
19 TO
1A STEP
1B THEN
1C #
1D <=
1E <>
1F >=
20 <
21 >
22 =
23 ^
24 *
25 +
26 -
27 /
28 NOT
29 OR
2A AND
2B (
2C )
2D =
2E =
2F <=
30 <>
31 >=
32 <
33 >
34 =
35 +
36 -
37 (
38 (
39 (
3A (
3B (
3C ,
3D STR$
3E CHR$
3F USR
40 ASC
41 VAL
42 LEN
43 ADR
44 ATN
45 COS
46 PEEK
47 SIN
48 RND
49 FRE
4A EXP
4B LOG
4C CLOG
4D SQR
4E SGN
4F ABS
50 INT
51 PADDLE
52 STICK
53 PTRIG
54 STRIG
NCONST is followed by 6 bytes of Atari BCD number.
SCONST is followed by string data.
If operand has bit 7 set, then it's reference to variable.
000A 0F 0F 36 80 2D 0E 40 10 00 00 00 00 16
Line 10
$0F - end of commands
$0F - end of this command
$36 - silent let
$80 - $80 & $7F = $00 - reference to variable 0 (A)
$2D - =
$0E - number constant
$4010000000 - BCD 10
$16 - EOL
0014 08 08 20 80 15 16
Line 20
$08 - end of commands
$08 - end of this command
$20 - PRINT
$80 - ref. to variable 0
$15 - ;
$16 - EOL
Output of my ChkBas program:
ChkBas v1.00 (c) 1998-1999 Jindrich Kubec <kubecj@asw.cz>
Latest version can be found at http://www.asw.cz/~kubecj
Published under GPL. See GPL.TXT
Thanks to Russ Gilbert for his SALVAGE programs
Input file: h
Constants & pointers:
Start of Name Table (VNT) : 000E
End of Name Table (VNTE) : 000F
Lenght of Name Table (VNTL) : 0002
Start of Variable Table (VVT) : 0010
End of Variable Table (VVTE) : 0017
Length of Variable Table (VVTL) : 0008
Number of Variables (NV) : 0001
Start of Code (STMTAB): 0018
Length of Code : 0017
Current command (STMCUR): 002F
Length of current command : 000C
First byte after program (STARP) : 003B
Length of file : 003B
File len difference : 00000000
Variable table:
0001 SCALAR (00) 00: 0 A
Main code starts here:
10 A=10
20 PRINT A;
Immediate code starts here:
32768 SAVE "H1:H"
Back (c) 1998-2004 Jindroush Last modified: Mon Apr 19 11:14:52 1999