Ignore:
Timestamp:
Sep 22, 2010, 4:28:19 PM (9 years ago)
Author:
mulligan
Message:

Rotation and SWAP instructions refactored.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/ASMInterpret.ml

    r108 r109  
    898898      let b = int_of_vect status.b in
    899899      if b = 0 then
    900         (* CSC: acc and b undefined! we leave them as they are... *)
     900        (* CSC: ACC and B undefined! We leave them as they are. *)
    901901        set_flags status false None true
    902902      else
     
    954954   | `CPL `C -> set_arg1 status (not (get_arg_1 status `C)) `C
    955955   | `CPL (`BIT b) -> set_arg1 status (not (get_arg_1 status (`BIT b))) (`BIT b)
     956   | `RL `A -> { status with acc = rotate_left status.acc }
     957   | `RLC `A ->
     958        let old_cy = get_cy_flag status in
     959        let n1, n2 = from_byte status.acc in
     960        let (b1,b2,b3,b4),(b5,b6,b7,b8) = from_nibble n1, from_nibble n2 in
     961        let status = set_arg1 status b1 `C in
     962          { status with acc = mk_byte (mk_nibble b2 b3 b4 b5) (mk_nibble b6 b7 b8 old_cy) }
     963   | `RR `A -> { status with acc = rotate_right status.acc }
     964   | `RRC `A ->
     965        let old_cy = get_cy_flag status in
     966        let n1, n2 = from_byte status.acc in
     967        let (b1,b2,b3,b4),(b5,b6,b7,b8) = from_nibble n1, from_nibble n2 in
     968        let status = set_arg1 status b8 `C in
     969          { status with acc = mk_byte (mk_nibble old_cy b1 b2 b3) (mk_nibble b4 b5 b6 b7) }
     970   | `SWAP `A ->
     971        let (acc_nibble_upper, acc_nibble_lower) = from_byte status.acc in
     972          { status with acc = mk_byte acc_nibble_lower acc_nibble_upper }
    956973(*
    957  | RL `A ->
    958      let (b1,b2,b3,b4),(b5,b6,b7,b8) = status.acc in
    959        { status with acc = (b2,b3,b4,b5),(b6,b7,b8,b1) }
    960  | RLC `A ->
    961      let old_carry = carr status in
    962      let (b1,b2,b3,b4),(b5,b6,b7,b8) = status.acc in
    963      let new_status = set_arg1 status b1 `C in
    964        { new_status with acc = (b2,b3,b4,b5),(b6,b7,b8,old_carry) }
    965  | RR `A ->
    966      let (b1,b2,b3,b4),(b5,b6,b7,b8) = status.acc in
    967        { status with acc = (b8,b1,b2,b3),(b4,b5,b6,b7) }
    968  | RRC `A ->
    969      let old_carry = carr status in
    970      let (b1,b2,b3,b4),(b5,b6,b7,b8) = status.acc in
    971      let new_status = set_arg1 status b8 `C in
    972        { new_status with acc = (old_carry,b1,b2,b3),(b4,b5,b6,b7) }
    973  | SWAP `A ->
    974      let (acc_n_1, acc_n_2) = status.acc in
    975        { status with acc = (acc_n_2, acc_n_1) }
    976974 | MOV(`U1(b1, b2)) ->
    977975                let arg = get_arg_8 status b2 in
Note: See TracChangeset for help on using the changeset viewer.