diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:10:01 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:10:01 +0100 |
commit | b2c5356b3f6d2e0a836a19b4cae1791d350785d3 (patch) | |
tree | c84011df6867b5fa9e4c211f300dbc0421683f93 /asm | |
parent | fb4a33dfbbfd3d85e3ecee65bdee36b12c4f9937 (diff) | |
download | SystDigit-Projet-b2c5356b3f6d2e0a836a19b4cae1791d350785d3.tar.gz SystDigit-Projet-b2c5356b3f6d2e0a836a19b4cae1791d350785d3.zip |
Assembler kind of works ; created simple assembly program that prints Tick! every second.
Diffstat (limited to 'asm')
-rw-r--r-- | asm/asmlex.mll | 4 | ||||
-rw-r--r-- | asm/assembler.ml | 2 | ||||
-rw-r--r-- | asm/test.asm | 8 |
3 files changed, 8 insertions, 6 deletions
diff --git a/asm/asmlex.mll b/asm/asmlex.mll index 98caa26..726b732 100644 --- a/asm/asmlex.mll +++ b/asm/asmlex.mll @@ -53,8 +53,8 @@ let v = let c = Char.code n.[i] in if c >= Char.code '0' && c <= Char.code '9' then c - (Char.code '0') - else if c >= Char.code 'a' && c <= Char.code 'f' then c - (Char.code 'a') - else c - (Char.code 'A') in + else if c >= Char.code 'a' && c <= Char.code 'f' then c - (Char.code 'a') + 10 + else c - (Char.code 'A') + 10 in res := !res + v done; !res diff --git a/asm/assembler.ml b/asm/assembler.ml index 2c91366..1158181 100644 --- a/asm/assembler.ml +++ b/asm/assembler.ml @@ -108,7 +108,7 @@ let print_program p = sprintf "liu %s %s" (rts r) (its i) | Liuz (r,i) -> (0b11011 lsl 11) lxor (r lsl 8) lxor (value i land 0xFF), sprintf "liuz %s %s" (rts r) (its i) - | TwoRawBytes(a, b) -> (a lsl 8) lxor b, sprintf "bytes %d %d" a b + | TwoRawBytes(a, b) -> (a) lxor (b lsl 8), sprintf "bytes %d %d" a b in let n = List.length p.text in let rev_lbls = Array.make n "" in diff --git a/asm/test.asm b/asm/test.asm index 2597f1f..d37ca61 100644 --- a/asm/test.asm +++ b/asm/test.asm @@ -4,6 +4,7 @@ init: liuz B 0x40 lw B 0(B) + jz B init add D D B push D la A msgtick @@ -12,13 +13,14 @@ init: j init ser_out_msg: - lb B 0(A) - jz B ser_out_msg_ret liuz C 0x41 lil C 0x02 +ser_out_msg_loop: + lb B 0(A) + jz B ser_out_msg_ret sb B 0(C) incri A 1 - j ser_out_msg + j ser_out_msg_loop ser_out_msg_ret: jr RA |