-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheditor.htm
224 lines (223 loc) · 12.7 KB
/
editor.htm
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>editor</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="/G-Pascal/G-Pascal.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header id="title-block-header">
<h1 class="title">G-Pascal Editor</h1>
</header>
<p><strong>Author</strong>: Nick Gammon</p>
<p><strong>Date</strong>: February 2022</p>
<div class="quick_link">
<a href="index.htm">Back to main G-Pascal page</a>
</div>
<div class="quick_link">
<a href="file_menu.htm">Loading and saving</a>
</div>
<div class="quick_link">
<a href="pascal_compiler.htm">G-Pascal info</a>
</div>
<div class="quick_link">
<a href="assembler.htm">Assembler info</a>
</div>
<ul>
<li><a href="#syntax">Editor commands</a></li>
<li><a href="#delete">Delete</a></li>
<li><a href="#find">Find</a></li>
<li><a href="#insert">Insert</a></li>
<li><a href="#list">List</a></li>
<li><a href="#load">Load</a></li>
<li><a href="#replace">Replace</a></li>
<li><a href="#save">Save</a></li>
<li><a href="#memory">Memory</a></li>
<li><a href="#recommendations">Recommendations</a></li>
<li><a href="#info">Info</a></li>
<li><a href="#library">Library</a></li>
<li><a href="#run">Run / Debug / Trace / Resume</a></li>
<li><a href="#poke">Poke / JSR / JMP</a></li>
</ul>
<p>The inbuilt text editor is designed to allow you to try out small programs, and make modifications “on the fly” without having to download or upload code from your “main” computer.</p>
<p>In order to see what you are typing you must enable “local echo” on your terminal program. In the case of miniterm you use the “-e” command-line flag to do that.</p>
<hr />
<h2 id="syntax">Editor commands</h2>
<p>The editor is available from the main “shell” prompt. Type <strong>H</strong> to see a list of editor commands:</p>
<pre><code>Available actions:
Delete line_number_range
Insert/LOad after_line
Find line_number_range /target/flags
List/SAve line_number_range
Replace line_number_range /target/replacement/flags
RECover
---
Help
INFo
Memory first_address last_address
Assemble
Compile/Syntax
DEBug/Trace
LIBrary
Poke/Jsr/JMp
RUn
RESume
(Actions may be abbreviated)
(Flags: 'I'gnore case, 'G'lobal, 'Q'uiet)</code></pre>
<p>You can assemble, compile (Pascal) or do a (Pascal) syntax check directly from the prompt (type <strong>A</strong>, <strong>C</strong> or <strong>S</strong>).</p>
<p>The editor is line-based with each line having a number, automatically assigned. These numbers can be used to delete, insert, list, load, find or replace. You need to press ENTER to have a command processed. Make sure you have enabled “local echo” in your terminal program (eg. miniterm) so that you can see your typing.</p>
<p>Commands have a line number range (if omitted, they affect all lines). For example to list lines 1 to 10:</p>
<pre><code>L1-10</code></pre>
<p>You may put spaces after the action, and between the line numbers if giving a range. You can also use a hyphen or comma to separate line numbers, e.g.</p>
<pre><code>LIST 1-10
LIST 1 10
LIST 1, 10</code></pre>
<ul>
<li>Actions may be abbreviated. The minimal amount to type is in upper case, so “L” would be LIST and not LOAD, and “S” would be SYNTAX and not SAVE.</li>
<li>As a shortcut, the command R on its own will be interpreted as Run (not Replace) as Replace would always need a delimiter after it.</li>
<li>The word “end” may be used in cases where you want the highest possible number, for example: “DELETE 100-end” to delete from line 100 onwards.</li>
</ul>
<hr />
<h2 id="delete">Delete</h2>
<p>Use DELETE to delete a range of lines (you cannot use DELETE on its own to delete the entire source). If you want to delete <em>everything</em> type “delete all” (or “del all”).</p>
<hr />
<h2 id="find">Find</h2>
<p>Use FIND to find a string. The string delimiter can be any single character which is not a letter, number or space. This is intended to help you find lines with certain words on them. For example:</p>
<pre><code>F .procedure.</code></pre>
<p>The matching lines will be shown, with their line numbers, so you could do a List of around that spot.</p>
<p>You may put options after the second delimiter as follows:</p>
<ul>
<li>G - global: find multiple occurrences on one line (this affects the number of matches reported)</li>
<li>I - ignore case: match on both upper and lower-case versions of the target string</li>
<li>Q - quiet: do not show matching lines, just show the count of matches</li>
</ul>
<p>For example:</p>
<pre><code>F 1, 100 /begin/giq</code></pre>
<p>That would search for “begin” between lines 1 and 100, and report on the number of occurrences, case insensitive. The lines would not be listed.</p>
<pre><code>F 20 - 999 /begin/</code></pre>
<p>That would list all lines with “begin” on them between lines 20 and 999 (or the end of the file, whichever came sooner).</p>
<hr />
<h2 id="insert">Insert</h2>
<p>Use INSERT to insert new lines. Use <strong>I</strong> on its own to insert right at the start of the source. Otherwise if you give a line number the inserted lines will appear after that line. To cancel inserting, press <strong>Esc</strong>.</p>
<p><strong>WARNING</strong>: If you attempt to insert multiple lines very quickly your source will be corrupted. In particular, this will happen if you go into Insert mode and then paste a whole lot of text from your PC. The reason for this is that displaying the line numbers takes quite a few calculations (binary to decimal conversion), which take time.</p>
<p>If you are planning to “paste” your source onto the board, use LOAD and “Load” it. This inserts source without displaying the line numbers.</p>
<hr />
<h2 id="list">List</h2>
<p>Use LIST on its own to list the entire source. Otherwise list one line or a range, for example:</p>
<pre><code>L
L42
L50-60</code></pre>
<p>As an alternative, for exporting your file back to your PC/Mac, use SAVE to save the source. This lists it without line numbers, suitable for copying from your terminal program and pasting back into a text editor on your PC.</p>
<p>Press Ctrl+C to abort a long listing.</p>
<p>Control characters in the source are shown with a carat before them. For example if you had 0x01 in your source it would show as ^A if you listed it.</p>
<hr />
<h2 id="load">Load</h2>
<p>This functions similarly to INSERT, however a line number is not displayed before each line of text. This saves time (converting binary to decimal is time-consuming) and is required if you are planning to paste code from your PC onto the board.</p>
<p>Typically you would:</p>
<ul>
<li>Type “DEL ALL” (to delete existing source)</li>
<li>Type “LOAD”.</li>
<li>Paste your source from your PC</li>
<li>Press <strong>Esc</strong> (escape) to stop the loading process.</li>
</ul>
<p>You may also want to compare the CRC of the loaded source with the CRC of your source file on your PC.</p>
<p>See <a href="file_menu.htm">Loading and saving</a> for more details about loading, saving, and calculating file cyclic redundancy checks (CRCs).</p>
<hr />
<h2 id="replace">Replace</h2>
<p>This lets you replace one string with another, either in a range of lines or the whole source. You might want to rename a variable with this, for example. You need to specify the “find” string and the “replace” string, separated by a delimiter of your choice. The string delimiter can be any single character which is not a letter, number or space.</p>
<p>There are options you can place after the third delimiter:</p>
<ul>
<li>G - global: find and replace multiple occurrences on one line</li>
<li>I - ignore case: match on both upper and lower-case versions of the target string</li>
<li>Q - quiet: do not show matching lines, just show the count of matches</li>
</ul>
<p>For example:</p>
<pre><code>R .fish.chips.g
R 1-20 /dog/cat/ i</code></pre>
<hr />
<h2 id="memory">Memory</h2>
<p>This lets you view any part of your RAM or ROM memory. You enter a start and end address, and the bytes in that range are displayed in hex, and also bytes in the range 0x20 to 0x7F are also displayed in ASCII on the right. eg.</p>
<pre><code>: mem $300 $31f
$0300: 7b 20 41 64 76 65 6e 74 75 72 65 2d 73 74 79 6c { A d v e n t u r e - s t y l
$0310: 65 20 67 61 6d 65 0a 20 20 41 75 74 68 6f 72 3a e g a m e . A u t h o r :</code></pre>
<p>Press Ctrl+C to abort a long listing.</p>
<hr />
<h2 id="save">Save</h2>
<p>This lists your source, similarly to LIST, however without line numbers. This is useful for just getting an exact copy of your source which you can then copy from the screen of your terminal program and paste into a text editor on your PC, for saving to disk.</p>
<p>See <a href="file_menu.htm">Loading and saving</a> for more details about loading, saving, and calculating file cyclic redundancy checks (CRCs).</p>
<hr />
<h2 id="recommendations">Recommendations</h2>
<p>For large-scale changes I suggest keeping a copy of your source on your PC (you need to do this anyway as the board does not have file saving capability). For anything other than small one or two-line changes, it will be quicker and easier to change the source on your PC, and re-download it, rather than fiddling around in the Editor.</p>
<p>The editor does not support cursor keys, so it is not the easiest editor to work with, particularly compared to modern editors available on PC/Macs.</p>
<p>Keeping your original source elsewhere also protects you against rogue code which might overwrite your source, as there is no memory-protection hardware on these chips.</p>
<hr />
<h2 id="info">Info</h2>
<p>Typing INFO will tell you various things about your source file, for example:</p>
<pre><code>Source starts at $0300
Source ends at $3a63
Source lines: 645
Source length: 14178 bytes
Source CRC $efdf</code></pre>
<p>For more information about the CRC value see the <a href="file_menu.htm">Loading and saving</a> page.</p>
<hr />
<h2 id="library">Library</h2>
<p>This lists all of the inbuilt assembler library function addresses, and also relevant zero-page address variables. For example:</p>
<pre><code>: library
$0060 bcd_result
$945f binary_to_decimal
$0010 call_a
$0013 call_p
$0014 call_s
$0011 call_x
$0012 call_y
...
$caa6 write_char
$0017 write_function
$ca97 write_to_lcd
$ca8c write_to_serial</code></pre>
<p>Note that the addresses shown will probably be different in your version, as they will change as more things are added to the system.</p>
<p>You can also supply a “filter” word, to narrow down the search to symbols matching that (partial) word, for example:</p>
<pre><code>: lib spi
$d243 spi_init
$d2ed spi_send_two_bytes
$d2e5 spi_ss_high
$d2dd spi_ss_low
$d279 spi_transfer</code></pre>
<p>You could also use this to jog your memory about the exact function name spelling, as in the example above for the SPI functions.</p>
<hr />
<h2 id="run">Run / Debug / Trace / Resume</h2>
<p>These are for executing your program in various ways.</p>
<h3 id="run-1">Run</h3>
<p>This runs (executes) the most recently-compiled code. The system automatically knows if you did a compile (Pascal) or an assemble (Assembler) and executes your code appropriately.</p>
<h3 id="debug">Debug</h3>
<p>As described on <a href="pascal_compiler.htm">the Pascal information page</a> you can debug your Pascal code, which shows the P-code address, the current P-code being executed, and the base and stack frame information.</p>
<h3 id="trace">Trace</h3>
<p>As described on <a href="pascal_compiler.htm">the Pascal information page</a> you can trace your Pascal code, which shows the P-code address, and the current P-code being executed.</p>
<h3 id="resume">Resume</h3>
<p>As described on <a href="assembler.htm">the Assembler information page</a> this resumes execution from a current breakpoint (placed by inserting a BRK instruction in your code).</p>
<hr />
<h2 id="poke">Poke / JSR / JMP</h2>
<p>These debugging techniqes are described on <a href="assembler.htm">the Assembler information page</a>.</p>
<hr />
<div class="quick_link">
<a href="index.htm">Back to main G-Pascal page</a>
</div>
<div class="quick_link">
<a href="file_menu.htm">Loading and saving</a>
</div>
<hr />
<h2 id="license">License</h2>
<p>Information and images on this site are licensed under the <a href="https://creativecommons.org/licenses/by/3.0/au/">Creative Commons Attribution 3.0 Australia License</a> unless stated otherwise.</p>
</body>
</html>