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

ANL, ORL and XRL instructions implemented.

File:
1 edited

Legend:

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

    r79 r80  
    732732;;
    733733
     734let xor b1 b2 =
     735  if b1 = true && b2 = true then
     736    false
     737  else if b1 = false && b2 = false then
     738    false
     739  else true
     740;;
     741
    734742let execute1 status =
    735743 let instr,pc,ticks = fetch status.code_memory status.pc in
     
    816824         let lower_nibble = nibble_of_int lower_nibble_int_val in
    817825           { status with acc = (upper_nibble, lower_nibble) }
     826 (* logical operations *)
    818827 | ANL (`U1(`A, ag)) ->
    819828     let (ac1,ac2,ac3,ac4),(ac5,ac6,ac7,ac8) = fetch_arg8 status `A in
     
    822831                   (ac5 && ag5, ac6 && ag6, ac7 && ag7, ac8 && ag8)) in
    823832       set_arg8 status and_val `A
    824 (*
    825  (* logical operations *)
    826  | ANL of
    827     (acc * [ reg | direct | indirect | data ],
    828      direct * [ acc | data ],
    829      carry * [ bit | nbit]) union3
    830  | ORL of
    831     (acc * [ reg | direct | indirect ],
    832      direct * [ acc | data ],
    833      carry * [ bit | nbit]) union3
    834  | XRL of
    835     (acc * [ reg | direct | indirect ],
    836      direct * [ acc | data ]) union2 *)
     833 | ANL (`U2((`DIRECT d), ag)) ->
     834     let (d1,d2,d3,d4),(d5,d6,d7,d8) = fetch_arg8 status (`DIRECT d) in
     835     let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = fetch_arg8 status ag in
     836     let and_val = ((d1 && ag1, d2 && ag2, d3 && ag3, d4 && ag4),
     837                   (d5 && ag5, d6 && ag6, d7 && ag7, d8 && ag8)) in
     838       set_arg8 status and_val `A
     839 | ANL (`U3 (`C, (`BIT b))) ->
     840     let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
     841     let c = fetch_arg1 status `C in
     842     let ag_val = fetch_arg1 status (`BIT b) in
     843       { status with psw = (c && ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
     844 | ANL (`U3 (`C, (`NBIT b))) ->
     845     let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
     846     let c = fetch_arg1 status `C in
     847     let ag_val = not (fetch_arg1 status (`NBIT b)) in
     848       { status with psw = (c && ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
     849 | ORL (`U1(`A, ag)) ->
     850     let (ac1,ac2,ac3,ac4),(ac5,ac6,ac7,ac8) = fetch_arg8 status `A in
     851     let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = fetch_arg8 status ag in
     852     let and_val = ((ac1 || ag1, ac2 || ag2, ac3 || ag3, ac4 || ag4),
     853                   (ac5 || ag5, ac6 || ag6, ac7 || ag7, ac8 || ag8)) in
     854       set_arg8 status and_val `A
     855 | ORL (`U2((`DIRECT d), ag)) ->
     856     let (d1,d2,d3,d4),(d5,d6,d7,d8) = fetch_arg8 status (`DIRECT d) in
     857     let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = fetch_arg8 status ag in
     858     let and_val = ((d1 || ag1, d2 || ag2, d3 || ag3, d4 || ag4),
     859                   (d5 || ag5, d6 || ag6, d7 || ag7, d8 || ag8)) in
     860       set_arg8 status and_val `A
     861 | ORL (`U3 (`C, (`BIT b))) ->
     862     let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
     863     let c = fetch_arg1 status `C in
     864     let ag_val = fetch_arg1 status (`BIT b) in
     865       { status with psw = (c || ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
     866 | ORL (`U3 (`C, (`NBIT b))) ->
     867     let (cy,ac,fo,rs1),(rs0,ov,ud,p) = status.psw in
     868     let c = fetch_arg1 status `C in
     869     let ag_val = not (fetch_arg1 status (`NBIT b)) in
     870       { status with psw = (c || ag_val,ac,fo,rs1),(rs0,ov,ud,p) }
     871 | XRL (`U1(`A, ag)) ->
     872     let (ac1,ac2,ac3,ac4),(ac5,ac6,ac7,ac8) = fetch_arg8 status `A in
     873     let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = fetch_arg8 status ag in
     874     let and_val = ((xor ac1 ag1, xor ac2 ag2, xor ac3 ag3, xor ac4 ag4),
     875                   (xor ac5 ag5, xor ac6 ag6, xor ac7 ag7, xor ac8 ag8)) in
     876       set_arg8 status and_val `A
     877 | XRL (`U2((`DIRECT d), ag)) ->
     878     let (d1,d2,d3,d4),(d5,d6,d7,d8) = fetch_arg8 status (`DIRECT d) in
     879     let (ag1,ag2,ag3,ag4),(ag5,ag6,ag7,ag8) = fetch_arg8 status ag in
     880     let and_val = ((xor d1 ag1, xor d2 ag2, xor d3 ag3, xor d4 ag4),
     881                   (xor d5 ag5, xor d6 ag6, xor d7 ag7, xor d8 ag8)) in
     882       set_arg8 status and_val `A
    837883 | CLR `A -> set_arg8 status
    838884     ((false,false,false,false),(false,false,false,false)) `A
Note: See TracChangeset for help on using the changeset viewer.