diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 16:56:20 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 16:56:20 +0100 |
commit | 70a040d0c327ef1fa8fa73da70f245dedbf8bf2e (patch) | |
tree | c17ff1a97e7126194b5ba6081aeb353435d54cd3 /asm/asmpars.mly | |
parent | 6de7ebfc3fa320b639a292a174f213005d5ce2c2 (diff) | |
parent | b840059a7f2fb0e3796414f30f1e241d03b44dbf (diff) | |
download | SystDigit-Projet-70a040d0c327ef1fa8fa73da70f245dedbf8bf2e.tar.gz SystDigit-Projet-70a040d0c327ef1fa8fa73da70f245dedbf8bf2e.zip |
Merge branch 'emile'
Diffstat (limited to 'asm/asmpars.mly')
-rw-r--r-- | asm/asmpars.mly | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/asm/asmpars.mly b/asm/asmpars.mly index 4850c55..258396e 100644 --- a/asm/asmpars.mly +++ b/asm/asmpars.mly @@ -23,17 +23,24 @@ let li u r = function | Imm i -> - let c = - if u then i < 1 lsl 8 - else i >= -(1 lsl 7) && i < 1 lsl 7 in - if c then (add pc 2; [Lilz (r,Imm i)]) - else (add pc 4; [Lilz (r,Imm (i land 0x00FF)); Liu (r,Imm ((i land 0xFF00) lsr 8))]) + if u then + if i < 1 lsl 8 then (add pc 2; [Lilz (r,Imm i)]) + else (add pc 4; [Lil (r,Imm (i land 0x00FF)); Liu (r,Imm ((i land 0xFF00) lsr 8))]) + else if i >=0 && i < 1 lsl 7 then + (add pc 2; [Lilz (r,Imm i)]) + else if i < 0 && i >= - ( 1 lsl 7 ) then + (add pc 4; [Lil (r,Imm i); Liu (r,Imm 0xFF)]) + else (add pc 4; [Lil (r,Imm (i land 0x00FF)); Liu (r,Imm ((i land 0xFF00) asr 8))]) | Lab id -> add pc 4; [Lilz (r,Lab id); Liu (r,Lab id)] + + let itw = function + | Imm i -> Word i + | Lab l -> Wlab l %} -%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII +%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII,SEMIC %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 @@ -127,8 +134,8 @@ _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* { List.map (fun b -> add pc 1; Byte b) bs } - | WORD ws=int* { List.map (fun w -> add pc 2; Word w) ws } + | 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 } | HLT { add pc 2; [Hlt] } | ASCII s=STR { List.map (fun c -> add pc 1; Byte (Char.code c)) s } |