Better support for assignment

This commit is contained in:
Dmitry Boulytchev 2019-04-11 17:31:45 +03:00
parent 7bf40bf26f
commit 061bd3c48d
2 changed files with 19 additions and 5 deletions

View file

@ -180,11 +180,20 @@ let compile env code =
| S _ | M _ -> [Mov (env'#loc x, eax); Mov (eax, s)]
| _ -> [Mov (env'#loc x, s)]
)
| ST x ->
let env' = env#variable x in
let s = env'#peek in
env',
(match s with
| S _ | M _ -> [Mov (s, eax); Mov (eax, env'#loc x)]
| _ -> [Mov (s, env'#loc x)]
)
| STA ->
call env ".sta" 3
| ST ->
| STI ->
let v, x, env' = env#pop2 in
env'#push x,
(match x with