Changeset 196 for Deliverables


Ignore:
Timestamp:
Oct 19, 2010, 10:55:54 AM (9 years ago)
Author:
mulligan
Message:

Improvements to processor status output. Now includes readout of main
utility registers (R0--R7).

Location:
Deliverables/D4.1
Files:
2 edited

Legend:

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

    r195 r196  
    233233  let (_,_,_,_),(_,_,_,p) = bits_of_byte status.psw in p
    234234
     235let get_address_of_register status (b1,b2,b3) =
     236 let bu,_bl = from_byte status.psw in
     237 let (_,_,rs1,rs0) = from_nibble bu in
     238 let base =
     239  match rs1,rs0 with
     240     false,false -> 0x00
     241   | false,true  -> 0x08
     242   | true,false  -> 0x10
     243   | true,true   -> 0x18
     244 in
     245   vect_of_int (base + int_of_vect (mk_nibble false b1 b2 b3)) `Seven
     246;;
     247
     248let get_register status reg =
     249  let addr = get_address_of_register status reg in
     250    Byte7Map.find addr status.low_internal_ram
     251;;
     252
    235253let string_of_status status =   
    236   let acc_str = string_of_vect status.acc in
    237   let b_str   = string_of_vect status.b in
    238   let psw_str = string_of_vect status.psw in
    239   let sp_str  = string_of_vect status.sp in
    240   let ip_str  = string_of_vect status.ip in
    241   let pc_str  = string_of_vect status.pc in
    242   let dpl_str = string_of_vect status.dpl in
    243   let dph_str = string_of_vect status.dph in
    244   let scn_str = string_of_vect status.scon in
    245   let sbf_str = string_of_vect status.sbuf in
     254  let acc_str = (string_of_int <*> int_of_vect $ status.acc) ^ " (" ^ string_of_vect status.acc ^ ")" in
     255  let b_str   = (string_of_int <*> int_of_vect $ status.b) ^ " (" ^ string_of_vect status.b ^ ")" in
     256  let psw_str = (string_of_int <*> int_of_vect $ status.psw) ^ " (" ^ string_of_vect status.psw ^ ")" in
     257  let sp_str  = (string_of_int <*> int_of_vect $ status.sp) ^ " (" ^ string_of_vect status.sp ^ ")" in
     258  let ip_str  = (string_of_int <*> int_of_vect $ status.ip) ^ " (" ^ string_of_vect status.ip ^ ")" in
     259  let pc_str  = (string_of_int <*> int_of_vect $ status.pc) ^ " (" ^ string_of_vect status.pc ^ ")" in
     260  let dpl_str = (string_of_int <*> int_of_vect $ status.dpl) ^ " (" ^ string_of_vect status.dpl ^ ")" in
     261  let dph_str = (string_of_int <*> int_of_vect $ status.dph) ^ " (" ^ string_of_vect status.dph ^ ")" in
     262  let scn_str = (string_of_int <*> int_of_vect $ status.scon) ^ " (" ^ string_of_vect status.scon ^ ")" in
     263  let sbf_str = (string_of_int <*> int_of_vect $ status.sbuf) ^ " (" ^ string_of_vect status.sbuf ^ ")" in
     264  let r0_str  = (string_of_int <*> int_of_vect $ get_register status (false, false, false)) ^ " (" ^ (string_of_vect $ get_register status (false, false, false)) ^ ")" in
     265  let r1_str  = (string_of_int <*> int_of_vect $ get_register status (false, false, true)) ^ " (" ^ (string_of_vect $ get_register status (false, false, true)) ^ ")" in
     266  let r2_str  = (string_of_int <*> int_of_vect $ get_register status (false, true, false)) ^ " (" ^ (string_of_vect $ get_register status (false, true, false)) ^ ")" in
     267  let r3_str  = (string_of_int <*> int_of_vect $ get_register status (false, true, true)) ^ " (" ^ (string_of_vect $ get_register status (false, true, true)) ^ ")" in
     268  let r4_str  = (string_of_int <*> int_of_vect $ get_register status (true, false, false)) ^ " (" ^ (string_of_vect $ get_register status (true, false, false)) ^ ")" in
     269  let r5_str  = (string_of_int <*> int_of_vect $ get_register status (true, false, true)) ^ " (" ^ (string_of_vect $ get_register status (true, false, true)) ^ ")" in
     270  let r6_str  = (string_of_int <*> int_of_vect $ get_register status (true, true, false)) ^ " (" ^ (string_of_vect $ get_register status (true, true, false)) ^ ")" in
     271  let r7_str  = (string_of_int <*> int_of_vect $ get_register status (true, true, true)) ^ " (" ^ (string_of_vect $ get_register status (true, true, true)) ^ ")" in
    246272    "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" ^
    247273    " Processor status:                               \n" ^
     
    250276    "   B   : " ^ b_str   ^ "\n"                          ^
    251277    "   PSW : " ^ psw_str ^ "\n"                          ^
    252     "    where                                        \n" ^
     278    "    with flags set as                            \n" ^
    253279    "     CY  : " ^ (string_of_bool <*> get_cy_flag $ status) ^ "\n" ^
    254280    "     AC  : " ^ (string_of_bool <*> get_ac_flag $ status) ^ "\n" ^
     
    266292    "   SCON: " ^ scn_str ^ "\n"                          ^
    267293    "   SBUF: " ^ sbf_str ^ "\n"                          ^
     294    "   Registers:                                    \n" ^
     295    "    R0 : " ^ r0_str  ^ "\n"                          ^
     296    "    R1 : " ^ r1_str  ^ "\n"                          ^
     297    "    R2 : " ^ r2_str  ^ "\n"                          ^
     298    "    R3 : " ^ r3_str  ^ "\n"                          ^
     299    "    R4 : " ^ r4_str  ^ "\n"                          ^
     300    "    R5 : " ^ r5_str  ^ "\n"                          ^
     301    "    R6 : " ^ r6_str  ^ "\n"                          ^
     302    "    R7 : " ^ r7_str  ^ "\n"                          ^
    268303    "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
    269304(* timings taken from SIEMENS *)
     
    858893                assembly1 (`LCALL (`ADDR16 (vect_of_int pc_offset `Sixteen)))
    859894          | #instruction as i -> assembly1 i) l), costs
    860 ;;
    861 
    862 let get_address_of_register status (b1,b2,b3) =
    863  let bu,_bl = from_byte status.psw in
    864  let (_,_,rs1,rs0) = from_nibble bu in
    865  let base =
    866   match rs1,rs0 with
    867      false,false -> 0x00
    868    | false,true  -> 0x08
    869    | true,false  -> 0x10
    870    | true,true   -> 0x18
    871  in
    872    vect_of_int (base + int_of_vect (mk_nibble false b1 b2 b3)) `Seven
    873 ;;
    874 
    875 let get_register status reg =
    876   let addr = get_address_of_register status reg in
    877     Byte7Map.find addr status.low_internal_ram
    878895;;
    879896
  • Deliverables/D4.1/test.ml

    r195 r196  
    1414     match instr with
    1515       `SJMP (`REL b) ->
    16           if int_of_vect b = 254 then
     16          if int_of_vect b = 254 || int_of_vect b = 0 then
    1717            prerr_endline <*> string_of_status $ status
    1818          else
Note: See TracChangeset for help on using the changeset viewer.