Ignore:
Timestamp:
Sep 23, 2010, 11:46:51 AM (9 years ago)
Author:
mulligan
Message:

Sorted out inconsistent ocaml state (???). Refactored ACALL.

File:
1 edited

Legend:

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

    r116 r117  
    10531053  | `RET ->
    10541054      (* DPM: What happens when we underflow? *)
    1055       let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
    1056       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    1057       let status = { status with sp = new_sp } in
    1058       let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
    1059       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    1060       let status = { status with sp = new_sp } in
    1061         { status with pc = mk_byte high_bits low_bits }
     1055       let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1056       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
     1057       let status = { status with sp = new_sp } in
     1058       let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1059       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
     1060       let status = { status with sp = new_sp } in
     1061         { status with pc = mk_byte high_bits low_bits }
    10621062  | `RETI ->
    1063       let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
    1064       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    1065       let status = { status with sp = new_sp } in
    1066       let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
    1067       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    1068       let status = { status with sp = new_sp } in
    1069         { status with pc = mk_byte high_bits low_bits }
     1063       let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1064       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
     1065       let status = { status with sp = new_sp } in
     1066       let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1067       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
     1068       let status = { status with sp = new_sp } in
     1069         { status with pc = mk_byte high_bits low_bits }
     1070  | `ACALL (`ADDR11 a) ->
     1071       let cry, new_pc = half_add status.pc (vect_of_int 2 `Sixteen) in
     1072       let status = { status with pc = new_pc } in
     1073       let cry, new_sp = half_add status.sp (vect_of_int 1 `Eight) in
     1074       let status = { status with sp = new_sp } in
     1075       let pc_upper_byte, pc_lower_byte = from_byte status.pc in
     1076       let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_lower_byte status.low_internal_ram in
     1077       let status = { status with low_internal_ram = lower_mem } in
     1078       let cry, new_sp = half_add status.sp (vect_of_int 1 `Eight) in
     1079       let status = { status with sp = new_sp } in
     1080       let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_upper_byte status.low_internal_ram in
     1081       let status = { status with low_internal_ram = lower_mem } in
     1082       let n1, n2 = from_byte pc_upper_byte in
     1083       let (b1,b2,b3,b) = from_word11 a in
     1084       let (p1,p2,p3,p4),(p5,_,_,_) = from_nibble n1, from_nibble n2 in
     1085       let addr = mk_word (mk_byte (mk_nibble p1 p2 p3 p4) (mk_nibble p5 b1 b2 b3)) pc_lower_byte in
     1086         { status with pc = addr }
    10701087(*
    1071  | ACALL (`ADDR11 (b1,b2,b3,b)) ->
    1072      let status = { status with pc = status.pc ++ 2 } in
    1073      let status = { status with sp = byte_of_int ((int_of_byte status.sp) + 1) } in
    1074      let (bh, bl) = status.pc in
    1075      let lower_mem = Byte7Map.add (byte7_of_byte status.sp) bl status.low_internal_ram in
    1076      let status = { status with low_internal_ram = lower_mem } in
    1077      let status = { status with sp = byte_of_int ((int_of_byte status.sp) + 1) } in
    1078      let lower_mem = Byte7Map.add (byte7_of_byte status.sp) bh status.low_internal_ram in
    1079      let status = { status with low_internal_ram = lower_mem } in
    1080      let ((p1,p2,p3,p4),(p5,_,_,_)),b = status.pc in
    1081      let addr = (((p1,p2,p3,p4),(p5,b1,b2,b3)),b) in
    1082        { status with pc = addr }
    10831088 | LCALL (`ADDR16 addr) ->
    10841089     let status = { status with pc = status.pc ++ 3 } in
Note: See TracChangeset for help on using the changeset viewer.