summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-10 18:40:20 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-10 18:40:20 +0100
commit7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e (patch)
treec53c988a40486f4758f34fa76e011d21894cdcab
parent7a2e8c69cb4a4407261f11dd36374273d1fc5a28 (diff)
parentcc00abd9e33a00d3c7acfe310bf8d6522e9a1888 (diff)
downloadSystDigit-Projet-7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e.tar.gz
SystDigit-Projet-7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e.zip
Merge branch 'emile'
Conflicts: asm/asmpars.mly
-rw-r--r--asm/asmlex.mll3
-rw-r--r--asm/asmpars.mly26
-rw-r--r--cpu/os.asm4
3 files changed, 16 insertions, 17 deletions
diff --git a/asm/asmlex.mll b/asm/asmlex.mll
index 1f598e9..b2c7718 100644
--- a/asm/asmlex.mll
+++ b/asm/asmlex.mll
@@ -86,7 +86,7 @@ rule token = parse
| '#' { comment lexbuf }
| ['\t' '\r' ' '] { token lexbuf }
| ':' { COLON }
- | '\n' { Lexing.new_line lexbuf; token lexbuf }
+ | '\n' { Lexing.new_line lexbuf; NLB }
| ((['a'-'z'] | '_') (alpha | digit | '_')*) as id
{ try ROP (List.assoc id keywords_r)
with Not_found -> try RIOP (List.assoc id keywords_ri)
@@ -108,7 +108,6 @@ rule token = parse
| '(' { LP }
| ')' { RP }
| '"' { str [] lexbuf }
- |';' { SEMIC }
and str acc = parse
| "\\\\" { str ('\\' :: acc) lexbuf }
diff --git a/asm/asmpars.mly b/asm/asmpars.mly
index 258396e..c48c9ce 100644
--- a/asm/asmpars.mly
+++ b/asm/asmpars.mly
@@ -40,7 +40,7 @@
%}
-%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII,SEMIC
+%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII,NLB
%token POP,PUSH,INCRI,SHI,JJ,JAL,JR,JALR,LW,SW,LB,SB,NOT,LIL,LILZ,LIU,LIUZ,LRA,LI
%token<Asm.reg> REG
%token<Asm.fmt_r> ROP,RIOP
@@ -53,17 +53,17 @@
%%
program:
- TEXT is=instr* data? EOF
+ NLB* TEXT NLB* is=instr* data? EOF
{ { text = List.flatten is;
lbls = !lbls2 } }
data:
- DATA d=datas* { d }
-
+ DATA NLB* d=datas* { d }
+
datas:
- | labeld datas { () }
- | BYTE n=INT { add ram n }
- | WORD n=INT { add ram (2*n) }
+ | labeld NLB* datas { () }
+ | BYTE n=INT NLB+ { add ram n }
+ | WORD n=INT NLB+ { add ram (2*n) }
labeli:
id=ID COLON { lbls2 := Imap.add id (!pc,true) !lbls2 }
@@ -72,9 +72,9 @@ labeld:
id=ID COLON { lbls2 := Imap.add id (!ram,false) !lbls2 }
instr:
- | labeli i=instr { i }
- | i=_instr { i }
-
+ | labeli NLB* i=instr { i }
+ | i=_instr NLB+ { i }
+
_instr:
| o=ROP r1=REG r2=REG r3=REG { add pc 2; [R (o,r1,r2,r3)] }
| o=RIOP r1=REG r2=REG imm=imm
@@ -134,11 +134,11 @@ _instr:
add pc 2; l @ [R (Jner,5,r,0)] }
| POP r=REG { add pc 4; [Lw (r,7,0); Incri (7,2)] }
| PUSH r=REG { add pc 4; [Incri (7,-2); Sw (r,7,0)] }
- | BYTE bs=int+ SEMIC { List.map (fun b -> add pc 1; Byte b) bs }
- | WORD ws=imm+ SEMIC { List.map (fun w -> add pc 2; itw w) ws }
+ | BYTE bs=int+ { List.map (fun b -> add pc 1; Byte b) bs }
+ | WORD ws=imm+ { List.map (fun w -> add pc 2; itw w) ws }
| HLT { add pc 2; [Hlt] }
| ASCII s=STR { List.map (fun c -> add pc 1; Byte (Char.code c)) s }
-
+
imm:
| id=ID { Lab id }
| n=int { Imm n }
diff --git a/cpu/os.asm b/cpu/os.asm
index ff0fd60..1617d6b 100644
--- a/cpu/os.asm
+++ b/cpu/os.asm
@@ -225,9 +225,9 @@ error:
# For unit-tests
testlist:
- word unit_test_0 unit_test_1 unit_test_2 unit_test_3 0;
+ word unit_test_0 unit_test_1 unit_test_2 unit_test_3 0
teststr:
- word test0 test1 test2 test3 0;
+ word test0 test1 test2 test3 0
testbegin:
ascii "Runing CPU unit tests...\n"
testok: