aboutsummaryrefslogtreecommitdiff
path: root/dumpbas.rst
blob: 59cf93b8edeed1fca79515ba4b80c9cbe2e171f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
=======
dumpbas
=======

-------------------------------------------------------
Formatted hexdump for tokenized Atari 8-bit BASIC files
-------------------------------------------------------

.. include:: manhdr.rst

SYNOPSIS
========
dumpbas [**-v**] [**-l** *lineno*] [**-s** *start-lineno*] [**-e** *end-lineno*] *input-file*

DESCRIPTION
===========
**dumpbas** reads a tokenized Atari 8-bit BASIC program and prints a
formatted hexdump on standard output. The formatting groups the hex bytes
by line and statement, and includes special characters to mark different
types of token (see **FORMATTING**, below).

**dumpbas** does not detokenize BASIC programs or dump information
about variable names/values. Use **chkbas**\(1) for that. This tool is
intended to help the user learn about the tokenized BASIC format, or
as an aid for developing/debugging other tools that process tokenized
files. It's an alternative to looking at raw hex dumps.

It's assumed the user has at least some knowledge of BASIC's tokenized
SAVE format. The **Atari BASIC Sourcebook** is a good starting point
for learning the tokenized format.

OPTIONS
=======

General Options
---------------
**--help**
  Print usage message and exit.

**--version**
  Print version number and exit.

**-v**
  Verbose operation. When displaying a number in verbose mode, it will
  be prefixed with *$* if it's in hex, or no prefix for decimal.

Dump Options
------------
**-s** *start-lineno*
  Don't dump lines before **start-lineno**. Default: *0*.

**-e** *end-lineno*
  Don't dump lines after **start-lineno**. Default: *32768*.

**-l** *lineno*
  Only dump one line. This is exactly equivalent to "**-s** *lineno* **-e** *lineno*".

FORMATTING
==========
Every byte in the file is displayed in hex. However, they are grouped by line
and statement, and certain tokens get marker characters to help keep track
of what they're for. Strings are displayed in quotes, in both hex and ASCII. Floating
point constants are displayed as 6 hex bytes with square brackets around them.

Line Header Markers
-------------------
**@**
  Separates decimal line number from hex file offset.

**^**
  Prefix for line length.

**(** **)**
  Surrounds the 2 hex bytes for the line number.

Statement Markers
-----------------
**>**
  Prefix for next-statement offset. Every statement begins with this.

**!**
  Prefix for a command token. Every line of BASIC code begins with a
  command.

**:**
  Suffix for the *14* token; end of statement.

**#**
  Prefix for the *0e* token, which introduces a BCD floating point constant.

**[** **]**
  Surrounds the 6 bytes of a BCD floating point constant.

**$**
  Prefix for the *0f* token, which introduces a string constant.

**=**
  Prefix for the string-length byte of a string constant.

String Byte Markers
-------------------
**"**
  A string constant is surrounded by double-quotes.

**^**
  Prefix for a control character. For instance, *03* is displayed as *^C*.

**|**
  Prefix for an inverse video character. Example: *c1* (inverse video *A*)
  is displayed as *|A*. May be combined with *^*, for inverse control characters.

**/**
  Separates the printable ASCII representation of a character from its hex byte.
  Example: *A/41*.

Line header
-----------
Each line number begins with the line number (decimal) and offset from
the start of the file (hex), followed by the 2 hex bytes for the line
number in parentheses, followed by the line length (hex, preceded by
^). Example::

     10@0018 (0a 00): ^19

The line number is *10*, and the file offset is *0018*. The *0a 00*
are 10 again, in hex, LSB first. The *19* is the line length.

Statements
----------
Each statement within the line is displayed separately. For this line of code::

  10 ? "HELLO":A=1

The dump looks like::

   10@0018 (0a 00): ^19 
    >0d !28 $0f =05 "H/48 E/45 L/4c L/4c O/4f" 14:
    >19 !36 80 2d #0e [40 01 00 00 00 00] 16

The first line is the line header. The next two are the two
statements. The first one ends with token *14* (the end-of-statement
or tokenized colon) and the second ends with *16* (the end-of-line
token). The string *"HELLO"* is visible, and so is the floating point
constant *1*.

Long statements will wrap, if they're wider than the terminal. If this
is a problem, use a wider terminal, and/or pipe through a pager that
knows how to scroll horizontally.

EXIT STATUS
===========

0 for success, 1 for failure.

.. include:: manftr.rst