Skip to content

Commit 15c66e9

Browse files
committed
Detect overwriting a non-zero value; optionally suppress the check.
* src/aes.adb: add -z/--overwrite-nonzero option, save to Store. * src/analytical_engine-card.ads (Image): new. * src/analytical_engine-card.adb: likewise. (Zero): deleted. (Execute(Variable_Card)): use new version of Store.Get. (Image): new. * src/analytical_engine-card_reader.adb (Execute): name the loop Execution. Use Card.Image instead of d.i.y. Catch and report exceptions. * src/analytical_engine-store.ads (Allow_Overwrite_Nonzero): new. (Get): new parameter Preserve. (Store_Error): new. * src/analytical_engine-store.adb (Zero): new. (Overwrite_Nonzero_Allowed): new. (Allow_Overwrite_Nonzero): new. (Set): if required, check for overwriting non-zero column, raise Store_Error if so. (Get): handle new Preserve parameter; if tracing, report if column has been zeroed; if not set, set the column to zero. * bernouilli.ae: load-and-zero where required (Z instead of L). * bernouilli5.ae: likewise. * README.md: updated.
1 parent 5f2e1fd commit 15c66e9

9 files changed

+175
-94
lines changed

README.md

+35-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ The Ada emulator is written using [Ada2012][], and uses the
3232
[GMP binding in GNATCOLL][].
3333

3434
If you have the [FSF GCC 6.1.0 binary for OS X][] a suitable library
35-
is provided. GMP and GNATCOLL are reasonably straightforward to build.
35+
is provided. Otherwise, GMP and GNATCOLL are reasonably
36+
straightforward to build.
3637

3738
[Ada2012]: http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-TOC.html
3839

@@ -42,6 +43,32 @@ is provided. GMP and GNATCOLL are reasonably straightforward to build.
4243

4344
[FSF GCC 6.1.0 binary for OS X]: https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/6.1.0/
4445

46+
## Running
47+
48+
There are three switches:
49+
50+
* `-h` or `--help`: outputs help.
51+
* `-t` or `--trace`: trace execution (like card T1)
52+
* `-z` or `--overwrite-nonzero`: allow storing to a non-zero column
53+
54+
and, as usual, run by
55+
56+
./aes [switches] [card-chain-file]
57+
58+
(uses standard input if no card chain file is supplied).
59+
60+
The "storing to a non-zero column" issue is referenced in [this paper][]
61+
by Rainer Glaschick, section 3.5, Memory peculiarities. It would have
62+
been necessary to ensure that a column that was to be written to was
63+
zero beforehand; the operation of storing a value involved racks
64+
transferring the value on the source to the destination as the source
65+
digits were rotated back to zeros.
66+
67+
If `-z` is given, overwriting will be allowed; otherwise, an error
68+
will be reported ane exceution will halt.
69+
70+
[this paper]: http://rclab.de/rclab/_media/analyticalengine/aal_noteg_glaschick_v1.2.pdf
71+
4572
## Programming Cards
4673

4774
The design here is as in the [Fourmilab Java implementation][]. To
@@ -118,12 +145,13 @@ The [Deep Learning with the Analytical Engine][] project, with the
118145
> sufficiently long).
119146
120147
The program consists of over 400,000 cards! (it was generated by
121-
Python scripts from a high-level description). As a timing test, the
122-
program was run for the first 10 images only: in Java, this took 18
123-
seconds, of which 10 seconds was initial processing, in Ada (where the
124-
initial processing was about a second) with `-O0 -gnata` 44 seconds,
125-
with `-O2 -gnatp` 22 seconds. So the Ada implementation is about 3
126-
times slower than the Java one. More work to be done!
148+
Python scripts from a high-level description). It requires `-z` to
149+
run. As a timing test, the program was run for the first 10 images
150+
only: in Java, this took 18 seconds, of which 10 seconds was initial
151+
processing, in Ada (where the initial processing was about a second)
152+
with `-O0 -gnata` 44 seconds, with `-O2 -gnatp` 22 seconds. So the Ada
153+
implementation is about 3 times slower than the Java one. More work to
154+
be done!
127155

