Ignore:
Timestamp:
Sep 22, 2010, 3:30:26 PM (9 years ago)
Author:
mulligan
Message:

Significantly improved implementation of ANL instructions.

File:
1 edited

Legend:

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

    r104 r105  
    762762    `BIT addr
    763763  | `NBIT addr as x ->
     764     let n1, n2 = from_byte addr in
    764765     let res =
    765       (match addr with
    766          (false,r1,r2,r3),n1 ->
    767            let addr = (int_of_vect (mk_byte7 r1 r2 r3 n1)) in
     766      (match from_nibble n1 with
     767         (false,r1,r2,r3) ->
     768           let addr = (int_of_vect (mk_byte7 r1 r2 r3 n2)) in
    768769           let addr' = vect_of_int ((addr / 8) + 32) `Seven in
    769770           let bit = get_bit (Byte7Map.find addr' status.low_internal_ram) (addr mod 8) in
     
    771772               None -> assert false
    772773             | Some bit' -> bit')
    773         | (true,r1,r2,r3),n1 ->
     774        | (true,r1,r2,r3) ->
    774775           (*CSC: SFR access, TO BE IMPLEMENTED *)
    775776           assert false)
     
    916917          else
    917918            status
     919 | `ANL (`U1(`A, ag)) ->
     920     let and_val = get_arg_8 status `A -&- get_arg_8 status ag in
     921       set_arg8 status and_val `A
     922 | `ANL (`U2((`DIRECT d), ag)) ->
     923     let and_val = get_arg_8 status (`DIRECT d) -&- get_arg_8 status ag in
     924       set_arg8 status and_val `A
     925 | `ANL (`U3 (`C, (`BIT b))) ->
     926     let and_val = get_cy_flag status && get_arg_1 status (`BIT b) in
     927       set_flags status and_val None (get_ov_flag status)
     928 | `ANL (`U3 (`C, (`NBIT b))) ->
     929     let and_val = get_cy_flag status && get_arg_1 status (`NBIT b) in
     930       set_flags status and_val None (get_ov_flag status)
    918931(*
    919  (* logical operations *)
    920  | ANL (`U1(`A, ag)) ->
    921      let (ac1,ac2,ac3,ac4),(ac5,ac6,ac7,ac8) = get_arg_8 status `A in
    922      let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = get_arg_8 status ag in
    923      let and_val = ((ac1 && ag1, ac2 && ag2, ac3 && ag3, ac4 && ag4),
    924                    (ac5 && ag5, ac6 && ag6, ac7 && ag7, ac8 && ag8)) in
    925        set_arg8 status and_val `A
    926  | ANL (`U2((`DIRECT d), ag)) ->
    927      let (d1,d2,d3,d4),(d5,d6,d7,d8) = get_arg_8 status (`DIRECT d) in
    928      let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = get_arg_8 status ag in
    929      let and_val = ((d1 && ag1, d2 && ag2, d3 && ag3, d4 && ag4),
    930                    (d5 && ag5, d6 && ag6, d7 && ag7, d8 && ag8)) in
    931        set_arg8 status and_val `A
    932  | ANL (`U3 (`C, (`BIT b))) ->
    933      let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
    934      let c = get_arg_1 status `C in
    935      let ag_val = get_arg_1 status (`BIT b) in
    936        { status with psw = (c && ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
    937  | ANL (`U3 (`C, (`NBIT b))) ->
    938      let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
    939      let c = get_arg_1 status `C in
    940      let ag_val = not (get_arg_1 status (`NBIT b)) in
    941        { status with psw = (c && ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
    942932 | ORL (`U1(`A, ag)) ->
    943933     let (ac1,ac2,ac3,ac4),(ac5,ac6,ac7,ac8) = get_arg_8 status `A in
Note: See TracChangeset for help on using the changeset viewer.