Changeset 2100


Ignore:
Timestamp:
Jun 18, 2012, 5:16:08 PM (5 years ago)
Author:
tranquil
Message:

temporary solution to a bug where operations on spilled registers disrupted the carry bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/ERTL/ERTLToLTLI.ml

    r1589 r2100  
    4949  let adjust off = locals - (off + I8051.int_size)
    5050
    51   (* side-effects : dpl, dph, a *)
     51  (* side-effects : dpl, dph, a, st1 if adjust off <> 0 *)
    5252  let move_sp_to_dptr off l =
    5353    let off = adjust off in
     
    5858      LTL.St_to_acc (I8051.spl, l)
    5959    else
     60      let l = generate (LTL.St_op2 (I8051.Sub, LTL.Reg I8051.st1, l)) in
     61      let l = generate (LTL.St_clear_carry l) in
     62      let l = generate (LTL.St_int (I8051.a, 0, l)) in
     63      (* ^ restore the carry bit ^ *)
    6064      let l = generate (LTL.St_from_acc (I8051.dph, l)) in
    6165      let l = generate (LTL.St_op2 (I8051.Addc, LTL.Reg I8051.sph, l)) in
     
    6367      let l = generate (LTL.St_from_acc (I8051.dpl, l)) in
    6468      let l = generate (LTL.St_op2 (I8051.Add, LTL.Reg I8051.spl, l)) in
    65       LTL.St_int (I8051.a, off, l)
    66 
    67 
    68   (* side-effects : dpl, dph, a *)
     69      let l = generate (LTL.St_int (I8051.a, off, l)) in
     70      let l = generate (LTL.St_from_acc (I8051.st1, l)) in
     71      let l = generate (LTL.St_op2 (I8051.Addc, LTL.Imm 0, l)) in
     72      LTL.St_int (I8051.a, 0, l)
     73      (* ^ save the carry bit ^ *)
     74
     75
     76  (* side-effects : dpl, dph, a, st1 if adjust off <> 0 *)
    6977  let get_stack r off l =
    7078    let l =
     
    7381    move_sp_to_dptr off l
    7482
    75   (* side-effects : dpl, dph, a *)
     83  (* side-effects : dpl, dph, a, st1 if adjust off <> 0 *)
    7684  let set_stack_not_a off r l =
    7785    let l = generate (LTL.St_store l) in
     
    7987    move_sp_to_dptr off l
    8088
    81   (* side-effects : dpl, dph, st0 *)
     89  (* side-effects : dpl, dph, st0, st1 if adjust off <> 0 *)
    8290  let set_stack_a off l =
    8391    let l = generate (set_stack_not_a off I8051.st0 l) in
    8492    LTL.St_from_acc (I8051.st0, l)
    8593
    86   (* side-effects : dpl, dph, st0 if r = a, a if r != a *)
     94  (* side-effects : dpl, dph, st0 if r = a, a if r != a, st1 if adjust off <> 0 *)
    8795  let set_stack off r =
    8896    if I8051.eq_reg r I8051.a then set_stack_a off else
    8997      set_stack_not_a off r
    9098
    91   (* side-effects : dpl, dph, a *)
     99  (* side-effects : dpl, dph, a, st1 if adjust off <> 0 *)
    92100  let set_stack_int off k l =
    93101    let l = generate (LTL.St_store l) in
     
    96104
    97105
    98   (* side-effects : (dpl, dph, a) if dest spilled *)
     106  (* side-effects : (dpl, dph, a, st1 if adjust off <> 0) if dest spilled *)
    99107  let move_int (dest : decision) (k : int) l =
    100108    match dest with
     
    103111
    104112  (* side-effects : none if dest = src, a if both colored,
    105                     (dpl, dph, a) if src spilled or src imm and dest spilled,
    106                     (dpl, dph, a, st0) if dest spilled *)
     113                    (dpl, dph, a, st1 if adjust off <> 0) if src spilled or src imm and dest spilled,
     114                    (dpl, dph, a, st0, st1 if adjust off <> 0) if dest spilled *)
    107115  let move (dest : decision) (src : argument) l =
    108116    match dest, src with
Note: See TracChangeset for help on using the changeset viewer.