This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* the memory is in an array Mem, which is of type int[] or char[] or something */ | |
Mem[B] -= Mem[A]; | |
if (Mem[B] <= 0) goto C; | |
else goto (IP + 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (A < 0) A = Mem[-A]; /* treat negative numbers as pointers-to-pointers */ | |
if (B < 0) B = Mem[-B]; | |
if (C < 0) C = Mem[-C]; | |
Mem[B] -= Mem[A]; /* as before, using the maybe-adjusted A, B, and C */ | |
if (Mem[B] <= 0) goto C; | |
else goto (IP + 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn subleq | |
([in out mem regs] ; in this case data and program memory are the same | |
(apply subleq in out mem regs (subvec mem (:ip regs) (+ 3 (:ip regs))))) | |
([in out mem regs a b c] | |
(let [a-ind (if (neg? a) (nth mem (- a)) a) | |
b-ind (if (neg? b) (nth mem (- b)) b) | |
c-ind (if (neg? c) (nth mem (- c)) c) | |
mem (assoc mem b-ind | |
(- (mem b-ind) (mem a-ind)))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; First example: | |
Clojure=> (subleq 3 4 [5 8 12 0 0 42 0 0 144 1 2 3 4 5 6 7] {:ip 0}) ; here x = 42 and y = 144 | |
[[5 8 12 0 0 42 0 0 102 1 2 3 4 5 6 7] {:out false, :in false, :ip 3}] | |
; Mem[A] has been subtracted from Mem[B], but Mem[B] is 102 so we do not jump to C | |
Clojure=> (subleq 3 4 [5 8 12 0 0 144 0 0 42 1 2 3 4 5 6 7] {:ip 0}) ; now switch Mem[A] and Mem[B] | |
[[5 8 12 0 0 144 0 0 -102 1 2 3 4 5 6 7] {:out false, :in false, :ip 12}] | |
;; Second example, with a negative operand: | |
Clojure=> (subleq 3 4 [5 8 -12 0 0 42 0 0 144 1 2 3 14 5 6 7] {:ip 0}) | |
[[5 8 -12 0 0 42 0 0 102 1 2 3 14 5 6 7] {:out false, :in false, :ip 3}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn drive-subleq | |
"Runs an OISC SUBLEQ program. Given the program (as a list of integers) and the input (in the same way), it runs the program and returns the output." | |
[program input] | |
(let [-out- (count program) | |
-in- (inc -out-) | |
input-len (count input)] | |
(loop [mem (vec (concat program | |
[0 (if (zero? input-len) -1 (nth input 0))] ; fill in the first char of the input now, unless there is no input, in which case give EOF right away | |
(vec (range 0 1023)))) ; memory starts out as the program, then the special output cell, then the special input cell, followed by 1024 memory cells filled with the numbers from 0 to 1023 | |
regs {:ip 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clojure=> (drive-subleq [85 20 3, 20 18 6, 20 20 9, 19 20 12, 20 79 15, 79 19 18] "") | |
["A" 58] ; cool! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<item> | |
<name>LaTeX Keyboard</name> | |
<appendix>With Control_L as a modifier, overlay all the alphabetic keys with characters useful for LaTeX (and programming in general).</appendix> | |
<identifier>private.latex_keyboard</identifier> | |
<!-- the basic trick: CONTROL_L+key => CONTROL_R+key, but CONTROL_L => ESCAPE --> | |
<autogen>--KeyOverlaidModifier-- KeyCode::CONTROL_L, KeyCode::CONTROL_R, KeyCode::ESCAPE</autogen> | |
<autogen>--KeyToKey-- KeyCode::OPTION_L, KeyCode::CONTROL_L</autogen> | |
<!-- keys from http://www.autohotkey.com/community/viewtopic.php?t=18536 --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alex$ make | |
Generating dependencies hello_world.d from hello_world.c | |
Compiling hello_world.c | |
Linking hello_world.elf | |
>>>> Size of Firmware <<<< | |
text data bss dec hex filename | |
316 50 0 366 16e hello_world.elf | |
unix2dos: converting file hello_world.txt to DOS format ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class Mspdebug < Formula | |
homepage 'http://mspdebug.sourceforge.net/' | |
url 'http://sourceforge.net/projects/mspdebug/files/mspdebug-0.20.tar.gz' | |
sha1 'ddf589e6e15c2577fc132001f757113309e134e9' | |
head 'git://mspdebug.git.sourceforge.net/gitroot/mspdebug/mspdebug' | |
depends_on 'libusb-compat' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function t = T(params) | |
d = length(params); | |
t = eye(d+1); | |
if isa(params, 'sym') | |
t = sym(t); | |
end | |
t(1:d,d+1) = params; | |
end |
OlderNewer