diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:33:54 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:33:54 +0100 |
commit | 2ab6a18d17e0f16f359feafc582f2ff732f34492 (patch) | |
tree | a14e83560b4b577313f9ef2fe3f9c0be5220ef0a /asm/asmpars.mly | |
parent | b2c5356b3f6d2e0a836a19b4cae1791d350785d3 (diff) | |
parent | e07508129a81605f77ee410ef4db104a96fc44bf (diff) | |
download | SystDigit-Projet-2ab6a18d17e0f16f359feafc582f2ff732f34492.tar.gz SystDigit-Projet-2ab6a18d17e0f16f359feafc582f2ff732f34492.zip |
Merge branch 'integration-progressive'
Conflicts:
asm/asm.ml
asm/asmlex.mll
asm/asmpars.mly
asm/assembler.ml
Diffstat (limited to 'asm/asmpars.mly')
-rw-r--r-- | asm/asmpars.mly | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/asm/asmpars.mly b/asm/asmpars.mly index ebc4ae7..8dbf665 100644 --- a/asm/asmpars.mly +++ b/asm/asmpars.mly @@ -15,7 +15,7 @@ let pc = ref 0 - let ram = ref 0x8000 + let ram = ref 0 let add r i = r := !r + i @@ -29,14 +29,8 @@ 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))]) | Lab id -> - add pc 4; [Lilz (r,Lab id); Liu (r,Labu id)] - | _ -> assert false + add pc 4; [Lilz (r,Lab id); Liu (r,Lab id)] - let up = function - | Imm i -> Imm i - | Lab l -> Labu l - | _ -> assert false - let explode s = (* string -> char list *) let rec exp i l = if i < 0 then l else exp (i - 1) (s.[i] :: l) in @@ -65,21 +59,18 @@ data: DATA d=datas* { d } datas: - | l=label_ram d=datas { d } + | labeld d=datas { d } | BYTE bs=int* { List.map (fun i -> add ram 1; i,false) bs } | WORD bs=int* { List.map (fun i -> add ram 2; i,true) bs } - | ASCIIZ s=STR { - add ram 1; - List.map (fun c -> add ram 1; Char.code c, false) (explode s) @ [0, false] - } - -label_ram: - id=ID COLON { lbls2 := Imap.add id !ram !lbls2; id } -label_pc: - id=ID COLON { lbls2 := Imap.add id !pc !lbls2; id } +labeli: + id=ID COLON { lbls2 := Imap.add id (!pc,true) !lbls2 } + +labeld: + id=ID COLON { lbls2 := Imap.add id (!ram,false) !lbls2 } + instr: - | l=label_pc i=instr { i } + | labeli i=instr { i } | i=_instr { i } _instr: |