?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Dump Analyzer : Display B and C Registers Command' ??
MODULE dum$display_b_and_c_registers;

{ PURPOSE:
{   This module contains the command which displays the B and C registers that are stored in the
{   BXX/BX1 and CXX/CX1 records.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc due$exception_condition_codes
?? POP ??
*copyc clp$close_display
*copyc clp$convert_integer_to_rjstring
*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc dup$display_register_data
*copyc dup$find_record_list_entry
*copyc dup$new_page_procedure
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$set_status_abnormal
?? EJECT ??
*copyc duv$dump_environment_p
*copyc duv$execution_environment
*copyc duv$title_data
?? OLDTITLE ??
?? NEWTITLE := 'display_record_data', EJECT ??

{ PURPOSE:
{   This procedure displays data from the record.

  PROCEDURE display_record_data
    (    record_name: string (3);
         iou_index: string (1);
         entry_p: ^dut$de_other_record_entry;
     VAR display_control: clt$display_control);

    CONST
      c$number_of_bytes = 80;

    TYPE
      t$record_data = PACKED ARRAY [1 .. c$number_of_bytes] OF t$record_data_entry,

      t$record_data_entry = PACKED RECORD
        unused: 0 .. 0f(16),
        data: 0 .. 0ff(16),
      RECEND,

      t$unpacked_data = RECORD
        CASE boolean OF
        = TRUE =
          data: ARRAY [1 .. c$number_of_bytes] OF 0 .. 0ff(16),
        = FALSE =
          registers: ARRAY [0 .. 9] OF ARRAY [1 .. 8] OF 0 .. 0ff(16),
        CASEND,
      RECEND;

    VAR
      cell_p: ^cell,
      display_string: string (osc$max_string_size),
      ignore_status: ost$status,
      index: 0 .. 0ff(16),
      integer_string: ost$string,
      record_data_p: ^t$record_data,
      restart_file_seq_p: ^SEQ ( * ),
      string_length: integer,
      unpacked_data: t$unpacked_data;

    restart_file_seq_p := duv$execution_environment.data_file_p^.segment_pointer.sequence_pointer;
    cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p), entry_p^.first_byte);
    RESET restart_file_seq_p TO cell_p;

    IF #SIZE (t$record_data) > entry_p^.size THEN
      clp$put_display (display_control, 'ERROR - Not enough data in the record, data not displayed.',
            clc$trim, ignore_status);
      RETURN;  {---->
    IFEND;

    STRINGREP (display_string, string_length, record_name, ' - ', record_name(1), '-Registers:');
    clp$put_display (display_control, display_string (1, string_length), clc$trim, ignore_status);
    clp$put_display (display_control, ' ', clc$trim, ignore_status);
    STRINGREP (display_string, string_length, '  This record contains the pre-deadstart contents of the');
    clp$put_display (display_control, display_string (1, string_length), clc$trim, ignore_status);
    STRINGREP (display_string, string_length, '  ', record_name(1), '-Registers for IOU', iou_index, '.');
    clp$put_display (display_control, display_string (1, string_length), clc$trim, ignore_status);
    clp$put_display (display_control, ' ', clc$trim, ignore_status);

    NEXT record_data_p IN restart_file_seq_p;
    FOR index := 1 TO c$number_of_bytes DO
      unpacked_data.data [index] := record_data_p^ [index].data;
    FOREND;

    FOR index := 0 TO 9 DO
      clp$convert_integer_to_string (index, 10, FALSE, integer_string, ignore_status);
      STRINGREP (display_string, string_length, record_name(1),
            integer_string.value (1, integer_string.size));
      dup$display_register_data (display_string (1, string_length), unpacked_data.registers [index],
            display_control);
    FOREND;
    clp$put_display (display_control, ' ', clc$trim, ignore_status);

  PROCEND display_record_data;
?? OLDTITLE ??
?? NEWTITLE := 'dup$display_b_and_c_registers', EJECT ??

{ PURPOSE:
{   This procedure displays the B and C registers.

  PROCEDURE [XDCL] dup$display_b_and_c_registers
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE display_b_and_c_registers, disbacr (
{   output, o: file = $optional
{   title, t: string 1..31 = 'display_b_and_c_registers'
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??
  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$string_type_qualifier,
        default_value: string (27),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 9, 4, 7, 52, 19, 766],
    clc$command, 5, 3, 0, 0, 0, 0, 3, ''], [
    ['O                              ',clc$abbreviation_entry, 1],
    ['OUTPUT                         ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 3],
    ['T                              ',clc$abbreviation_entry, 2],
    ['TITLE                          ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [2, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_parameter, 0
  , 0],
{ PARAMETER 2
    [5, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 8,
  clc$optional_default_parameter, 0, 27],
{ PARAMETER 3
    [3, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$file_type]],
{ PARAMETER 2
    [[1, 0, clc$string_type], [1, 31, FALSE],
    '''display_b_and_c_registers'''],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];
?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$output = 1,
      p$title = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;

    VAR
      time_zone: ost$time_zone,
      data_displayed: boolean,
      data_value: clt$data_value,
      display_control: clt$display_control,
      entry_p: ^dut$de_other_record_entry,
      ignore_status: ost$status,
      output_display_opened: boolean,
      ring_attributes: amt$ring_attributes;

*copy dup$abort_handler
?? NEWTITLE := 'clean_up', EJECT ??

{ PURPOSE:
{   This procedure is called from the abort handler to close the file.

    PROCEDURE [INLINE] clean_up;

      VAR
        ignore_status: ost$status;

      IF output_display_opened THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND clean_up;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;  {---->
    IFEND;

    IF duv$dump_environment_p = NIL THEN
      osp$set_status_abnormal (duc$dump_analyzer_id, due$no_restart_file, '', status);
      RETURN;  {---->
    IFEND;

    output_display_opened := FALSE;
    osp$establish_block_exit_hndlr (^abort_handler);

   /display_opened/
    BEGIN

    { Prepare the output display file.

      IF pvt [p$output].specified THEN
        ring_attributes.r1 := #RING (^ring_attributes);
        ring_attributes.r2 := #RING (^ring_attributes);
        ring_attributes.r3 := #RING (^ring_attributes);
        clp$open_display_reference (pvt [p$output].value^.file_value^, ^dup$new_page_procedure, fsc$list,
              ring_attributes, display_control, status);
        IF NOT status.normal THEN
          EXIT /display_opened/;  {---->
        IFEND;
        output_display_opened := TRUE;
      ELSE
        display_control := duv$execution_environment.output_file.display_control;
        display_control.line_number := display_control.page_length + 1;
      IFEND;

      duv$title_data.build_title := TRUE;
      duv$title_data.command_name := pvt [p$title].value^.string_value^;

      data_displayed := FALSE;

      data_value.kind := clc$name;
      data_value.name_value := 'BXX';
      dup$find_record_list_entry (data_value, entry_p);
      IF entry_p <> NIL THEN
        data_displayed := TRUE;
        display_record_data ('BXX', '0', entry_p, display_control);
      IFEND;

      data_value.kind := clc$name;
      data_value.name_value := 'BX1';
      dup$find_record_list_entry (data_value, entry_p);
      IF entry_p <> NIL THEN
        data_displayed := TRUE;
        display_record_data ('BX1', '1', entry_p, display_control);
      IFEND;

      data_value.kind := clc$name;
      data_value.name_value := 'CXX';
      dup$find_record_list_entry (data_value, entry_p);
      IF entry_p <> NIL THEN
        data_displayed := TRUE;
        display_record_data ('CXX', '0', entry_p, display_control);
      IFEND;

      data_value.kind := clc$name;
      data_value.name_value := 'CX1';
      dup$find_record_list_entry (data_value, entry_p);
      IF entry_p <> NIL THEN
        data_displayed := TRUE;
        display_record_data ('CX1', '1', entry_p, display_control);
      IFEND;

      IF NOT data_displayed THEN
        osp$set_status_abnormal (duc$dump_analyzer_id, due$data_not_on_dump,
              'The BXX/BX1 and CXX/CX1 records are', status);
      IFEND;

    END /display_opened/;

    IF output_display_opened THEN
      clp$close_display (display_control, ignore_status);
    IFEND;
    osp$disestablish_cond_handler;

  PROCEND dup$display_b_and_c_registers;
MODEND dum$display_b_and_c_registers;
