diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:20:58 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-08 18:20:58 +0100 |
commit | 91bc6bd5554bb4267cbaf147e603791e50462242 (patch) | |
tree | cc6583bc0e334840ee23e45ef620925b38eb6db1 /asm/asmpars.mly | |
parent | fa2e69bf68346d653d194d863c019674ea0fd7e2 (diff) | |
download | SystDigit-Projet-91bc6bd5554bb4267cbaf147e603791e50462242.tar.gz SystDigit-Projet-91bc6bd5554bb4267cbaf147e603791e50462242.zip |
2e mail Emile
Diffstat (limited to 'asm/asmpars.mly')
-rw-r--r-- | asm/asmpars.mly | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/asm/asmpars.mly b/asm/asmpars.mly index c8f3944..294374a 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,13 +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 %} %token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP @@ -59,15 +54,18 @@ data: DATA d=datas* { d } datas: - | l=label d=datas { lbls2 := Imap.add l !ram !lbls2; 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 } -label: - id=ID COLON { 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 i=instr { lbls2 := Imap.add l !pc !lbls2; i } + | labeli i=instr { i } | i=_instr { i } _instr: |