Changeset 144


Ignore:
Timestamp:
Sep 29, 2010, 7:03:08 PM (9 years ago)
Author:
sacerdot
Message:

The sp can also point to upper internal ram. Fixed everywhere.

Location:
Deliverables/D4.1
Files:
3 edited

Legend:

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

    r143 r144  
    946946let ($) f x = f x
    947947
     948let read_at_sp status =
     949 let n1,n2 = from_byte status.sp in
     950 let m,r1,r2,r3 = from_nibble n1 in
     951  Byte7Map.find (mk_byte7 r1 r2 r3 n2)
     952   (if m then status.low_internal_ram else status.high_internal_ram)
     953;;
     954
     955let write_at_sp status v =
     956 let n1,n2 = from_byte status.sp in
     957 match from_nibble n1 with
     958    true,r1,r2,r3 ->
     959     let memory =
     960      Byte7Map.add (mk_byte7 r1 r2 r3 n2) v status.low_internal_ram
     961     in
     962      { status with low_internal_ram = memory }
     963  | false,r1,r2,r3 ->
     964     let memory =
     965      Byte7Map.add (mk_byte7 r1 r2 r3 n2) v status.high_internal_ram
     966     in
     967      { status with high_internal_ram = memory }
     968;;
     969
    948970let execute1 status =
    949971 let instr,pc,ticks = fetch status.code_memory status.pc in
     
    10891111       let cry,new_sp = half_add status.sp (vect_of_int 1 `Eight) in
    10901112       let status = { status with sp = new_sp } in
    1091        let memory = Byte7Map.add (byte7_of_byte status.sp) b status.low_internal_ram in
    1092          { status with low_internal_ram = memory }
     1113        write_at_sp status b
    10931114  | `POP (`DIRECT b) ->
    1094        let contents = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1115       let contents = read_at_sp status in
    10951116       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    10961117       let status = { status with sp = new_sp } in
     
    11431164  | `RET ->
    11441165      (* DPM: What happens when we underflow? *)
    1145        let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1166       let high_bits = read_at_sp status in
    11461167       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    11471168       let status = { status with sp = new_sp } in
    1148        let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1169       let low_bits = read_at_sp status in
    11491170       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    11501171       let status = { status with sp = new_sp } in
    11511172         { status with pc = mk_word high_bits low_bits }
    11521173  | `RETI ->
    1153        let high_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1174       let high_bits = read_at_sp status in
    11541175       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    11551176       let status = { status with sp = new_sp } in
    1156        let low_bits = Byte7Map.find (byte7_of_byte status.sp) status.low_internal_ram in
     1177       let low_bits = read_at_sp status in
    11571178       let new_sp,_,_,_ = subb8_with_c status.sp (vect_of_int 1 `Eight) false in
    11581179       let status = { status with sp = new_sp } in
     
    11641185       let status = { status with sp = new_sp } in
    11651186       let pc_upper_byte, pc_lower_byte = from_word status.pc in
    1166        let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_lower_byte status.low_internal_ram in
    1167        let status = { status with low_internal_ram = lower_mem } in
     1187       let status = write_at_sp status pc_lower_byte in
    11681188       let cry, new_sp = half_add status.sp (vect_of_int 1 `Eight) in
    11691189       let status = { status with sp = new_sp } in
    1170        let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_upper_byte status.low_internal_ram in
    1171        let status = { status with low_internal_ram = lower_mem } in
     1190       let status = write_at_sp status pc_upper_byte in
    11721191       let n1, n2 = from_byte pc_upper_byte in
    11731192       let (b1,b2,b3,_) = from_word11 a in
     
    11811200       let status = { status with sp = new_sp } in
    11821201       let pc_upper_byte, pc_lower_byte = from_word status.pc in
    1183        let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_upper_byte status.low_internal_ram in
    1184        let status = { status with low_internal_ram = lower_mem } in
     1202       let status = write_at_sp status pc_upper_byte in
    11851203       let cry, new_sp = half_add status.sp (vect_of_int 1 `Eight) in
    11861204       let status = { status with sp = new_sp } in
    1187        let lower_mem = Byte7Map.add (byte7_of_byte status.sp) pc_lower_byte status.low_internal_ram in
    1188        let status = { status with low_internal_ram = lower_mem } in
     1205       let status = write_at_sp status pc_lower_byte in
    11891206         { status with pc = addr }
    11901207  | `AJMP (`ADDR11 a) ->
  • Deliverables/D4.1/Physical.ml

    r128 r144  
    3737    false -> 0
    3838  | true -> 1
    39 
    40 let byte7_of_byte b =
    41   let n1,n2 = from_byte b in
    42     match from_nibble n1 with
    43       (false,b1,b2,b3) -> mk_byte7 b1 b2 b3 n2
    44     | _ -> raise Byte7_conversion
    4539
    4640let add8_with_c (b1 : [`Eight] vect) (b2 : [`Eight] vect) (c : bit) =
  • Deliverables/D4.1/Physical.mli

    r128 r144  
    1616module WordMap : Map with type key = word
    1717
    18 val byte7_of_byte: byte -> byte7
    1918val int_of_bit: bit -> int
    2019
Note: See TracChangeset for help on using the changeset viewer.