128156
[Deep Learning with the Analytical Engine]: https://cp4space.wordpress.com/2016/02/06/deep-learning-with-the-analytical-engine/
129157
[Deep Learning with the Analytical Engine repository]: https://gitlab.com/apgoucher/DLAE

bernouilli.ae

+30-30
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
A bug in operation 4 has been fixed (the comment requires V4/V5,
1111
AAL's code does V5/V4).
1212

13-
Another bug is at operation 24: the value accumulated in V13 is *the
13+
Another bug was at operation 24: the value accumulated in V13 is *the
1414
negative* of the required value, see Note G Equation 9.
1515

1616
useful constants
@@ -38,13 +38,13 @@ s006
3838

3939
operation 2
4040
-
41-
l004
41+
z004
4242
l001
4343
s004
4444

4545
operation 3
4646
+
47-
l005
47+
z005
4848
l001
4949
s005
5050

@@ -57,13 +57,13 @@ s011'
5757

5858
operation 5
5959
/
60-
l011
60+
z011
6161
l002
6262
s011'
6363

6464
operation 6
6565
-
66-
l013
66+
z013
6767
z011
6868
s013
6969

@@ -85,7 +85,7 @@ l006
8585
l007
8686
s011'
8787

88-
operation 10
88+
operation 10, using b1 (v021)
8989
*
9090
l021
9191
l011
@@ -95,25 +95,25 @@ s012
9595
operation 11
9696
+
9797
z012
98-
l013
98+
z013
9999
s013
100100

101101
operation 12
102102
-
103-
l010
103+
z010
104104
l001
105105
s010
106106
--------------------
107107
operation 13
108108
-
109-
l006
109+
z006
110110
l001
111111
s006
112112

113113
operation 14
114114
+
115115
l001
116-
l007
116+
z007
117117
s007
118118

119119
operation 15
@@ -126,20 +126,20 @@ s008'
126126
operation 16
127127
*
128128
z008
129-
l011
129+
z011
130130
>10
131131
s011
132132

133133
operation 17
134134
-
135-
l006
135+
z006
136136
l001
137137
s006
138138

139139
operation 18
140140
+
141141
l001
142-
l007
142+
z007
143143
s007
144144

145145
operation 19
@@ -152,11 +152,11 @@ s009'
152152
operation 20
153153
*
154154
z009
155-
l011
155+
z011
156156
>10
157157
s011
158158

159-
operation 21
159+
operation 21, using b3 (v022)
160160
*
161161
l022
162162
l011
@@ -166,25 +166,25 @@ s012
166166
operation 22
167167
+
168168
z012
169-
l013
169+
z013
170170
s013
171171

172172
operation 23
173173
-
174-
l010
174+
z010
175175
l001
176176
s010
177177
.................... repeat starts here
178178
operation 13
179179
-
180-
l006
180+
z006
181181
l001
182182
s006
183183

184184
operation 14
185185
+
186186
l001
187-
l007
187+
z007
188188
s007
189189

190190
operation 15
@@ -197,20 +197,20 @@ s008'
197197
operation 16
198198
*
199199
z008
200-
l011
200+
z011
201201
>10
202202
s011
203203

204204
operation 17
205205
-
206-
l006
206+
z006
207207
l001
208208
s006
209209

210210
operation 18
211211
+
212212
l001
213-
l007
213+
z007
214214
s007
215215

216216
operation 19
@@ -223,11 +223,11 @@ s009'
223223
operation 20
224224
*
225225
z009
226-
l011
226+
z011
227227
>10
228228
s011
229229

230-
operation 21 (NB using v023 this time)
230+
operation 21 (NB using b5, v023 this time)
231231
*
232232
l023
233233
l011
@@ -237,12 +237,12 @@ s012
237237
operation 22
238238
+
239239
z012
240-
l013
240+
z013
241241
s013
242242

243243
operation 23
244244
-
245-
l010
245+
z010
246246
l001
247247
s010
248248
--------------------
@@ -257,8 +257,8 @@ p
257257
operation 25
258258
+
259259
l001
260-
l003
260+
z003
261261
s003
262-
-- and clear V6, V7
263-
n006 0
264-
n007 0
262+
-- and clear V6, V7 (should have been done earlier, operation 19)
263+
n006 0
264+
n007 0

0 commit comments

Comments
 (0)