Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move comments to defmethod docstrings

  • Loading branch information...
commit e7e7df498e7924458a5232ac0e415a8f8c1a6f34 1 parent 1e3936c
Devin Walters authored April 10, 2012

Showing 1 changed file with 16 additions and 16 deletions. Show diff stats Hide diff stats

  1. 32  src/clj_dcpu16/core.clj
32  src/clj_dcpu16/core.clj
@@ -139,21 +139,21 @@
139 139
 
140 140
 (defmulti execute get-o)
141 141
 
142  
-;;Special OP Codes *currently only JMP*
143 142
 (defmethod execute 0x0 [word]
  143
+  "Special OP codes *currently only JMP*"
144 144
   (if (= 1 (get-a word))
145 145
     (let [[a b out] (process word)]
146 146
       (change-memory :push (bit-and 0xFFFF (inc (get-memory :pc))))
147 147
       (change-memory :pc b))))
148 148
 
149  
-;; SET a to b
150 149
 (defmethod execute 0x1 [word]
  150
+  "SET a to b"
151 151
   (let [[a b out] (process word)]
152 152
     (change-memory out b)
153 153
     (if-not (= out :pc) (inc-memory :pc))))
154 154
 
155  
-;; ADD a to b
156 155
 (defmethod execute 0x2 [word]
  156
+  "ADD a to b"
157 157
   (let [[a b out] (process word)]
158 158
     (if (> 0xFFFF (+ a b))
159 159
       (change-memory :o 1)
@@ -161,8 +161,8 @@
161 161
     (change-memory out (bit-and 0xFFFF (+ a b)))
162 162
     (inc-memory :pc)))
163 163
 
164  
-;; SUB a from b
165 164
 (defmethod execute 0x3 [word]
  165
+  "SUB a from b"
166 166
   (let [[a b out] (process word)]
167 167
     (if (pos? (- a b))
168 168
       (change-memory :o 0xFFFF)
@@ -170,56 +170,56 @@
170 170
     (change-memory out (bit-and 0xFFFF (- a b)))
171 171
     (inc-memory :pc)))
172 172
 
173  
-;; MUL a = a * b
174 173
 (defmethod execute 0x4 [word]
  174
+  "MUL a = a * b"
175 175
   (let [[a b out] (process word)]
176 176
     (change-memory :o (bit-and 0xFFFF (bit-shift-right (* a b) 16)))
177 177
     (change-memory out (bit-and 0xFFFF (* a b)))
178 178
     (inc-memory :pc)))
179 179
 
180  
-;; DIV a = a / b
181 180
 (defmethod execute 0x5 [word]
  181
+  "DIV a = a / b"
182 182
   (let [[a b out] (process word)]
183 183
     (change-memory :o (bit-and 0xFFFF (/ (bit-shift-right a 16) b)))
184 184
     (change-memory out (bit-and 0xFFFF (/ a b)))
185 185
     (inc-memory :pc)))
186 186
 
187  
-;; MOD a = a % b
188 187
 (defmethod execute 0x6 [word]
  188
+  "MOD a = a % b"
189 189
   (let [[a b out] (process word)]
190 190
     (if (zero? b)
191 191
       (change-memory out 0)
192 192
       (change-memory out (bit-and 0xFFFF (mod a b))))
193 193
     (inc-memory :pc)))
194 194
 
195  
-;; SHL a = a << b
196 195
 (defmethod execute 0x7 [word]
  196
+  "SHL a = a << b"
197 197
   (let [[a b out] (process word)]
198 198
     (change-memory :o (bit-and 0xFFFF (bit-shift-right (bit-shift-left a b) 16)))
199 199
     (change-memory out (bit-and 0xFFFF (bit-shift-left a b)))
200 200
     (inc-memory :pc)))
201 201
 
202  
-;; SHR a = a >> b
203 202
 (defmethod execute 0x8 [word]
  203
+  "SHR a = a >> b"
204 204
   (let [[a b out] (process word)]
205 205
     (change-memory :o (bit-and 0xFFFF (bit-shift-right (bit-shift-left a 16) b)))
206 206
     (change-memory out (bit-and 0xFFFF (bit-shift-right a b)))
207 207
     (inc-memory :pc)))
208 208
 
209  
-;; AND a = a & b
210 209
 (defmethod execute 0x9 [word]
  210
+  "AND a = a & b"
211 211
   (let [[a b out] (process word)]
212 212
     (change-memory out (bit-and a b))
213 213
     (inc-memory :pc)))
214 214
 
215  
-;; BOR a = a | b
216 215
 (defmethod execute 0xa [word]
  216
+  "BOR a = a | b"
217 217
   (let [[a b out] (process word)]
218 218
     (change-memory out (bit-or a b))
219 219
     (inc-memory :pc)))
220 220
 
221  
-;; XOR a = a ^ b
222 221
 (defmethod execute 0xb [word]
  222
+  "XOR a = a ^ b"
223 223
   (let [[a b out] (process word)]
224 224
     (change-memory out (bit-xor a b))
225 225
     (inc-memory :pc)))
@@ -232,23 +232,23 @@
232 232
     (change-memory :pc (let [pc (get-memory :pc)]
233 233
                          (+ pc 1 (op-size (get-memory (inc pc))))))))
234 234
 
235  
-;; IFE execute next instruction iff a==b
236 235
 (defmethod execute 0xc [word]
  236
+  "IFE execute next instruction iff a==b"
237 237
   (let [[a b out] (process word)]
238 238
     (perform-branch (= a b))))
239 239
 
240  
-;; IFN execute next instruction iff a!=b
241 240
 (defmethod execute 0xd [word]
  241
+  "IFN execute next instruct iff a!=b"
242 242
   (let [[a b out] (process word)]
243 243
     (perform-branch (not= a b))))
244 244
 
245  
-;; IFG execute next instruction iff a>b
246 245
 (defmethod execute 0xe [word]
  246
+  "IFG execute next instruction iff a>b"
247 247
   (let [[a b out] (process word)]
248 248
     (perform-branch (> a b))))
249 249
 
250  
-;; IFB execute next instruction iff (a&b)!= 0
251 250
 (defmethod execute 0xf [word]
  251
+  "IFB execute next instruction iff (a&b)!=0"
252 252
   (let [[a b out] (process word)]
253 253
     (perform-branch (not= 0 (bit-and a b)))))
254 254
 

0 notes on commit e7e7df4

Please sign in to comment.
Something went wrong with that request. Please try again.