Changeset 114


Ignore:
Timestamp:
Sep 23, 2010, 10:54:58 AM (9 years ago)
Author:
mulligan
Message:

Noticed redundancy in ANL and ORL instructions, removed. Introduced
Haskell style $ function application and tidied code.

File:
1 edited

Legend:

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

    r113 r114  
    854854;;
    855855
     856let ($) f x = f x
     857
    856858let execute1 status =
    857859 let instr,pc,ticks = fetch status.code_memory status.pc in
     
    925927        let and_val = get_arg_8 status (`DIRECT d) -&- get_arg_8 status ag in
    926928          set_arg8 status and_val `A
    927    | `ANL (`U3 (`C, (`BIT b))) ->
    928         let and_val = get_cy_flag status && get_arg_1 status (`BIT b) in
    929           set_flags status and_val None (get_ov_flag status)
    930    | `ANL (`U3 (`C, (`NBIT b))) ->
    931         let and_val = get_cy_flag status && get_arg_1 status (`NBIT b) in
     929   | `ANL (`U3 (`C, b)) ->
     930        let and_val = get_cy_flag status && get_arg_1 status b in
    932931          set_flags status and_val None (get_ov_flag status)
    933932   | `ONL (`U1(`A, ag)) ->
     
    937936        let or_val = get_arg_8 status (`DIRECT d) -|- get_arg_8 status ag in
    938937          set_arg8 status or_val `A
    939    | `ONL (`U3 (`C, (`BIT b))) ->
    940         let or_val = get_cy_flag status || get_arg_1 status (`BIT b) in
    941           set_flags status or_val None (get_ov_flag status)
    942    | `ONL (`U3 (`C, (`NBIT b))) ->
    943         let or_val = get_cy_flag status || get_arg_1 status (`NBIT b) in
     938   | `ONL (`U3 (`C, b)) ->
     939        let or_val = get_cy_flag status || get_arg_1 status b in
    944940          set_flags status or_val None (get_ov_flag status)
    945941   | `XRL (`U1(`A, ag)) ->
     
    953949   | `CLR ((`BIT b) as a) -> set_arg1 status false a
    954950   | `CPL `A -> { status with acc = complement status.acc }
    955    | `CPL `C -> set_arg1 status (not (get_arg_1 status `C)) `C
    956    | `CPL (`BIT b) -> set_arg1 status (not (get_arg_1 status (`BIT b))) (`BIT b)
     951   | `CPL `C -> set_arg1 status (not $ get_arg_1 status `C) `C
     952   | `CPL ((`BIT _) as b) -> set_arg1 status (not $ get_arg_1 status b) b
    957953   | `RL `A -> { status with acc = rotate_left status.acc }
    958954   | `RLC `A ->
     
    10161012      let status = set_arg8 status old_acc arg in
    10171013        { status with acc = old_arg }
    1018   | `XCHD(`A, (`INDIRECT i)) ->
    1019       let acc_upper_nibble, acc_lower_nibble = from_byte (get_arg_8 status `A) in
    1020       let ind_upper_nibble, ind_lower_nibble = from_byte (get_arg_8 status (`INDIRECT i)) in
     1014  | `XCHD(`A, i) ->
     1015      let acc_upper_nibble, acc_lower_nibble = from_byte $ get_arg_8 status `A in
     1016      let ind_upper_nibble, ind_lower_nibble = from_byte $ get_arg_8 status i in
    10211017      let new_acc = mk_byte acc_upper_nibble ind_lower_nibble in
    10221018      let new_reg = mk_byte ind_upper_nibble acc_lower_nibble in
    10231019      let status = { status with acc = new_acc } in
    1024         set_arg8 status new_reg (`INDIRECT i)
     1020        set_arg8 status new_reg i
    10251021 (* program branching *)
    10261022  | `JC (`REL rel) ->
     
    10361032      else
    10371033        status
     1034  | `JB (b, (`REL rel)) ->
     1035      if get_arg_1 status b then
     1036        let cry, new_pc = half_add status.pc rel in
     1037          { status with pc = new_pc }
     1038      else
     1039        status
     1040  | `JNB (b, (`REL rel)) ->
     1041      if not $ get_arg_1 status b then
     1042        let cry, new_pc = half_add status.pc rel in
     1043          { status with pc = new_pc }
     1044      else
     1045        status
    10381046(*
    1039  | JB ((`BIT b1), (`REL rel)) ->
    1040      let val_bit = get_arg_1 status (`BIT b1) in
    1041        if val_bit = true then
    1042          { status with pc = status.pc ++ (int_of_byte rel) }
    1043        else
    1044          status
    1045  | JNB ((`BIT b1), (`REL rel)) ->
    1046      let val_bit = get_arg_1 status (`BIT b1) in
    1047        if val_bit = false then
    1048          { status with pc = status.pc ++ (int_of_byte rel) }
    1049        else
    1050          status
    10511047 | JBC ((`BIT b1), (`REL rel)) ->
    10521048    let val_bit = get_arg_1 status (`BIT b1) in
Note: See TracChangeset for help on using the changeset viewer.