Ignore:
Timestamp:
Sep 14, 2010, 3:12:52 PM (9 years ago)
Author:
mulligan
Message:

DA instruction implemented: pretty complex!

File:
1 edited

Legend:

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

    r71 r72  
    780780      let status = { status with acc = q ; b = r } in
    781781       set_flags status false None false
     782 | DA `A ->
     783     let (b1,b2,b3,b4),(b5,b6,b7,b8) = status.acc in
     784     let acc_int_val = int_of_byte ((b1,b2,b3,b4),(b5,b6,b7,b8)) in
     785     let (cy, ac, fo, rs1),(rs0, ov, ud, p) = status.psw in
     786     let lower_nibble_int_val = int_of_nibble (b5,b6,b7,b8) in
     787     let upper_nibble_int_val = int_of_nibble (b1,b2,b3,b4) in
     788       if lower_nibble_int_val > 9 or ac = true then
     789         let acc_int_val = acc_int_val + 6 in
     790           if lower_nibble_int_val > 15 then
     791             let upper_nibble_int_val = upper_nibble_int_val + 6 in
     792             let upper_nibble = nibble_of_int upper_nibble_int_val in
     793             let lower_nibble = nibble_of_int lower_nibble_int_val in
     794             let new_psw = (true, ac, fo, rs1),(rs0, ov, ud, p) in
     795               { status with acc = (upper_nibble, lower_nibble); psw = new_psw }
     796           else
     797             if upper_nibble_int_val > 9 then
     798               let upper_nibble_int_val = upper_nibble_int_val + 6 in
     799                 if upper_nibble_int_val > 15 then
     800                   let upper_nibble = nibble_of_int upper_nibble_int_val in
     801                   let lower_nibble = nibble_of_int lower_nibble_int_val in
     802                   let new_psw = (true, ac, fo, rs1),(rs0, ov, ud, p) in
     803                     { status with acc = (upper_nibble, lower_nibble); psw = new_psw }
     804                 else
     805                   let upper_nibble = nibble_of_int upper_nibble_int_val in
     806                   let lower_nibble = nibble_of_int lower_nibble_int_val in
     807                     { status with acc = (upper_nibble, lower_nibble) }
     808             else
     809               let upper_nibble = nibble_of_int upper_nibble_int_val in
     810               let lower_nibble = nibble_of_int lower_nibble_int_val in
     811                 { status with acc = (upper_nibble, lower_nibble) }
     812       else
     813         let upper_nibble = nibble_of_int upper_nibble_int_val in
     814         let lower_nibble = nibble_of_int lower_nibble_int_val in
     815           { status with acc = (upper_nibble, lower_nibble) }
    782816(*
    783817 | ANL (`U1 (`A, ag)) ->
Note: See TracChangeset for help on using the changeset viewer.